From 8dd0932302286425dc28410a0ff3fb3dc4eb5434 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 28 Apr 2024 21:29:40 +0100 Subject: [PATCH 001/422] Silence compiler warnings --- src/dfu.c | 8 ++++---- src/flip2.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dfu.c b/src/dfu.c index bfc6bdf2..2b13f584 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -394,10 +394,10 @@ void dfu_show_info(struct dfu_dev *dfu) msg_info(" USB Product : 0x%04hX\n", (unsigned short) dfu->dev_desc.idProduct); - msg_info(" USB Release : %hu.%hu.%hu\n", - ((unsigned short) dfu->dev_desc.bcdDevice >> 8) & 0xFF, - ((unsigned short) dfu->dev_desc.bcdDevice >> 4) & 0xF, - ((unsigned short) dfu->dev_desc.bcdDevice >> 0) & 0xF); + msg_info(" USB Release : %u.%u.%u\n", + (dfu->dev_desc.bcdDevice >> 8) & 0xFF, + (dfu->dev_desc.bcdDevice >> 4) & 0xF, + (dfu->dev_desc.bcdDevice >> 0) & 0xF); if (dfu->serno_str != NULL) msg_info(" USB Serial No : %s\n", dfu->serno_str); diff --git a/src/flip2.c b/src/flip2.c index 8aaf6b2c..50bb486f 100644 --- a/src/flip2.c +++ b/src/flip2.c @@ -555,9 +555,9 @@ static void flip2_show_info(struct flip2 *flip2) { (char) (flip2->part_rev / 26 - 1 + 'A'), (char) (flip2->part_rev % 26 + 'A')); - msg_info(" Bootloader version : 2.%hu.%hu\n", - ((unsigned short) flip2->boot_ver >> 4) & 0xF, - ((unsigned short) flip2->boot_ver >> 0) & 0xF); + msg_info(" Bootloader version : 2.%u.%u\n", + (flip2->boot_ver >> 4) & 0xF, + (flip2->boot_ver >> 0) & 0xF); msg_info(" USB max packet size : %hu\n", (unsigned short) flip2->dfu->dev_desc.bMaxPacketSize0); @@ -778,7 +778,7 @@ flip2_read_max1k_status: if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) && status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF)) { - pmsg_error("address out of range [0x%04hX,0x%04hX]\n", offset, offset+size-1); + pmsg_error("address out of range [0x%04X,0x%04X]\n", offset, (offset+size-1) & 0xffff); } else pmsg_error("DFU status %s\n", flip2_status_str(&status)); dfu_clrstatus(dfu); @@ -836,7 +836,7 @@ static int flip2_write_max1k(struct dfu_dev *dfu, if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) && status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF)) { - pmsg_error("address out of range [0x%04hX,0x%04hX]\n", offset, offset+size-1); + pmsg_error("address out of range [0x%04X,0x%04X]\n", offset, (offset+size-1) & 0xffff); } else pmsg_error("DFU status %s\n", flip2_status_str(&status)); dfu_clrstatus(dfu); From 54cf8717f091ea9b5e0f13af74cddaddc1b1a43a Mon Sep 17 00:00:00 2001 From: RoboSchmied Date: Thu, 2 May 2024 00:23:18 +0200 Subject: [PATCH 002/422] Fix: 7 typos Co-authored-by: RoAGmer Signed-off-by: Michael Seibt --- src/config.c | 2 +- src/fileio.c | 8 ++++---- src/jtagmkII_private.h | 2 +- src/term.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/config.c b/src/config.c index b9b9adb5..3a3ccc14 100644 --- a/src/config.c +++ b/src/config.c @@ -912,7 +912,7 @@ void cfg_assign(char *sp, int strct, Component_t *cp, VALUE *v) { cp->name, cfg_strct_name(strct), cfg_comp_type(cp->type), cfg_v_type(v->type)); return; } - // TODO: consider endianess (code currently assumes little endian) + // TODO: consider endianness (code currently assumes little endian) num = v->number; memcpy(sp+cp->offset, &num, cp->size); break; diff --git a/src/fileio.c b/src/fileio.c index 694af668..be6b303e 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -857,16 +857,16 @@ static int elf2b(const char *infile, FILE *inf, const AVRMEM *mem, } const char *endianname; - unsigned char endianess; + unsigned char endianness; if (p->prog_modes & PM_aWire) { // AVR32 - endianess = ELFDATA2MSB; + endianness = ELFDATA2MSB; endianname = "little"; } else { - endianess = ELFDATA2LSB; + endianness = ELFDATA2LSB; endianname = "big"; } if (id[EI_CLASS] != ELFCLASS32 || - id[EI_DATA] != endianess) { + id[EI_DATA] != endianness) { pmsg_error("ELF file %s is not a 32-bit, %s-endian file that was expected\n", infile, endianname); goto done; diff --git a/src/jtagmkII_private.h b/src/jtagmkII_private.h index f567ce73..d3aec68b 100644 --- a/src/jtagmkII_private.h +++ b/src/jtagmkII_private.h @@ -335,7 +335,7 @@ typedef enum * In appnote AVR067, struct device_descriptor is written with * int/long field types. We cannot use them directly, as they were * neither properly aligned for portability, nor did they care for - * endianess issues. We thus use arrays of unsigned chars, plus + * endianness issues. We thus use arrays of unsigned chars, plus * conversion macros. */ struct device_descriptor diff --git a/src/term.c b/src/term.c index 4ee0bc73..66caa74f 100644 --- a/src/term.c +++ b/src/term.c @@ -522,7 +522,7 @@ static int cmd_write(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch } if(sd->warnstr) pmsg_warning("(write) %s\n", sd->warnstr); - // Always write little endian (assume double and int have same endianess) + // Always write little endian (assume double and int have same endianness) if(is_bigendian() && sd->size > 0 && (sd->type & STR_NUMBER)) change_endian(sd->a, sd->size); } else { From e35cacf3d9995d00e452733c74680bf8ea32ecb6 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 2 May 2024 17:43:15 +0100 Subject: [PATCH 003/422] Silence compiler warning when printing `size_t` variable --- src/updi_link.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/updi_link.c b/src/updi_link.c index 4bd82f51..39be1e64 100644 --- a/src/updi_link.c +++ b/src/updi_link.c @@ -90,7 +90,7 @@ static int updi_physical_send(const PROGRAMMER *pgm, unsigned char *buf, size_t size_t i; int rv; - pmsg_debug("sending %lu bytes [", len); + pmsg_debug("sending %lu bytes [", (unsigned long) len); for (i=0; i Date: Sat, 6 Apr 2024 18:40:49 +0200 Subject: [PATCH 004/422] Add serprog programmer This commit adds support to program AVRs via programmers speaking the serprog protocol used by flashrom. A programmer implementing this is for example: https://github.com/stacksmashing/pico-serprog --- src/CMakeLists.txt | 2 + src/Makefile.am | 2 + src/avrdude.conf.in | 18 ++ src/pgm_type.c | 2 + src/serprog.c | 485 ++++++++++++++++++++++++++++++++++++++++++++ src/serprog.h | 35 ++++ 6 files changed, 544 insertions(+) create mode 100644 src/serprog.c create mode 100644 src/serprog.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9ddb59d..7d8a2669 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -231,6 +231,8 @@ add_library(libavrdude serialadapter.c serialupdi.c serialupdi.h + serprog.c + serprog.h solaris_ecpp.h stk500.c stk500.h diff --git a/src/Makefile.am b/src/Makefile.am index f90b82c8..f67ac711 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -185,6 +185,8 @@ libavrdude_a_SOURCES = \ usbasp.h \ serialupdi.c \ serialupdi.h \ + serprog.c \ + serprog.h \ updi_constants.h \ updi_link.c \ updi_link.h \ diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 10513680..968962f3 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -1479,6 +1479,24 @@ programmer # serialupdi hvupdi_support = 1; ; +#------------------------------------------------------------ +# serprog +#------------------------------------------------------------ + +# The Serprog programmer implementation allows programming +# with programmers using the serprog protocol from flashrom. +# See https://flashrom.org/classic_cli_manpage.html#serprog-programmer +# and https://wiki.flashrom.org/Serprog +# for details. + +programmer # serprog + id = "serprog"; + desc = "Serprog"; + type = "serprog"; + prog_modes = PM_ISP; + connection_type = serial; +; + #------------------------------------------------------------ # avrisp #------------------------------------------------------------ diff --git a/src/pgm_type.c b/src/pgm_type.c index 945f816f..56639eb8 100644 --- a/src/pgm_type.c +++ b/src/pgm_type.c @@ -49,6 +49,7 @@ #include "ppi.h" #include "serbb.h" #include "serialupdi.h" +#include "serprog.h" #include "stk500.h" #include "stk500generic.h" #include "stk500v2.h" @@ -100,6 +101,7 @@ const PROGRAMMER_TYPE programmers_types[] = { // Name(s) the programmers call th {"pickit2", pickit2_initpgm, pickit2_desc}, // "pickit2" {"serbb", serbb_initpgm, serbb_desc}, // "SERBB" {"serialupdi", serialupdi_initpgm, serialupdi_desc}, // "serialupdi" + {"serprog", serprog_initpgm, serprog_desc}, // "serprog" {"stk500", stk500_initpgm, stk500_desc}, // "STK500" {"stk500generic", stk500generic_initpgm, stk500generic_desc}, // "STK500GENERIC" {"stk500v2", stk500v2_initpgm, stk500v2_desc}, // "STK500V2" diff --git a/src/serprog.c b/src/serprog.c new file mode 100644 index 00000000..03cb1ad0 --- /dev/null +++ b/src/serprog.c @@ -0,0 +1,485 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Support for using serprog programmers to program over ISP + * + * Copyright (C) 2024 Sydney Louisa Wilke + * used linuxspi.c as a template: + * Copyright (C) 2013 Kevin Cuzner + * Copyright (C) 2018 Ralf Ramsauer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ac_cfg.h" + +#include "avrdude.h" +#include "libavrdude.h" + +#include "serprog.h" + +#include +#include + +#include +#include +#include +#include + +#define serprog "serprog" + +const char serprog_desc[] = "Programmer using the serprog protocol"; + +/* + * Private data for this programmer. + */ +struct pdata { + unsigned char cmd_bitmap[32]; +}; + +#define my (*(struct pdata *)(pgm->cookie)) + +// serprog protocol specification + +/* According to Serial Flasher Protocol Specification - version 1 */ +#define S_ACK 0x06 +#define S_NAK 0x15 +#define S_CMD_NOP 0x00 /* No operation */ +#define S_CMD_Q_IFACE 0x01 /* Query interface version */ +#define S_CMD_Q_CMDMAP 0x02 /* Query supported commands bitmap */ +#define S_CMD_Q_PGMNAME 0x03 /* Query programmer name */ +#define S_CMD_Q_SERBUF 0x04 /* Query Serial Buffer Size */ +#define S_CMD_Q_BUSTYPE 0x05 /* Query supported bustypes */ +#define S_CMD_Q_CHIPSIZE 0x06 /* Query supported chipsize (2^n format) */ +#define S_CMD_Q_OPBUF 0x07 /* Query operation buffer size */ +#define S_CMD_Q_WRNMAXLEN 0x08 /* Query Write to opbuf: Write-N maximum length */ +#define S_CMD_R_BYTE 0x09 /* Read a single byte */ +#define S_CMD_R_NBYTES 0x0A /* Read n bytes */ +#define S_CMD_O_INIT 0x0B /* Initialize operation buffer */ +#define S_CMD_O_WRITEB 0x0C /* Write opbuf: Write byte with address */ +#define S_CMD_O_WRITEN 0x0D /* Write to opbuf: Write-N */ +#define S_CMD_O_DELAY 0x0E /* Write opbuf: udelay */ +#define S_CMD_O_EXEC 0x0F /* Execute operation buffer */ +#define S_CMD_SYNCNOP 0x10 /* Special no-operation that returns NAK+ACK */ +#define S_CMD_Q_RDNMAXLEN 0x11 /* Query read-n maximum length */ +#define S_CMD_S_BUSTYPE 0x12 /* Set used bustype(s). */ +#define S_CMD_O_SPIOP 0x13 /* Perform SPI operation. */ +#define S_CMD_S_SPI_FREQ 0x14 /* Set SPI clock frequency */ +#define S_CMD_S_PIN_STATE 0x15 /* Enable/disable output drivers */ +#define S_CMD_S_SPI_CS 0x16 /* Set SPI chip select to use */ +#define S_CMD_S_SPI_MODE 0x17 /* Sets the spi mode used by S_CMD_O_SPIOP */ +#define S_CMD_S_CS_MODE 0x18 /* Sets the way the CS is controlled */ + +enum spi_mode { + SPI_MODE_HALF_DUPLEX = 0, + SPI_MODE_FULL_DUPLEX = 1, + SPI_MODE_MAX = SPI_MODE_FULL_DUPLEX, +}; + +enum cs_mode { + CS_MODE_AUTO = 0, + CS_MODE_SELECTED = 1, + CS_MODE_DESELECTED = 2, + CS_MODE_MAX = CS_MODE_DESELECTED, +}; + +// little endian helper functions + +static uint16_t read_le16(unsigned char* buf) { + return buf[0] | (buf[1] << 8); +} + +static uint32_t read_le32(unsigned char* buf) { + return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); +} + +static void write_le24(unsigned char* buf, uint32_t val) { + buf[0] = val; + buf[1] = val >> 8; + buf[2] = val >> 16; +} + +static void write_le32(unsigned char* buf, uint32_t val) { + buf[0] = val; + buf[1] = val >> 8; + buf[2] = val >> 16; + buf[3] = val >> 24; +} + +// serprog communication functions + +static int perform_serprog_cmd_full(const PROGRAMMER *pgm, uint8_t cmd, + const unsigned char* params, int params_len, + const unsigned char* send_buf, int send_len, + unsigned char* recv_buf, int recv_len) { + unsigned char resp_status_code = 0; + + serial_send(&pgm->fd, &cmd, 1); + if (params_len > 0) + serial_send(&pgm->fd, params, params_len); + if (send_len > 0) + serial_send(&pgm->fd, send_buf, send_len); + + if (serial_recv(&pgm->fd, &resp_status_code, 1) < 0 || serial_recv(&pgm->fd, recv_buf, recv_len) < 0) + return -1; + if (resp_status_code == S_ACK) + return 0; + else if (resp_status_code == S_NAK) + return 1; + else + return -1; +} + +static int perform_serprog_cmd(const PROGRAMMER *pgm, uint8_t cmd, + const unsigned char* params, int params_len, + unsigned char* recv_buf, int recv_len) { + return perform_serprog_cmd_full(pgm, cmd, params, params_len, NULL, 0, recv_buf, recv_len); +} + +/** + * @brief Sends/receives a message to the AVR in full duplex mode + * @return -1 on failure, otherwise number of bytes sent/received + */ +static int serprog_spi_duplex(const PROGRAMMER *pgm, const unsigned char *tx, unsigned char *rx, int len) { + unsigned char params[6]; + write_le24(params, len); + write_le24(params + 3, len); + if (perform_serprog_cmd_full(pgm, S_CMD_O_SPIOP, params, sizeof(params), tx, len, rx, len) != 0) { + return -1; + } + + return len; +} + +static bool is_serprog_cmd_supported(unsigned char *cmd_bitmap, unsigned char cmd) { + return (cmd_bitmap[cmd / 8] >> (cmd % 8)) & 1; +} + +// programmer lifecycle handlers + +static int serprog_open(PROGRAMMER *pgm, const char *pt) { + const char *port_error = + "unknown port specification, " + "please use the format /dev/ttyACM0,cs=0\n"; + char port_default[] = "/dev/ttyACM0"; + char *serialdev; + char *port = mmt_strdup(pt); + + if (str_eq(port, "unknown")) { + port = port_default; + } + + serialdev = strtok(port, ","); + if (!serialdev) { + pmsg_error("%s", port_error); + return -1; + } + + // parse chip select if specified + uint8_t cs = 0; + char *option_str = strtok(NULL, ","); + if (option_str) { + char *option_name = strtok(option_str, "="); + if (strcmp(option_name, "cs") != 0) { + pmsg_error("unkown parameter: %s\n", option_name); + return -1; + } + char *option_value = strtok(NULL, "="); + if (option_value) { + cs = atoi(option_value); + } + } + + union pinfo pinfo; + pgm->port = port; + pinfo.serialinfo.baud = pgm->baudrate? pgm->baudrate: 115200; + pinfo.serialinfo.cflags = SERIAL_8N1; + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + unsigned char buf[32]; + + // sync + memset(buf, 0, sizeof(buf)); + if (perform_serprog_cmd(pgm, S_CMD_SYNCNOP, NULL, 0, buf, 1) != 1 || buf[0] != S_ACK) { + pmsg_error("can not sync. is this a serprog programmer?\n"); + return -1; + } + + // get command bitmap + memset(my.cmd_bitmap, 0, sizeof(my.cmd_bitmap)); + if (perform_serprog_cmd(pgm, S_CMD_Q_CMDMAP, NULL, 0, my.cmd_bitmap, 32) != 0) { + pmsg_error("can not get list of supported serprog commands.\n"); + return -1; + } + + // get protocol version + memset(buf, 0, sizeof(buf)); + if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_Q_IFACE) + || perform_serprog_cmd(pgm, S_CMD_Q_IFACE, NULL, 0, buf, 2) != 0) { + pmsg_error("can not get serprog protocol version.\n"); + return -1; + } + if (read_le16(buf) != 0x01) { + pmsg_error("unsupported serprog protocol version: %d\n", read_le16(buf)); + return -1; + } + + pmsg_info("serprog protocol version: %d\n", read_le16(buf)); + + // get programmer name + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_Q_PGMNAME)) { + memset(buf, 0, sizeof(buf)); + if (perform_serprog_cmd(pgm, S_CMD_Q_PGMNAME, NULL, 0, buf, 16) != 0) { + pmsg_error("can not get programmer name.\n"); + return -1; + } + pmsg_info("programmer name: %s\n", buf); + } + + // check if required commands are supported + if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_O_SPIOP)) { + pmsg_error("this programmer does not support SPI operations.\n"); + return -1; + } + + if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_CS_MODE)) { + pmsg_error("this programmer does not support setting the CS mode.\n"); + return -1; + } + + if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_MODE)) { + pmsg_error("this programmer does not support setting the SPI mode.\n"); + return -1; + } + + // set SPI clock frequency + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { + memset(buf, 0, sizeof(buf)); + write_le32(buf, 115200); + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { + pmsg_error("can not set SPI frequency.\n"); + return -1; + } + if (read_le32(buf) != 115200) { + pmsg_error("set SPI frequency differs from requested.\n"); + return -1; + } + } + + // set active chip select + if (option_str != NULL) { + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { + memset(buf, 0, sizeof(buf)); + buf[0] = cs; + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { + pmsg_error("can not change CS.\n"); + return -1; + } + } else { + pmsg_error("changing the CS is not supported by the programmer.\n"); + return -1; + } + } + + // set full duplex + memset(buf, 0, sizeof(buf)); + buf[0] = SPI_MODE_FULL_DUPLEX; + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { + pmsg_error("can not set SPI full duplex mode.\n"); + return -1; + } + + // set output + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { + memset(buf, 0, sizeof(buf)); + buf[0] = 1; // Pin state enable + if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { + pmsg_error("can not enable pin state.\n"); + return -1; + } + } + + // enable the CS / reset pin + const unsigned char cs_mode = CS_MODE_SELECTED; + if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { + pmsg_error("can not enable the reset pin.\n"); + return -1; + } + return 0; +} + +static void serprog_close(PROGRAMMER *pgm) { + unsigned char buf[32]; + // switch cs to auto + const unsigned char cs_mode = CS_MODE_AUTO; + if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { + pmsg_error("can not reset the CS mode to auto.\n"); + } + // disable output + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { + memset(buf, 0, sizeof(buf)); + buf[0] = 0; // Pin state disable + if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { + pmsg_error("can not disable pin state.\n"); + } + } + // restore half duplex + memset(buf, 0, sizeof(buf)); + buf[0] = SPI_MODE_HALF_DUPLEX; + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { + pmsg_error("can not reset SPI half duplex mode.\n"); + } + // reset CS to CS_0 + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { + memset(buf, 0, sizeof(buf)); + buf[0] = 0; + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { + pmsg_error("can not reset CS to CS_0.\n"); + } + } + + serial_close(&pgm->fd); +} + +static int serprog_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned char *res) { + return serprog_spi_duplex(pgm, cmd, res, 4); +} + +static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *p) { + int tries, ret; + + if (p->prog_modes & PM_TPI) { + /* We do not support TPI. This is a dedicated SPI thing */ + pmsg_error("programmer " serprog " does not support TPI\n"); + return -1; + } + + //enable programming on the part + tries = 0; + do { + ret = pgm->program_enable(pgm, p); + if (ret == 0 || ret == -1) + break; + } while(tries++ < 65); + + if (ret) + pmsg_error("AVR device not responding\n"); + + return ret; +} + +static int serprog_program_enable(const PROGRAMMER *pgm, const AVRPART *p) { + unsigned char cmd[4], res[4]; + + if (!p->op[AVR_OP_PGM_ENABLE]) { + pmsg_error("program enable instruction not defined for part %s\n", p->desc); + return -1; + } + + memset(cmd, 0, sizeof(cmd)); + avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd); //set the cmd + pgm->cmd(pgm, cmd, res); + + if (res[2] != cmd[1]) { + /** From ATtiny441 datasheet: + * + * In some systems, the programmer can not guarantee that SCK is held low + * during power-up. In this case, RESET must be given a positive pulse after + * SCK has been set to '0'. The duration of the pulse must be at least t RST + * plus two CPU clock cycles. See Table 25-5 on page 240 for definition of + * minimum pulse width on RESET pin, t RST + * 2. Wait for at least 20 ms and then enable serial programming by sending + * the Programming Enable serial instruction to the SDO pin + * 3. The serial programming instructions will not work if the communication + * is out of synchronization. When in sync, the second byte (0x53) will echo + * back when issuing the third byte of the Programming Enable instruction + * ... + * If the 0x53 did not echo back, give RESET a positive pulse and issue a + * new Programming Enable command + */ + unsigned char cs_mode = CS_MODE_DESELECTED; + if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { + return -1; + } + usleep(5); + cs_mode = CS_MODE_SELECTED; + if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { + return -1; + } + usleep(20000); + + return -2; + } + + return 0; +} + +static int serprog_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { + unsigned char cmd[4], res[4]; + + if (!p->op[AVR_OP_CHIP_ERASE]) { + pmsg_error("chip erase instruction not defined for part %s\n", p->desc); + return -1; + } + + memset(cmd, 0, sizeof(cmd)); + avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd); + pgm->cmd(pgm, cmd, res); + usleep(p->chip_erase_delay); + pgm->initialize(pgm, p); + + return 0; +} + +static void serprog_disable(const PROGRAMMER* pgm) { +} + +static void serprog_enable(PROGRAMMER *pgm, const AVRPART *p) { +} + +static void serprog_display(const PROGRAMMER* pgm, const char* p) { +} + +static void serprog_setup(PROGRAMMER *pgm) { + pgm->cookie = mmt_malloc(sizeof(struct pdata)); +} + +static void serprog_teardown(PROGRAMMER* pgm) { + mmt_free(pgm->cookie); + pgm->cookie = NULL; +} + +void serprog_initpgm(PROGRAMMER *pgm) { + strcpy(pgm->type, serprog); + + // required fields + pgm->initialize = serprog_initialize; + pgm->display = serprog_display; + pgm->enable = serprog_enable; + pgm->disable = serprog_disable; + pgm->program_enable = serprog_program_enable; + pgm->chip_erase = serprog_chip_erase; + pgm->cmd = serprog_cmd; + pgm->open = serprog_open; + pgm->close = serprog_close; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + + // optional fields + pgm->setup = serprog_setup; + pgm->teardown = serprog_teardown; +} + diff --git a/src/serprog.h b/src/serprog.h new file mode 100644 index 00000000..092dd95b --- /dev/null +++ b/src/serprog.h @@ -0,0 +1,35 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2013 Kevin Cuzner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef serprog_h +#define serprog_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char serprog_desc[]; +void serprog_initpgm(PROGRAMMER *pgm); + +#ifdef __cplusplus +} +#endif + +#endif //serprog_h + From 14e32f49c4adea44ff38e476faf844c0548b65f4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 5 May 2024 22:57:24 +0100 Subject: [PATCH 005/422] Adapt messages to AVRDUDE style --- src/serprog.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index 03cb1ad0..f0e80c7b 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -214,14 +214,14 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { // sync memset(buf, 0, sizeof(buf)); if (perform_serprog_cmd(pgm, S_CMD_SYNCNOP, NULL, 0, buf, 1) != 1 || buf[0] != S_ACK) { - pmsg_error("can not sync. is this a serprog programmer?\n"); + pmsg_error("cannot sync; is this a serprog programmer?\n"); return -1; } // get command bitmap memset(my.cmd_bitmap, 0, sizeof(my.cmd_bitmap)); if (perform_serprog_cmd(pgm, S_CMD_Q_CMDMAP, NULL, 0, my.cmd_bitmap, 32) != 0) { - pmsg_error("can not get list of supported serprog commands.\n"); + pmsg_error("cannot get list of supported serprog commands\n"); return -1; } @@ -229,7 +229,7 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { memset(buf, 0, sizeof(buf)); if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_Q_IFACE) || perform_serprog_cmd(pgm, S_CMD_Q_IFACE, NULL, 0, buf, 2) != 0) { - pmsg_error("can not get serprog protocol version.\n"); + pmsg_error("cannot get serprog protocol version\n"); return -1; } if (read_le16(buf) != 0x01) { @@ -243,7 +243,7 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_Q_PGMNAME)) { memset(buf, 0, sizeof(buf)); if (perform_serprog_cmd(pgm, S_CMD_Q_PGMNAME, NULL, 0, buf, 16) != 0) { - pmsg_error("can not get programmer name.\n"); + pmsg_error("cannot get programmer name\n"); return -1; } pmsg_info("programmer name: %s\n", buf); @@ -251,17 +251,17 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { // check if required commands are supported if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_O_SPIOP)) { - pmsg_error("this programmer does not support SPI operations.\n"); + pmsg_error("this programmer does not support SPI operations\n"); return -1; } if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_CS_MODE)) { - pmsg_error("this programmer does not support setting the CS mode.\n"); + pmsg_error("this programmer does not support setting the CS mode\n"); return -1; } if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_MODE)) { - pmsg_error("this programmer does not support setting the SPI mode.\n"); + pmsg_error("this programmer does not support setting the SPI mode\n"); return -1; } @@ -270,11 +270,11 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { memset(buf, 0, sizeof(buf)); write_le32(buf, 115200); if (perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { - pmsg_error("can not set SPI frequency.\n"); + pmsg_error("cannot set SPI frequency\n"); return -1; } if (read_le32(buf) != 115200) { - pmsg_error("set SPI frequency differs from requested.\n"); + pmsg_error("set SPI frequency differs from the requested one\n"); return -1; } } @@ -285,11 +285,11 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { memset(buf, 0, sizeof(buf)); buf[0] = cs; if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { - pmsg_error("can not change CS.\n"); + pmsg_error("cannot change CS\n"); return -1; } } else { - pmsg_error("changing the CS is not supported by the programmer.\n"); + pmsg_error("changing the CS is not supported by the programmer\n"); return -1; } } @@ -298,7 +298,7 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { memset(buf, 0, sizeof(buf)); buf[0] = SPI_MODE_FULL_DUPLEX; if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { - pmsg_error("can not set SPI full duplex mode.\n"); + pmsg_error("cannot set SPI full duplex mode\n"); return -1; } @@ -307,7 +307,7 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { memset(buf, 0, sizeof(buf)); buf[0] = 1; // Pin state enable if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { - pmsg_error("can not enable pin state.\n"); + pmsg_error("cannot enable pin state\n"); return -1; } } @@ -315,7 +315,7 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { // enable the CS / reset pin const unsigned char cs_mode = CS_MODE_SELECTED; if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { - pmsg_error("can not enable the reset pin.\n"); + pmsg_error("cannot enable the reset pin\n"); return -1; } return 0; @@ -326,28 +326,28 @@ static void serprog_close(PROGRAMMER *pgm) { // switch cs to auto const unsigned char cs_mode = CS_MODE_AUTO; if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { - pmsg_error("can not reset the CS mode to auto.\n"); + pmsg_error("cannot reset the CS mode to auto\n"); } // disable output if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { memset(buf, 0, sizeof(buf)); buf[0] = 0; // Pin state disable if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { - pmsg_error("can not disable pin state.\n"); + pmsg_error("cannot disable pin state\n"); } } // restore half duplex memset(buf, 0, sizeof(buf)); buf[0] = SPI_MODE_HALF_DUPLEX; if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { - pmsg_error("can not reset SPI half duplex mode.\n"); + pmsg_error("cannot reset SPI half duplex mode\n"); } // reset CS to CS_0 if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { memset(buf, 0, sizeof(buf)); buf[0] = 0; if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { - pmsg_error("can not reset CS to CS_0.\n"); + pmsg_error("cannot reset CS to CS_0\n"); } } @@ -396,7 +396,7 @@ static int serprog_program_enable(const PROGRAMMER *pgm, const AVRPART *p) { if (res[2] != cmd[1]) { /** From ATtiny441 datasheet: * - * In some systems, the programmer can not guarantee that SCK is held low + * In some systems, the programmer cannot guarantee that SCK is held low * during power-up. In this case, RESET must be given a positive pulse after * SCK has been set to '0'. The duration of the pulse must be at least t RST * plus two CPU clock cycles. See Table 25-5 on page 240 for definition of From 59edcd8c78ecf4e913a01e28e3309d4a2624ab3c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 5 May 2024 23:00:47 +0100 Subject: [PATCH 006/422] Use command line programmer name in messages --- src/serprog.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index f0e80c7b..95fbd4fb 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -37,8 +37,6 @@ #include #include -#define serprog "serprog" - const char serprog_desc[] = "Programmer using the serprog protocol"; /* @@ -251,17 +249,17 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { // check if required commands are supported if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_O_SPIOP)) { - pmsg_error("this programmer does not support SPI operations\n"); + pmsg_error("the %s programmer does not support SPI operations\n", pgmid); return -1; } if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_CS_MODE)) { - pmsg_error("this programmer does not support setting the CS mode\n"); + pmsg_error("the %s programmer does not support setting the CS mode\n", pgmid); return -1; } if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_MODE)) { - pmsg_error("this programmer does not support setting the SPI mode\n"); + pmsg_error("the %s programmer does not support setting the SPI mode\n", pgmid); return -1; } @@ -289,7 +287,7 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { return -1; } } else { - pmsg_error("changing the CS is not supported by the programmer\n"); + pmsg_error("changing the CS is not supported by the %s programmer\n", pgmid); return -1; } } @@ -363,7 +361,7 @@ static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *p) { if (p->prog_modes & PM_TPI) { /* We do not support TPI. This is a dedicated SPI thing */ - pmsg_error("programmer " serprog " does not support TPI\n"); + pmsg_error("the %s programmer does not support TPI\n", pgmid); return -1; } @@ -463,7 +461,7 @@ static void serprog_teardown(PROGRAMMER* pgm) { } void serprog_initpgm(PROGRAMMER *pgm) { - strcpy(pgm->type, serprog); + strcpy(pgm->type, "serprog"); // required fields pgm->initialize = serprog_initialize; From 5cf001f045da0ed935ac5b32c40b927e2315e773 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 5 May 2024 23:03:41 +0100 Subject: [PATCH 007/422] Space pointer declarations consistently --- src/serprog.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index 95fbd4fb..d05f8dd2 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -94,21 +94,21 @@ enum cs_mode { // little endian helper functions -static uint16_t read_le16(unsigned char* buf) { +static uint16_t read_le16(unsigned char *buf) { return buf[0] | (buf[1] << 8); } -static uint32_t read_le32(unsigned char* buf) { +static uint32_t read_le32(unsigned char *buf) { return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); } -static void write_le24(unsigned char* buf, uint32_t val) { +static void write_le24(unsigned char *buf, uint32_t val) { buf[0] = val; buf[1] = val >> 8; buf[2] = val >> 16; } -static void write_le32(unsigned char* buf, uint32_t val) { +static void write_le32(unsigned char *buf, uint32_t val) { buf[0] = val; buf[1] = val >> 8; buf[2] = val >> 16; @@ -118,9 +118,9 @@ static void write_le32(unsigned char* buf, uint32_t val) { // serprog communication functions static int perform_serprog_cmd_full(const PROGRAMMER *pgm, uint8_t cmd, - const unsigned char* params, int params_len, - const unsigned char* send_buf, int send_len, - unsigned char* recv_buf, int recv_len) { + const unsigned char *params, int params_len, + const unsigned char *send_buf, int send_len, + unsigned char *recv_buf, int recv_len) { unsigned char resp_status_code = 0; serial_send(&pgm->fd, &cmd, 1); @@ -140,8 +140,8 @@ static int perform_serprog_cmd_full(const PROGRAMMER *pgm, uint8_t cmd, } static int perform_serprog_cmd(const PROGRAMMER *pgm, uint8_t cmd, - const unsigned char* params, int params_len, - unsigned char* recv_buf, int recv_len) { + const unsigned char *params, int params_len, + unsigned char *recv_buf, int recv_len) { return perform_serprog_cmd_full(pgm, cmd, params, params_len, NULL, 0, recv_buf, recv_len); } @@ -442,20 +442,20 @@ static int serprog_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { return 0; } -static void serprog_disable(const PROGRAMMER* pgm) { +static void serprog_disable(const PROGRAMMER *pgm) { } static void serprog_enable(PROGRAMMER *pgm, const AVRPART *p) { } -static void serprog_display(const PROGRAMMER* pgm, const char* p) { +static void serprog_display(const PROGRAMMER *pgm, const char *p) { } static void serprog_setup(PROGRAMMER *pgm) { pgm->cookie = mmt_malloc(sizeof(struct pdata)); } -static void serprog_teardown(PROGRAMMER* pgm) { +static void serprog_teardown(PROGRAMMER *pgm) { mmt_free(pgm->cookie); pgm->cookie = NULL; } From 638a429337cd9a62bfc67316843027807d30e517 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 5 May 2024 23:06:38 +0100 Subject: [PATCH 008/422] Add const to pointer argument where possible --- src/serprog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index d05f8dd2..3eb39f32 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -94,11 +94,11 @@ enum cs_mode { // little endian helper functions -static uint16_t read_le16(unsigned char *buf) { +static uint16_t read_le16(const unsigned char *buf) { return buf[0] | (buf[1] << 8); } -static uint32_t read_le32(unsigned char *buf) { +static uint32_t read_le32(const unsigned char *buf) { return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); } @@ -160,7 +160,7 @@ static int serprog_spi_duplex(const PROGRAMMER *pgm, const unsigned char *tx, un return len; } -static bool is_serprog_cmd_supported(unsigned char *cmd_bitmap, unsigned char cmd) { +static bool is_serprog_cmd_supported(const unsigned char *cmd_bitmap, unsigned char cmd) { return (cmd_bitmap[cmd / 8] >> (cmd % 8)) & 1; } From 9f69a6e09a5c32794b63e6d14257c1abb9cb7037 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 6 May 2024 22:37:09 +0100 Subject: [PATCH 009/422] Put static variables of avr.c into context structure ... and convert static memory for strings returned by avr_prog_modes() into closed-circuit memory area in the context structure --- src/arduino.c | 2 +- src/avr.c | 42 ++++++++++++++++++++++-------------------- src/libavrdude.h | 23 ++++++++++++++++++++++- src/main.c | 6 +++++- src/urclock.c | 2 +- 5 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index c6ffa28f..70072da7 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -135,5 +135,5 @@ void arduino_initpgm(PROGRAMMER *pgm) { pgm->open = arduino_open; pgm->close = arduino_close; - disable_trailing_ff_removal(); /* so that arduino bootloader can ignore chip erase */ + cx->avr_disableffopt = 1; // Disable trailing 0xff removal } diff --git a/src/avr.c b/src/avr.c index 7125a4a2..564c1d3d 100644 --- a/src/avr.c +++ b/src/avr.c @@ -291,15 +291,14 @@ rcerror: int avr_mem_hiaddr(const AVRMEM * mem) { int i, n; - static int disableffopt; - /* calling once with NULL disables any future trailing-0xff optimisation */ + // Deprecated: calling with NULL disables trailing 0xff optimisation (remove in v8.0) if(!mem) { - disableffopt = 1; + cx->avr_disableffopt = 1; return 0; } - if(disableffopt) + if(cx->avr_disableffopt) return mem->size; /* if the memory is not a flash-type memory do not remove trailing 0xff */ @@ -578,16 +577,14 @@ uint64_t avr_ustimestamp() { memset(&tv, 0, sizeof tv); if(gettimeofday(&tv, NULL) == 0) { - static uint64_t epoch; - static int init; uint64_t now; now = tv.tv_sec*1000000ULL + tv.tv_usec; - if(!init) { - epoch = now; - init = 1; + if(!cx->avr_epoch_init) { + cx->avr_epoch = now; + cx->avr_epoch_init = 1; } - return now - epoch; + return now - cx->avr_epoch; } return 0; @@ -1445,9 +1442,15 @@ int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles) { } -// Returns a pointer to static memory of list of programming modes +// Returns a string in closed-circuit space with list of programming modes char *avr_prog_modes(int pm) { - static char type[1024]; + // Return string is overwritten after a few calls + if(!cx->avr_s) + cx->avr_s = cx->avr_space; + char *type = cx->avr_s + strlen(cx->avr_s) + 1; + // Overwrite space once only 128 bytes left + if((size_t) (type - cx->avr_space) > sizeof cx->avr_space - 128) + type = cx->avr_space; strcpy(type, "?"); if(pm & PM_SPM) @@ -1477,7 +1480,8 @@ char *avr_prog_modes(int pm) { if(pm & PM_aWire) strcat(type, ", aWire"); - return type + (type[1] == 0? 0: 3); + cx->avr_s = type + (type[1] == 0? 0: 3); + return cx->avr_s; } @@ -1710,8 +1714,6 @@ int avr_unlock(const PROGRAMMER *pgm, const AVRPART *p) { */ void report_progress(int completed, int total, const char *hdr) { - static int last; - static double start_time; int percent; double t; @@ -1725,12 +1727,12 @@ void report_progress(int completed, int total, const char *hdr) { t = avr_timestamp(); - if(hdr || !start_time) - start_time = t; + if(hdr || !cx->avr_start_time) + cx->avr_start_time = t; - if(hdr || percent > last) { - last = percent; - update_progress(percent, t - start_time, hdr, total < 0? -1: !!total); + if(hdr || percent > cx->avr_last_percent) { + cx->avr_last_percent = percent; + update_progress(percent, t - cx->avr_start_time, hdr, total < 0? -1: !!total); } } diff --git a/src/libavrdude.h b/src/libavrdude.h index ee102e34..4e5c2e3c 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1171,7 +1171,6 @@ int avr_mem_is_known(const char *str); int avr_mem_might_be_known(const char *str); -#define disable_trailing_ff_removal() avr_mem_hiaddr(NULL) int avr_mem_hiaddr(const AVRMEM * mem); int avr_chip_erase(const PROGRAMMER *pgm, const AVRPART *p); @@ -1532,6 +1531,28 @@ void terminal_setup_update_progress(void); } #endif +/* + * Context structure + * + * Global and static variables should go here; the only remaining static + * variables ought to be read-only tables. Access should be via a global + * pointer cx_t *cx; applications using libavrdude ought to allocate cx = + * mmt_malloc(sizeof *cx) for each instantiation (and set initial values + * if needed) and deallocate with mmt_free(cx). + */ + +typedef struct { + // Static variables from avr.c + int avr_disableffopt; // Disables trailing 0xff flash optimisation + uint64_t avr_epoch; // Epoch for avr_ustimestamp() + int avr_epoch_init; // Whether above epoch is initialised + char avr_space[1024], *avr_s; // Closed-circuit space for avr+prog_modes() + int avr_last_percent; // Last valid percentage for report_progress() + double avr_start_time; // Start time in s of report_progress() activity +} cx_t; + +extern cx_t *cx; + /* formerly confwin.h */ #if defined(WIN32) diff --git a/src/main.c b/src/main.c index 49dae75f..e65088c9 100644 --- a/src/main.c +++ b/src/main.c @@ -188,6 +188,9 @@ struct list_walk_cookie const char *prefix; }; + +cx_t *cx; // Context pointer, eventually the only global variable + static LISTID updates = NULL; static LISTID extended_params = NULL; @@ -642,6 +645,7 @@ int main(int argc, char * argv []) char * logfile; /* Use logfile rather than stderr for diagnostics */ enum updateflags uflags = UF_AUTO_ERASE | UF_VERIFY; /* Flags for do_op() */ + cx = mmt_malloc(sizeof *cx); // Allocate and initialise context structure (void) avr_ustimestamp(); // Base timestamps from program start #ifdef _MSC_VER @@ -823,7 +827,7 @@ int main(int argc, char * argv []) /* fall through */ case 'A': /* explicit disabling of trailing-0xff removal */ - disable_trailing_ff_removal(); + cx->avr_disableffopt = 1; break; case 'e': /* perform a chip erase */ diff --git a/src/urclock.c b/src/urclock.c index fc0fbe53..62bee5d2 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -2584,7 +2584,7 @@ void urclock_initpgm(PROGRAMMER *pgm) { pgm->readonly = urclock_readonly; pgm->flash_readhook = urclock_flash_readhook; - disable_trailing_ff_removal(); + cx->avr_disableffopt = 1; // Disable trailing 0xff removal #if defined(HAVE_LIBREADLINE) pmsg_notice2("libreadline is used; avrdude -t -c urclock should work interactively\n"); #else From fa186e26a33929e49017e3a7ba1d12ce1708b5b0 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 7 May 2024 21:11:39 +0100 Subject: [PATCH 010/422] Put static variables of avrpart.c into context structure --- src/avr.c | 25 +++++++++++++++++++++---- src/avrpart.c | 34 ---------------------------------- src/libavrdude.h | 5 ++--- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/avr.c b/src/avr.c index 564c1d3d..61c8872e 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1442,8 +1442,13 @@ int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles) { } -// Returns a string in closed-circuit space with list of programming modes -char *avr_prog_modes(int pm) { +/* + * Returns a string in closed-circuit space with a comma-separated list of + * programming modes; variant creates the list in subtly different way + * - 0: PM_SPM prints bootloader, pm == 0 prints "?" + * - 1: PM_SPM prints SPM, pm == 0 prints "0" + */ +static char *prog_modes_string(int pm, int variant) { // Return string is overwritten after a few calls if(!cx->avr_s) cx->avr_s = cx->avr_space; @@ -1452,8 +1457,8 @@ char *avr_prog_modes(int pm) { if((size_t) (type - cx->avr_space) > sizeof cx->avr_space - 128) type = cx->avr_space; - strcpy(type, "?"); - if(pm & PM_SPM) + strcpy(type, variant? "0": "?"); + if(variant == 0 && (pm & PM_SPM)) strcat(type, ", bootloader"); if(pm & PM_TPI) strcat(type, ", TPI"); @@ -1479,11 +1484,23 @@ char *avr_prog_modes(int pm) { strcat(type, ", AVR32JTAG"); if(pm & PM_aWire) strcat(type, ", aWire"); + if(variant == 1 && (pm & PM_SPM)) + strcat(type, ", SPM"); cx->avr_s = type + (type[1] == 0? 0: 3); return cx->avr_s; } +// Returns a string in closed-circuit space with list of programming modes or "0" +char *avr_prog_modes_str(int pm) { + return prog_modes_string(pm, 1); +} + +// Returns a string in closed-circuit space with list of programming modes or "?" +char *avr_prog_modes(int pm) { + return prog_modes_string(pm, 0); +} + // Typical order in which memories show in avrdude.conf, runtime adds unknown ones (if any) memtable_t avr_mem_order[100] = { diff --git a/src/avrpart.c b/src/avrpart.c index 86235fce..c4023843 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -1083,40 +1083,6 @@ void sort_avrparts(LISTID avrparts) lsort(avrparts,(int (*)(void*, void*)) sort_avrparts_compare); } -const char *avr_prog_modes_str(int pm) { - static char type[1024]; - - strcpy(type, "0"); - if(pm & PM_TPI) - strcat(type, ", TPI"); - if(pm & PM_ISP) - strcat(type, ", ISP"); - if(pm & PM_PDI) - strcat(type, ", PDI"); - if(pm & PM_UPDI) - strcat(type, ", UPDI"); - if(pm & PM_HVSP) - strcat(type, ", HVSP"); - if(pm & PM_HVPP) - strcat(type, ", HVPP"); - if(pm & PM_debugWIRE) - strcat(type, ", debugWIRE"); - if(pm & PM_JTAG) - strcat(type, ", JTAG"); - if(pm & PM_JTAGmkI) - strcat(type, ", JTAGmkI"); - if(pm & PM_XMEGAJTAG) - strcat(type, ", XMEGAJTAG"); - if(pm & PM_AVR32JTAG) - strcat(type, ", AVR32JTAG"); - if(pm & PM_aWire) - strcat(type, ", aWire"); - if(pm & PM_SPM) - strcat(type, ", SPM"); - - return type + (type[1] == 0? 0: 3); -} - void avr_display(FILE *f, const AVRPART *p, const char *prefix, int verbose) { fprintf(f, "%sAVR Part : %s\n", prefix, p->desc); diff --git a/src/libavrdude.h b/src/libavrdude.h index 4e5c2e3c..a5f5f0da 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -573,7 +573,8 @@ AVRPART * locate_part(const LISTID parts, const char *partdesc); AVRPART * locate_part_by_avr910_devcode(const LISTID parts, int devcode); AVRPART * locate_part_by_signature(const LISTID parts, unsigned char *sig, int sigsize); AVRPART * locate_part_by_signature_pm(const LISTID parts, unsigned char *sig, int sigsize, int prog_modes); -const char *avr_prog_modes_str(int pm); +char *avr_prog_modes(int pm); +char *avr_prog_modes_str(int pm); void avr_display(FILE *f, const AVRPART *p, const char *prefix, int verbose); int avr_variants_display(FILE *f, const AVRPART *p, const char *prefix); @@ -1155,8 +1156,6 @@ int avr_get_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int *cycles); int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles); -char *avr_prog_modes(int pm); - int avr_get_mem_type(const char *str); int avr_mem_is_flash_type(const AVRMEM *mem); From 8a36a2f531f6f2f802011b95a7df49e0250aae1b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 7 May 2024 22:24:27 +0100 Subject: [PATCH 011/422] Put static variables of bitbang.c into context structure --- src/bitbang.c | 36 +++++++++++++----------------------- src/libavrdude.h | 10 ++++++++++ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/bitbang.c b/src/bitbang.c index ea7da211..dabefc81 100644 --- a/src/bitbang.c +++ b/src/bitbang.c @@ -44,21 +44,12 @@ #include "tpi.h" #include "bitbang.h" -static int delay_decrement; - #if defined(WIN32) -static int has_perfcount; -static LARGE_INTEGER freq; +#define freq (*(LARGE_INTEGER *)&cx->bb_freq) #else -static volatile int done; - -typedef void (*mysighandler_t)(int); -static mysighandler_t saved_alarmhandler; - -static void alarmhandler(int signo) -{ - done = 1; - signal(SIGALRM, saved_alarmhandler); +static void alarmhandler(int signo) { + *(volatile int *)&cx->bb_done = 1; + signal(SIGALRM, cx->bb_saved_alarmf); } #endif /* WIN32 */ @@ -75,7 +66,7 @@ static void bitbang_calibrate_delay(void) */ if (QueryPerformanceFrequency(&freq)) { - has_perfcount = 1; + cx->bb_has_perfcount = 1; pmsg_notice2("using performance counter for bitbang delays\n"); } else @@ -90,7 +81,7 @@ static void bitbang_calibrate_delay(void) * comparable hardware. */ pmsg_notice2("using guessed per-microsecond delay count for bitbang delays\n"); - delay_decrement = 100; + cx->bb_delay_decrement = 100; } #else /* !WIN32 */ struct itimerval itv; @@ -98,8 +89,8 @@ static void bitbang_calibrate_delay(void) pmsg_notice2("calibrating delay loop ..."); i = 0; - done = 0; - saved_alarmhandler = signal(SIGALRM, alarmhandler); + *(volatile int *)&cx->bb_done = 0; + cx->bb_saved_alarmf = signal(SIGALRM, alarmhandler); /* * Set ITIMER_REAL to 100 ms. All known systems have a timer * granularity of 10 ms or better, so counting the delay cycles @@ -114,16 +105,15 @@ static void bitbang_calibrate_delay(void) itv.it_value.tv_usec = 100000; itv.it_interval.tv_sec = itv.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &itv, 0); - while (!done) + while (!*(volatile int *)&cx->bb_done) i--; itv.it_value.tv_sec = itv.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &itv, 0); /* * Calculate back from 100 ms to 1 us. */ - delay_decrement = -i / 100000; - msg_notice2(" calibrated to %d cycles per us\n", - delay_decrement); + cx->bb_delay_decrement = -i / 100000; + msg_notice2(" calibrated to %d cycles per us\n", cx->bb_delay_decrement); #endif /* WIN32 */ } @@ -137,7 +127,7 @@ void bitbang_delay(unsigned int us) #if defined(WIN32) LARGE_INTEGER countNow, countEnd; - if (has_perfcount) + if (cx->bb_has_perfcount) { QueryPerformanceCounter(&countNow); countEnd.QuadPart = countNow.QuadPart + freq.QuadPart * us / 1000000ll; @@ -148,7 +138,7 @@ void bitbang_delay(unsigned int us) else /* no performance counters -- run normal uncalibrated delay */ { #endif /* WIN32 */ - volatile unsigned int del = us * delay_decrement; + volatile unsigned int del = us * cx->bb_delay_decrement; while (del > 0) del--; diff --git a/src/libavrdude.h b/src/libavrdude.h index a5f5f0da..0da1f9ba 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1548,6 +1548,16 @@ typedef struct { char avr_space[1024], *avr_s; // Closed-circuit space for avr+prog_modes() int avr_last_percent; // Last valid percentage for report_progress() double avr_start_time; // Start time in s of report_progress() activity + + // Static variables from bitbang.c + int bb_delay_decrement; +#if defined(WIN32) + int bb_has_perfcount; + uint64_t bb_freq; // Should be LARGE_INTEGER but what to include? +#else + int bb_done; // Handshake variable in alarm handler + void (*bb_saved_alarmf)(int); // Saved alarm handler +#endif } cx_t; extern cx_t *cx; From 1b0fb273a98b53ae59dd76d6592d84e823e5c72e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 7 May 2024 22:35:33 +0100 Subject: [PATCH 012/422] Make static variable const in avrftdi_tpi.c --- src/avrftdi_tpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/avrftdi_tpi.c b/src/avrftdi_tpi.c index be09e112..934d9936 100644 --- a/src/avrftdi_tpi.c +++ b/src/avrftdi_tpi.c @@ -20,7 +20,7 @@ static int avrftdi_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p); #ifdef notyet static void avrftdi_debug_frame(uint16_t frame) { - static char bit_name[] = "IDLES01234567PSS"; + static const char bit_name[] = "IDLES01234567PSS"; //static char bit_name[] = "SSP76543210SELDI"; char line0[34], line1[34], line2[34]; int bit, pos; From 14b337bb977b4de9081cbf7dc944a272c8a64544 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 7 May 2024 23:02:40 +0100 Subject: [PATCH 013/422] Put static variables of config.c into context structure --- src/config.c | 82 +++++++++++++++++++++--------------------------- src/libavrdude.h | 11 +++++++ 2 files changed, 46 insertions(+), 47 deletions(-) diff --git a/src/config.c b/src/config.c index b9b9adb5..df0a1136 100644 --- a/src/config.c +++ b/src/config.c @@ -488,8 +488,6 @@ unsigned strhash(const char *str) { } -static char **hstrings[1<<12]; - // Return a copy of the argument as hashed string const char *cache_string(const char *p) { int h, k; @@ -498,32 +496,23 @@ const char *cache_string(const char *p) { if(!p) p = "(NULL)"; - h = strhash(p) % (sizeof hstrings/sizeof*hstrings); - if(!(hs=hstrings[h])) - hs = hstrings[h] = (char **) mmt_realloc(NULL, (16+1)*sizeof**hstrings); + h = strhash(p) % (sizeof cx->cfg_hstrings/sizeof*cx->cfg_hstrings); + if(!(hs=cx->cfg_hstrings[h])) + hs = cx->cfg_hstrings[h] = (char **) mmt_realloc(NULL, (16+1)*sizeof**cx->cfg_hstrings); for(k=0; hs[k]; k++) if(*p == *hs[k] && str_eq(p, hs[k])) return hs[k]; if(k && k%16 == 0) - hstrings[h] = (char **) mmt_realloc(hstrings[h], (k+16+1)*sizeof**hstrings); + cx->cfg_hstrings[h] = (char **) mmt_realloc(cx->cfg_hstrings[h], (k+16+1)*sizeof**cx->cfg_hstrings); - hstrings[h][k+1] = NULL; + cx->cfg_hstrings[h][k+1] = NULL; - return hstrings[h][k] = mmt_strdup(p); + return cx->cfg_hstrings[h][k] = mmt_strdup(p); } -static LISTID cfg_comms; // A chain of comment lines -static LISTID cfg_prologue; // Comment lines at start of avrdude.conf -static char *lkw; // Last seen keyword -static int lkw_lineno; // Line number of that - -static LISTID cfg_strctcomms; // Passed on to config_gram.y -static LISTID cfg_pushedcomms; // Temporarily pushed main comments -static int cfg_pushed; // ... for memory sections - COMMENT *locate_comment(const LISTID comments, const char *where, int rhs) { if(comments) for(LNODEID ln=lfirst(comments); ln; ln=lnext(ln)) { @@ -536,57 +525,57 @@ COMMENT *locate_comment(const LISTID comments, const char *where, int rhs) { } static void addcomment(int rhs) { - if(lkw) { + if(cx->cfg_lkw) { COMMENT *node = mmt_malloc(sizeof(*node)); node->rhs = rhs; - node->kw = mmt_strdup(lkw); - node->comms = cfg_comms; - cfg_comms = NULL; - if(!cfg_strctcomms) - cfg_strctcomms = lcreat(NULL, 0); - ladd(cfg_strctcomms, node); + node->kw = mmt_strdup(cx->cfg_lkw); + node->comms = cx->cfg_comms; + cx->cfg_comms = NULL; + if(!cx->cfg_strctcomms) + cx->cfg_strctcomms = lcreat(NULL, 0); + ladd(cx->cfg_strctcomms, node); } } // Capture prologue during parsing (triggered by lexer.l) void cfg_capture_prologue(void) { - cfg_prologue = cfg_comms; - cfg_comms = NULL; + cx->cfg_prologue = cx->cfg_comms; + cx->cfg_comms = NULL; } LISTID cfg_get_prologue(void) { - return cfg_prologue; + return cx->cfg_prologue; } // Captures comments during parsing void capture_comment_str(const char *com, int lineno) { - if(!cfg_comms) - cfg_comms = lcreat(NULL, 0); - ladd(cfg_comms, mmt_strdup(com)); + if(!cx->cfg_comms) + cx->cfg_comms = lcreat(NULL, 0); + ladd(cx->cfg_comms, mmt_strdup(com)); // Last keyword lineno is the same as this comment's - if(lkw && lkw_lineno == lineno) + if(cx->cfg_lkw && cx->cfg_lkw_lineno == lineno) addcomment(1); // Register comms to show right of lkw = ...; } // Capture assignments (keywords left of =) and associate comments to them void capture_lvalue_kw(const char *kw, int lineno) { if(str_eq(kw, "memory")) { // Push part comments and start memory comments - if(!cfg_pushed) { // config_gram.y pops the part comments - cfg_pushed = 1; - cfg_pushedcomms = cfg_strctcomms; - cfg_strctcomms = NULL; + if(!cx->cfg_pushed) { // config_gram.y pops the part comments + cx->cfg_pushed = 1; + cx->cfg_pushedcomms = cx->cfg_strctcomms; + cx->cfg_strctcomms = NULL; } } if(str_eq(kw, "programmer") || str_eq(kw, "serialadapter") || str_eq(kw, "part") || str_eq(kw, "memory")) kw = "*"; // Show comment before programmer/part/memory - if(lkw) - mmt_free(lkw); - lkw = mmt_strdup(kw); - lkw_lineno = lineno; - if(cfg_comms) // Accrued list of # one-line comments + if(cx->cfg_lkw) + mmt_free(cx->cfg_lkw); + cx->cfg_lkw = mmt_strdup(kw); + cx->cfg_lkw_lineno = lineno; + if(cx->cfg_comms) // Accrued list of # one-line comments addcomment(0); // Register comment to appear before lkw assignment } @@ -594,16 +583,16 @@ void capture_lvalue_kw(const char *kw, int lineno) { LISTID cfg_move_comments(void) { capture_lvalue_kw(";", -1); - LISTID ret = cfg_strctcomms; - cfg_strctcomms = NULL; + LISTID ret = cx->cfg_strctcomms; + cx->cfg_strctcomms = NULL; return ret; } // config_gram.y calls this after ingressing the memory structure void cfg_pop_comms(void) { - if(cfg_pushed) { - cfg_pushed = 0; - cfg_strctcomms = cfg_pushedcomms; + if(cx->cfg_pushed) { + cx->cfg_pushed = 0; + cx->cfg_strctcomms = cx->cfg_pushedcomms; } } @@ -845,10 +834,9 @@ static int cmp_comp(const void *v1, const void *v2) { } Component_t *cfg_comp_search(const char *name, int strct) { - static int init; Component_t key; - if(!init++) + if(!cx->cfg_init_search++) qsort(avr_comp, sizeof avr_comp/sizeof*avr_comp, sizeof(Component_t), cmp_comp); diff --git a/src/libavrdude.h b/src/libavrdude.h index 0da1f9ba..11c8278a 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1558,6 +1558,17 @@ typedef struct { int bb_done; // Handshake variable in alarm handler void (*bb_saved_alarmf)(int); // Saved alarm handler #endif + + // Static variables from config.c + char **cfg_hstrings[1<<12]; // Hash lists for cache_string() + LISTID cfg_comms; // A chain of comment lines + LISTID cfg_prologue; // Comment lines at start of avrdude.conf + char *cfg_lkw; // Last seen keyword + int cfg_lkw_lineno; // Line number of that + LISTID cfg_strctcomms; // Passed on to config_gram.y + LISTID cfg_pushedcomms; // Temporarily pushed main comments + int cfg_pushed; // ... for memory sections + int cfg_init_search; // used in cfg_comp_search() } cx_t; extern cx_t *cx; From b84b2728d03c26d911e9ad325ec8f8361b259ad5 Mon Sep 17 00:00:00 2001 From: Funkeleinhorn Date: Wed, 8 May 2024 15:52:30 +0200 Subject: [PATCH 014/422] Make CS an extended parameter --- src/serprog.c | 125 +++++++++++++++++++++++++++++--------------------- 1 file changed, 73 insertions(+), 52 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index 3eb39f32..05d69ee7 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -20,6 +20,10 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * known limitations: + * - performance is suboptimal + * - connecting over TCP/IP to programmers is not implemented yet */ #include "ac_cfg.h" @@ -44,40 +48,41 @@ const char serprog_desc[] = "Programmer using the serprog protocol"; */ struct pdata { unsigned char cmd_bitmap[32]; + unsigned int cs; }; #define my (*(struct pdata *)(pgm->cookie)) // serprog protocol specification -/* According to Serial Flasher Protocol Specification - version 1 */ +// According to Serial Flasher Protocol Specification - version 1 #define S_ACK 0x06 #define S_NAK 0x15 -#define S_CMD_NOP 0x00 /* No operation */ -#define S_CMD_Q_IFACE 0x01 /* Query interface version */ -#define S_CMD_Q_CMDMAP 0x02 /* Query supported commands bitmap */ -#define S_CMD_Q_PGMNAME 0x03 /* Query programmer name */ -#define S_CMD_Q_SERBUF 0x04 /* Query Serial Buffer Size */ -#define S_CMD_Q_BUSTYPE 0x05 /* Query supported bustypes */ -#define S_CMD_Q_CHIPSIZE 0x06 /* Query supported chipsize (2^n format) */ -#define S_CMD_Q_OPBUF 0x07 /* Query operation buffer size */ -#define S_CMD_Q_WRNMAXLEN 0x08 /* Query Write to opbuf: Write-N maximum length */ -#define S_CMD_R_BYTE 0x09 /* Read a single byte */ -#define S_CMD_R_NBYTES 0x0A /* Read n bytes */ -#define S_CMD_O_INIT 0x0B /* Initialize operation buffer */ -#define S_CMD_O_WRITEB 0x0C /* Write opbuf: Write byte with address */ -#define S_CMD_O_WRITEN 0x0D /* Write to opbuf: Write-N */ -#define S_CMD_O_DELAY 0x0E /* Write opbuf: udelay */ -#define S_CMD_O_EXEC 0x0F /* Execute operation buffer */ -#define S_CMD_SYNCNOP 0x10 /* Special no-operation that returns NAK+ACK */ -#define S_CMD_Q_RDNMAXLEN 0x11 /* Query read-n maximum length */ -#define S_CMD_S_BUSTYPE 0x12 /* Set used bustype(s). */ -#define S_CMD_O_SPIOP 0x13 /* Perform SPI operation. */ -#define S_CMD_S_SPI_FREQ 0x14 /* Set SPI clock frequency */ -#define S_CMD_S_PIN_STATE 0x15 /* Enable/disable output drivers */ -#define S_CMD_S_SPI_CS 0x16 /* Set SPI chip select to use */ -#define S_CMD_S_SPI_MODE 0x17 /* Sets the spi mode used by S_CMD_O_SPIOP */ -#define S_CMD_S_CS_MODE 0x18 /* Sets the way the CS is controlled */ +#define S_CMD_NOP 0x00 // No operation +#define S_CMD_Q_IFACE 0x01 // Query interface version +#define S_CMD_Q_CMDMAP 0x02 // Query supported commands bitmap +#define S_CMD_Q_PGMNAME 0x03 // Query programmer name +#define S_CMD_Q_SERBUF 0x04 // Query Serial Buffer Size +#define S_CMD_Q_BUSTYPE 0x05 // Query supported bustypes +#define S_CMD_Q_CHIPSIZE 0x06 // Query supported chipsize (2^n format) +#define S_CMD_Q_OPBUF 0x07 // Query operation buffer size +#define S_CMD_Q_WRNMAXLEN 0x08 // Query Write to opbuf: Write-N maximum length +#define S_CMD_R_BYTE 0x09 // Read a single byte +#define S_CMD_R_NBYTES 0x0A // Read n bytes +#define S_CMD_O_INIT 0x0B // Initialize operation buffer +#define S_CMD_O_WRITEB 0x0C // Write opbuf: Write byte with address +#define S_CMD_O_WRITEN 0x0D // Write to opbuf: Write-N +#define S_CMD_O_DELAY 0x0E // Write opbuf: udelay +#define S_CMD_O_EXEC 0x0F // Execute operation buffer +#define S_CMD_SYNCNOP 0x10 // Special no-operation that returns NAK+ACK +#define S_CMD_Q_RDNMAXLEN 0x11 // Query read-n maximum length +#define S_CMD_S_BUSTYPE 0x12 // Set used bustype(s). +#define S_CMD_O_SPIOP 0x13 // Perform SPI operation. +#define S_CMD_S_SPI_FREQ 0x14 // Set SPI clock frequency +#define S_CMD_S_PIN_STATE 0x15 // Enable/disable output drivers +#define S_CMD_S_SPI_CS 0x16 // Set SPI chip select to use +#define S_CMD_S_SPI_MODE 0x17 // Sets the spi mode used by S_CMD_O_SPIOP +#define S_CMD_S_CS_MODE 0x18 // Sets the way the CS is controlled enum spi_mode { SPI_MODE_HALF_DUPLEX = 0, @@ -169,7 +174,7 @@ static bool is_serprog_cmd_supported(const unsigned char *cmd_bitmap, unsigned c static int serprog_open(PROGRAMMER *pgm, const char *pt) { const char *port_error = "unknown port specification, " - "please use the format /dev/ttyACM0,cs=0\n"; + "please use the format /dev/ttyACM0\n"; char port_default[] = "/dev/ttyACM0"; char *serialdev; char *port = mmt_strdup(pt); @@ -184,21 +189,6 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { return -1; } - // parse chip select if specified - uint8_t cs = 0; - char *option_str = strtok(NULL, ","); - if (option_str) { - char *option_name = strtok(option_str, "="); - if (strcmp(option_name, "cs") != 0) { - pmsg_error("unkown parameter: %s\n", option_name); - return -1; - } - char *option_value = strtok(NULL, "="); - if (option_value) { - cs = atoi(option_value); - } - } - union pinfo pinfo; pgm->port = port; pinfo.serialinfo.baud = pgm->baudrate? pgm->baudrate: 115200; @@ -278,18 +268,16 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { } // set active chip select - if (option_str != NULL) { - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { - memset(buf, 0, sizeof(buf)); - buf[0] = cs; - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot change CS\n"); - return -1; - } - } else { - pmsg_error("changing the CS is not supported by the %s programmer\n", pgmid); + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { + memset(buf, 0, sizeof(buf)); + buf[0] = my.cs; + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { + pmsg_error("cannot change CS\n"); return -1; } + } else if (my.cs > 0) { + pmsg_error("changing the CS is not supported by the programmer\n"); + return -1; } // set full duplex @@ -460,6 +448,38 @@ static void serprog_teardown(PROGRAMMER *pgm) { pgm->cookie = NULL; } +static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { + LNODEID ln; + const char *extended_param; + int rv = 0; + + for (ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); + + if (str_starts(extended_param, "cs=")) { + unsigned int cs; + if (sscanf(extended_param, "cs=%u", &cs) != 1) { + pmsg_error("invalid chip select '%s'\n", extended_param); + rv = -1; + } + my.cs = cs; + continue; + } + + if (str_eq(extended_param, "help")) { + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xcs=cs_num Set the chip select to use\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return LIBAVRDUDE_EXIT; + } + + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; + } + + return rv; +} + void serprog_initpgm(PROGRAMMER *pgm) { strcpy(pgm->type, "serprog"); @@ -479,5 +499,6 @@ void serprog_initpgm(PROGRAMMER *pgm) { // optional fields pgm->setup = serprog_setup; pgm->teardown = serprog_teardown; + pgm->parseextparams = serprog_parseextparams; } From 2266a0fe9c1ccfac3717a179cac2f2b9e81b1a30 Mon Sep 17 00:00:00 2001 From: Funkeleinhorn Date: Wed, 8 May 2024 16:42:30 +0200 Subject: [PATCH 015/422] Do enable/disable in correct functions instead of in open/close --- src/serprog.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index 05d69ee7..8a17f1ee 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -253,6 +253,11 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { return -1; } + if (my.cs > 0 && !is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { + pmsg_error("the %s programmer does not support changing the CS\n", pgmid); + return -1; + } + // set SPI clock frequency if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { memset(buf, 0, sizeof(buf)); @@ -267,17 +272,18 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { } } + return 0; +} + +static void serprog_enable(PROGRAMMER *pgm, const AVRPART *p) { + unsigned char buf[32]; // set active chip select if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { memset(buf, 0, sizeof(buf)); buf[0] = my.cs; if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { pmsg_error("cannot change CS\n"); - return -1; } - } else if (my.cs > 0) { - pmsg_error("changing the CS is not supported by the programmer\n"); - return -1; } // set full duplex @@ -285,7 +291,6 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { buf[0] = SPI_MODE_FULL_DUPLEX; if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { pmsg_error("cannot set SPI full duplex mode\n"); - return -1; } // set output @@ -294,7 +299,6 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { buf[0] = 1; // Pin state enable if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { pmsg_error("cannot enable pin state\n"); - return -1; } } @@ -302,12 +306,10 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { const unsigned char cs_mode = CS_MODE_SELECTED; if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { pmsg_error("cannot enable the reset pin\n"); - return -1; } - return 0; } -static void serprog_close(PROGRAMMER *pgm) { +static void serprog_disable(const PROGRAMMER *pgm) { unsigned char buf[32]; // switch cs to auto const unsigned char cs_mode = CS_MODE_AUTO; @@ -336,7 +338,9 @@ static void serprog_close(PROGRAMMER *pgm) { pmsg_error("cannot reset CS to CS_0\n"); } } +} +static void serprog_close(PROGRAMMER *pgm) { serial_close(&pgm->fd); } @@ -430,12 +434,6 @@ static int serprog_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { return 0; } -static void serprog_disable(const PROGRAMMER *pgm) { -} - -static void serprog_enable(PROGRAMMER *pgm, const AVRPART *p) { -} - static void serprog_display(const PROGRAMMER *pgm, const char *p) { } From 43e998b5c412e46ae24ff15a1ddfbaa9b916669f Mon Sep 17 00:00:00 2001 From: Funkeleinhorn Date: Wed, 8 May 2024 18:05:17 +0200 Subject: [PATCH 016/422] Add documentation and clean up code --- src/avrdude.1 | 11 +++++++++++ src/avrdude.conf.in | 4 ++-- src/doc/avrdude.texi | 15 +++++++++++++++ src/serprog.c | 18 ++++++++++-------- src/serprog.h | 4 +++- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index f5ed848d..28de8edb 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -1988,6 +1988,17 @@ the CS line being managed outside the application. .It Ar help Show help menu and exit. .El +.It Ar serprog +.Bl -tag -offset indent -width indent +.It Ar cs +Sets the chip select (CS) to use on supported programmers. +Programmers supporting the 0x16 serprog command can have more than the default CS (0). +This option allows to choose this additional CS's (1,2,3,...) for programming the AVR. +Here you can find the addition to the serprog spec enabling that: +https://review.coreboot.org/c/flashrom/+/80498 +.It Ar help +Show help menu and exit. +.El .El .Sh FILES .Bl -tag -offset indent -width /dev/ppi0XXX diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 968962f3..314b7ab7 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -1485,8 +1485,8 @@ programmer # serialupdi # The Serprog programmer implementation allows programming # with programmers using the serprog protocol from flashrom. -# See https://flashrom.org/classic_cli_manpage.html#serprog-programmer -# and https://wiki.flashrom.org/Serprog +# See https://flashrom.org/supported_hw/supported_prog/serprog/overview.html +# and https://flashrom.org/supported_hw/supported_prog/serprog/serprog-protocol.html # for details. programmer # serprog diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 68486c9c..83213daa 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -1645,6 +1645,21 @@ the CS line being managed outside the application. Show help menu and exit. @end table +@cindex Option @code{-x} serprog +@item serprog + +The serprog programmer type accepts the following extended parameter: +@table @code +@item @samp{cs} +Sets the chip select (CS) to use on supported programmers. +Programmers supporting the 0x16 serprog command can have more than the default CS (0). +This option allows to choose this additional CS's (1,2,3,...) for programming the AVR. +Here you can find the addition to the serprog spec enabling that: +https://review.coreboot.org/c/flashrom/+/80498 +@item @samp{help} +Show help menu and exit. +@end table + @end table @page diff --git a/src/serprog.c b/src/serprog.c index 8a17f1ee..66ec8762 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -1,6 +1,8 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Support for using serprog programmers to program over ISP + * Support for using serprog programmers to program over ISP. + * For information on serprog see: + * https://flashrom.org/supported_hw/supported_prog/serprog/index.html * * Copyright (C) 2024 Sydney Louisa Wilke * used linuxspi.c as a template: @@ -136,12 +138,8 @@ static int perform_serprog_cmd_full(const PROGRAMMER *pgm, uint8_t cmd, if (serial_recv(&pgm->fd, &resp_status_code, 1) < 0 || serial_recv(&pgm->fd, recv_buf, recv_len) < 0) return -1; - if (resp_status_code == S_ACK) - return 0; - else if (resp_status_code == S_NAK) - return 1; - else - return -1; + + return resp_status_code == S_ACK? 0: resp_status_code == S_NAK? 1: -1; } static int perform_serprog_cmd(const PROGRAMMER *pgm, uint8_t cmd, @@ -466,7 +464,11 @@ static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xcs=cs_num Set the chip select to use\n"); + msg_error(" -xcs=cs_num Sets the chip select (CS) to use on supported programmers.\n"); + msg_error(" Programmers supporting the 0x16 serprog command can have more than the default CS (0).\n"); + msg_error(" This option allows to choose this additional CS's (1,2,3,...) for programming the AVR.\n"); + msg_error(" Here you can find the addition to the serprog spec enabling that:\n"); + msg_error(" https://review.coreboot.org/c/flashrom/+/80498\n"); msg_error(" -xhelp Show this help menu and exit\n"); return LIBAVRDUDE_EXIT; } diff --git a/src/serprog.h b/src/serprog.h index 092dd95b..5de51452 100644 --- a/src/serprog.h +++ b/src/serprog.h @@ -1,6 +1,8 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2013 Kevin Cuzner + * Copyright (C) 2024 Sydney Louisa Wilke + * used linuxspi.h as a template: + * Copyright (C) 2013 Kevin Cuzner * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 40e75a447ff67f823de9e5f502bfdce349c2aeb4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 8 May 2024 18:59:32 +0100 Subject: [PATCH 017/422] Update avrintel.c from new atdf files --- src/avrintel.c | 1440 ++++++++++++++++++++++++------------- src/libavrdude-avrintel.h | 65 +- 2 files changed, 1002 insertions(+), 503 deletions(-) diff --git a/src/avrintel.c b/src/avrintel.c index df1ee6b1..01d6690e 100644 --- a/src/avrintel.c +++ b/src/avrintel.c @@ -9,7 +9,7 @@ * Meta-author Stefan Rueger * * v 1.3 - * 13.04.2024 + * 08.05.2024 * */ @@ -2135,6 +2135,12 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR16DD14*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD14*/ 401, rgftab_avr32dd14}, // Register file + //AVR16DU14 atdf // Sources + {"AVR16DU14", 386, F_AVR8X, {0x1E, 0x94, 0x3B}, // ID + /*AVR16DU14*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DU14*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR16DU14*/ 371, rgftab_avr16du14}, // Register file + //AVR16EB14 atdf, avrdude // Sources {"AVR16EB14", 380, F_AVR8X, {0x1E, 0x94, 0x49}, // ID /*AVR16EB14*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem @@ -2147,6 +2153,12 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR16DD20*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD20*/ 401, rgftab_avr32dd14}, // Register file + //AVR16DU20 atdf // Sources + {"AVR16DU20", 387, F_AVR8X, {0x1E, 0x94, 0x3A}, // ID + /*AVR16DU20*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DU20*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR16DU20*/ 372, rgftab_avr16du20}, // Register file + //AVR16EB20 atdf, avrdude // Sources {"AVR16EB20", 381, F_AVR8X, {0x1E, 0x94, 0x40}, // ID /*AVR16EB20*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem @@ -2159,6 +2171,12 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR16DD28*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD28*/ 401, rgftab_avr32dd14}, // Register file + //AVR16DU28 atdf // Sources + {"AVR16DU28", 388, F_AVR8X, {0x1E, 0x94, 0x39}, // ID + /*AVR16DU28*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR16DU28*/ 372, rgftab_avr16du20}, // Register file + //AVR16EA28 atdf, avrdude // Sources {"AVR16EA28", 332, F_AVR8X, {0x1E, 0x94, 0x37}, // ID /*AVR16EA28*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem @@ -2177,6 +2195,12 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR16DD32*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD32*/ 401, rgftab_avr32dd14}, // Register file + //AVR16DU32 atdf // Sources + {"AVR16DU32", 389, F_AVR8X, {0x1E, 0x94, 0x38}, // ID + /*AVR16DU32*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR16DU32*/ 372, rgftab_avr16du20}, // Register file + //AVR16EA32 atdf, avrdude // Sources {"AVR16EA32", 334, F_AVR8X, {0x1E, 0x94, 0x36}, // ID /*AVR16EA32*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem @@ -2201,12 +2225,24 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR32DD14*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD14*/ 401, rgftab_avr32dd14}, // Register file + //AVR32DU14 atdf // Sources + {"AVR32DU14", 390, F_AVR8X, {0x1E, 0x95, 0x4F}, // ID + /*AVR32DU14*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DU14*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR32DU14*/ 371, rgftab_avr16du14}, // Register file + //AVR32DD20 atdf, avrdude // Sources {"AVR32DD20", 337, F_AVR8X, {0x1E, 0x95, 0x3A}, // ID /*AVR32DD20*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DD20*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD20*/ 401, rgftab_avr32dd14}, // Register file + //AVR32DU20 atdf // Sources + {"AVR32DU20", 391, F_AVR8X, {0x1E, 0x95, 0x4E}, // ID + /*AVR32DU20*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DU20*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR32DU20*/ 372, rgftab_avr16du20}, // Register file + //AVR32DA28 atdf, avrdude // Sources {"AVR32DA28", 338, F_AVR8X, {0x1E, 0x95, 0x34}, // ID /*AVR32DA28*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem @@ -2225,6 +2261,12 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR32DD28*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD28*/ 401, rgftab_avr32dd14}, // Register file + //AVR32DU28 atdf // Sources + {"AVR32DU28", 392, F_AVR8X, {0x1E, 0x95, 0x40}, // ID + /*AVR32DU28*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR32DU28*/ 372, rgftab_avr16du20}, // Register file + //AVR32EA28 atdf, avrdude // Sources {"AVR32EA28", 341, F_AVR8X, {0x1E, 0x95, 0x3E}, // ID /*AVR32EA28*/ 0, 0x08000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7000, 0x1000, // Mem @@ -2249,6 +2291,12 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR32DD32*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD32*/ 401, rgftab_avr32dd14}, // Register file + //AVR32DU32 atdf // Sources + {"AVR32DU32", 393, F_AVR8X, {0x1E, 0x95, 0x3F}, // ID + /*AVR32DU32*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR32DU32*/ 372, rgftab_avr16du20}, // Register file + //AVR32EA32 atdf, avrdude // Sources {"AVR32EA32", 345, F_AVR8X, {0x1E, 0x95, 0x3D}, // ID /*AVR32EA32*/ 0, 0x08000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7000, 0x1000, // Mem @@ -2306,8 +2354,8 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown //AVR64DU28 atdf // Sources {"AVR64DU28", 384, F_AVR8X, {0x1E, 0x96, 0x22}, // ID /*AVR64DU28*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem - /*AVR64DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr64du28, // ISRs, Config - /*AVR64DU28*/ 372, rgftab_avr64du28}, // Register file + /*AVR64DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR64DU28*/ 372, rgftab_avr16du20}, // Register file //AVR64EA28 atdf, avrdude // Sources {"AVR64EA28", 354, F_AVR8X, {0x1E, 0x96, 0x20}, // ID @@ -2336,8 +2384,8 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown //AVR64DU32 atdf // Sources {"AVR64DU32", 385, F_AVR8X, {0x1E, 0x96, 0x21}, // ID /*AVR64DU32*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem - /*AVR64DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr64du28, // ISRs, Config - /*AVR64DU32*/ 372, rgftab_avr64du28}, // Register file + /*AVR64DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config + /*AVR64DU32*/ 372, rgftab_avr16du20}, // Register file //AVR64EA32 atdf, avrdude // Sources {"AVR64EA32", 358, F_AVR8X, {0x1E, 0x96, 0x1F}, // ID @@ -7205,7 +7253,10 @@ const char * const vtab_avr64dd32[vts_avr64dd32] = { "NVMCTRL_EE", // 35: NVM EEPROM }; -// AVR64DU32 AVR64DU28 +/* + * AVR64DU32 AVR64DU28 AVR32DU32 AVR32DU28 AVR32DU20 AVR32DU14 AVR16DU32 AVR16DU28 AVR16DU20 + * AVR16DU14 + */ const char * const vtab_avr64du32[vts_avr64du32] = { "RESET", // 0: Reset (various reasons) "CRCSCAN_NMI", // 1: CRCSCAN Non-maskable Interrupt @@ -9192,12 +9243,13 @@ static const Valueitem_t _values_eesave_atmega328[2] = { * ATtiny804 ATtiny806 ATtiny807 ATtiny814 ATtiny816 ATtiny817 ATtiny824 ATtiny826 ATtiny827 * ATtiny1604 ATtiny1606 ATtiny1607 ATtiny1614 ATtiny1616 ATtiny1617 ATtiny1626 ATtiny1627 * ATtiny3216 ATtiny3217 ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 - * ATmega1609 ATmega3208 ATmega3209 ATmega4808 ATmega4809 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 - * AVR16DD28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 - * AVR32DB28 AVR32DD28 AVR32EA28 AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 - * AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 - * AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 - * AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * ATmega1609 ATmega3208 ATmega3209 ATmega4808 ATmega4809 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 + * AVR16DU20 AVR16EB20 AVR16DD28 AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 + * AVR16EB32 AVR16EA48 AVR32DU14 AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 + * AVR32EA28 AVR32DA32 AVR32DB32 AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 + * AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 + * AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 + * AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_eesave_attiny204[2] = { {0, "eex_erased", "EEPROM content is erased during chip erase"}, @@ -9491,11 +9543,11 @@ static const Valueitem_t _values_bodlevel_attiny204[3] = { }; /* - * AVR32DD14 AVR16DD14 AVR16DD20 AVR16DD28 AVR16DD32 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32DA48 AVR32DB48 AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 - * AVR64DD28 AVR64DU28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64DA48 AVR64DB48 AVR64DA64 - * AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 - * AVR128DB64 + * AVR32DD14 AVR16DD14 AVR16DU14 AVR16DD20 AVR16DU20 AVR16DD28 AVR16DU28 AVR16DD32 AVR16DU32 + * AVR32DU14 AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32DA48 AVR32DB48 AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 AVR64DD28 + * AVR64DU28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 + * AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_bodlevel_avr32dd14[4] = { {0, "bod_1v9", "brownout detection at 1.9 V"}, @@ -9770,12 +9822,13 @@ static const Valueitem_t _values_sut_atmega64hve[4] = { * ATtiny804 ATtiny806 ATtiny807 ATtiny814 ATtiny816 ATtiny817 ATtiny824 ATtiny826 ATtiny827 * ATtiny1604 ATtiny1606 ATtiny1607 ATtiny1614 ATtiny1616 ATtiny1617 ATtiny1626 ATtiny1627 * ATtiny3216 ATtiny3217 ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 - * ATmega1609 ATmega3208 ATmega3209 ATmega4808 ATmega4809 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 - * AVR16DD28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 - * AVR32DB28 AVR32DD28 AVR32EA28 AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 - * AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 - * AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 - * AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * ATmega1609 ATmega3208 ATmega3209 ATmega4808 ATmega4809 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 + * AVR16DU20 AVR16EB20 AVR16DD28 AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 + * AVR16EB32 AVR16EA48 AVR32DU14 AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 + * AVR32EA28 AVR32DA32 AVR32DB32 AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 + * AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 + * AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 + * AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_sut_attiny204[8] = { {0, "sut_0ms", "startup time 0 ms"}, @@ -10485,12 +10538,13 @@ static const Valueitem_t _values_wdtperiod_attiny204[12] = { }; /* - * AVR32DD14 AVR64EA48 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 AVR16DD28 AVR16EA28 AVR16EB28 - * AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32EA28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 - * AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 - * AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 - * AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * AVR32DD14 AVR64EA48 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 AVR16DU20 AVR16EB20 AVR16DD28 + * AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DU14 + * AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32EA28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 + * AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 + * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 + * AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_wdtperiod_avr32dd14[12] = { {0x00, "t_off", "watchdog timer off"}, @@ -10531,12 +10585,13 @@ static const Valueitem_t _values_wdtwindow_attiny204[12] = { }; /* - * AVR32DD14 AVR64EA48 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 AVR16DD28 AVR16EA28 AVR16EB28 - * AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32EA28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 - * AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 - * AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 - * AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * AVR32DD14 AVR64EA48 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 AVR16DU20 AVR16EB20 AVR16DD28 + * AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DU14 + * AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32EA28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 + * AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 + * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 + * AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_wdtwindow_avr32dd14[12] = { {0x00, "t_off", "window mode off"}, @@ -10568,12 +10623,13 @@ static const Valueitem_t _values_bodsleep_attiny204[3] = { }; /* - * AVR32DD14 AVR64EA48 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 AVR16DD28 AVR16EA28 AVR16EB28 - * AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32EA28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 - * AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 - * AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 - * AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * AVR32DD14 AVR64EA48 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 AVR16DU20 AVR16EB20 AVR16DD28 + * AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DU14 + * AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32EA28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 + * AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 + * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 + * AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_bodsleep_avr32dd14[3] = { {0, "bod_disabled", "brownout detection disabled"}, @@ -10597,12 +10653,13 @@ static const Valueitem_t _values_bodactive_attiny204[4] = { }; /* - * AVR32DD14 AVR64EA48 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 AVR16DD28 AVR16EA28 AVR16EB28 - * AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32EA28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 - * AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 - * AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 - * AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * AVR32DD14 AVR64EA48 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 AVR16DU20 AVR16EB20 AVR16DD28 + * AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DU14 + * AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32EA28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 + * AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 + * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 + * AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_bodactive_avr32dd14[4] = { {0, "bod_disabled", "brownout detection disabled"}, @@ -10625,12 +10682,13 @@ static const Valueitem_t _values_bodsampfreq_attiny204[2] = { }; /* - * AVR32DD14 AVR64EA48 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 AVR16DD28 AVR16EA28 AVR16EB28 - * AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32EA28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 - * AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 - * AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 - * AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * AVR32DD14 AVR64EA48 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 AVR16DU20 AVR16EB20 AVR16DD28 + * AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DU14 + * AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32EA28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 + * AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 + * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 + * AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_bodsampfreq_avr32dd14[2] = { {0, "bod_128hz", "128 Hz sampling frequency"}, @@ -10781,8 +10839,9 @@ static const Valueitem_t _values_rstpincfg_attiny1624[4] = { /* * AVR32DD14 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 ATmega3209 ATmega4808 ATmega4809 - * AVR16DD14 AVR16DD20 AVR16DD28 AVR16DD32 AVR32DD20 AVR32DD28 AVR32DD32 AVR64DD14 AVR64DD20 - * AVR64DD28 AVR64DU28 AVR64DD32 AVR64DU32 + * AVR16DD14 AVR16DU14 AVR16DD20 AVR16DU20 AVR16DD28 AVR16DU28 AVR16DD32 AVR16DU32 AVR32DU14 + * AVR32DD20 AVR32DU20 AVR32DD28 AVR32DU28 AVR32DD32 AVR32DU32 AVR64DD14 AVR64DD20 AVR64DD28 + * AVR64DU28 AVR64DD32 AVR64DU32 */ static const Valueitem_t _values_rstpincfg_avr32dd14[2] = { {0, "gpio", "GPIO mode"}, @@ -10814,12 +10873,13 @@ static const Valueitem_t _values_rstpincfg_avr32da28[2] = { * ATtiny804 ATtiny806 ATtiny807 ATtiny814 ATtiny816 ATtiny817 ATtiny824 ATtiny826 ATtiny827 * ATtiny1604 ATtiny1606 ATtiny1607 ATtiny1614 ATtiny1616 ATtiny1617 ATtiny1626 ATtiny1627 * ATtiny3216 ATtiny3217 ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 - * ATmega1609 ATmega3208 ATmega3209 ATmega4808 ATmega4809 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 - * AVR16DD28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 - * AVR32DB28 AVR32DD28 AVR32EA28 AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 - * AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 - * AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 - * AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * ATmega1609 ATmega3208 ATmega3209 ATmega4808 ATmega4809 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 + * AVR16DU20 AVR16EB20 AVR16DD28 AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 + * AVR16EB32 AVR16EA48 AVR32DU14 AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 + * AVR32EA28 AVR32DA32 AVR32DB32 AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 + * AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 + * AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 + * AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_crcsrc_attiny204[4] = { {0, "flash", "CRC of entire flash (boot, application code and application data)"}, @@ -10838,11 +10898,11 @@ static const Valueitem_t _values_toutdis_attiny1624[2] = { }; /* - * AVR32DD14 AVR16DD14 AVR16DD20 AVR16DD28 AVR16DD32 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32DA48 AVR32DB48 AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 - * AVR64DD28 AVR64DU28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64DA48 AVR64DB48 AVR64DA64 - * AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 - * AVR128DB64 + * AVR32DD14 AVR16DD14 AVR16DU14 AVR16DD20 AVR16DU20 AVR16DD28 AVR16DU28 AVR16DD32 AVR16DU32 + * AVR32DU14 AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32DA48 AVR32DB48 AVR64DD14 AVR64DD20 AVR64DA28 AVR64DB28 AVR64DD28 + * AVR64DU28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 + * AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_clksel_avr32dd14[2] = { {0, "oschf", "1-32 MHz internal oscillator"}, @@ -10850,8 +10910,9 @@ static const Valueitem_t _values_clksel_avr32dd14[2] = { }; /* - * AVR32DD14 AVR16DD14 AVR16DD20 AVR16DD28 AVR16DD32 AVR32DD20 AVR32DD28 AVR32DD32 AVR64DD14 - * AVR64DD20 AVR64DD28 AVR64DU28 AVR64DD32 AVR64DU32 + * AVR32DD14 AVR16DD14 AVR16DU14 AVR16DD20 AVR16DU20 AVR16DD28 AVR16DU28 AVR16DD32 AVR16DU32 + * AVR32DU14 AVR32DD20 AVR32DU20 AVR32DD28 AVR32DU28 AVR32DD32 AVR32DU32 AVR64DD14 AVR64DD20 + * AVR64DD28 AVR64DU28 AVR64DD32 AVR64DU32 */ static const Valueitem_t _values_updipincfg_avr32dd14[2] = { {0, "gpio", "GPIO mode"}, @@ -10868,12 +10929,13 @@ static const Valueitem_t _values_updipincfg_avr64ea48[2] = { }; /* - * AVR32DD14 AVR64EA48 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 AVR16DD28 AVR16EA28 AVR16EB28 - * AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32EA28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 - * AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 - * AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 - * AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * AVR32DD14 AVR64EA48 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 AVR16DU20 AVR16EB20 AVR16DD28 + * AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DU14 + * AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32EA28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 + * AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 + * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 + * AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_crcsel_avr32dd14[2] = { {0, "crc16", "enable CRC16"}, @@ -10891,12 +10953,13 @@ static const Valueitem_t _values_mvsyscfg_avr32dd14[2] = { }; /* - * AVR32DD14 AVR64EA48 AVR16DD14 AVR16EB14 AVR16DD20 AVR16EB20 AVR16DD28 AVR16EA28 AVR16EB28 - * AVR16DD32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DD20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32EA28 - * AVR32DA32 AVR32DB32 AVR32DD32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 - * AVR64DA28 AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 - * AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 - * AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 + * AVR32DD14 AVR64EA48 AVR16DD14 AVR16DU14 AVR16EB14 AVR16DD20 AVR16DU20 AVR16EB20 AVR16DD28 + * AVR16DU28 AVR16EA28 AVR16EB28 AVR16DD32 AVR16DU32 AVR16EA32 AVR16EB32 AVR16EA48 AVR32DU14 + * AVR32DD20 AVR32DU20 AVR32DA28 AVR32DB28 AVR32DD28 AVR32DU28 AVR32EA28 AVR32DA32 AVR32DB32 + * AVR32DD32 AVR32DU32 AVR32EA32 AVR32DA48 AVR32DB48 AVR32EA48 AVR64DD14 AVR64DD20 AVR64DA28 + * AVR64DB28 AVR64DD28 AVR64DU28 AVR64EA28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64EA32 + * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 + * AVR128DB48 AVR128DA64 AVR128DB64 */ static const Valueitem_t _values_key_avr32dd14[2] = { {0x5cc5c55c, "nolock", "no locks"}, @@ -10921,30 +10984,39 @@ static const Valueitem_t _values_s8535c_at90s8535comp[2] = { {1, "c8535_disabled", "AT90S4434/8535 compatibility mode disabled"}, }; +/* + * AVR16DU14 AVR16DU20 AVR16DU28 AVR16DU32 AVR32DU14 AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 + * AVR64DU32 + */ +static const Valueitem_t _values_usbsink_avr16du14[2] = { + {0, "disable", "USB VREG cannot sink current"}, + {1, "enable", "USB VREG can sink current"}, +}; + +/* + * AVR16DU14 AVR16DU20 AVR16DU28 AVR16DU32 AVR32DU14 AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 + * AVR64DU32 + */ +static const Valueitem_t _values_nvmlevel_avr16du14[2] = { + {1, "nvmaccdis", "NVM access through UPDI disabled"}, + {3, "basic", "UPDI and UPDI pins working normally"}, +}; + // AVR16EB14 AVR16EB20 AVR16EB28 AVR16EB32 static const Valueitem_t _values_nvmlevel_avr16eb14[2] = { {2, "nvmaccdis", "NVM access through UPDI disabled"}, {3, "basic", "UPDI and UPDI pins working normally"}, }; -// AVR64DU28 AVR64DU32 -static const Valueitem_t _values_nvmlevel_avr64du28[2] = { - {1, "nvmaccdis", "NVM access through UPDI disabled"}, - {3, "basic", "UPDI and UPDI pins working normally"}, -}; - -// AVR16EB14 AVR16EB20 AVR16EB28 AVR16EB32 AVR64DU28 AVR64DU32 -static const Valueitem_t _values_nvmkey_avr16eb14[2] = { +/* + * AVR16DU14 AVR16EB14 AVR16DU20 AVR16EB20 AVR16DU28 AVR16EB28 AVR16DU32 AVR16EB32 AVR32DU14 + * AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 AVR64DU32 + */ +static const Valueitem_t _values_nvmkey_avr16du14[2] = { {0x00, "notact", "not active"}, {0xb45, "nvmact", "NVM protection active"}, }; -// AVR64DU28 AVR64DU32 -static const Valueitem_t _values_usbsink_avr64du28[2] = { - {0, "disable", "USB VREG can not sink current"}, - {1, "enable", "USB VREG can sink current"}, -}; - // Configuration tables @@ -12895,6 +12967,33 @@ const Configitem_t cfgtab_atmega808[15] = { {"lb", 2, _values_lb_attiny204, "lock", 0, 0xff, 0, 0xc5, "lock bits"}, }; +/* + * AVR16DU14 AVR16DU20 AVR16DU28 AVR16DU32 AVR32DU14 AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 + * AVR64DU32 + */ +const Configitem_t cfgtab_avr16du14[20] = { + {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, + {"wdtwindow", 12, _values_wdtwindow_avr32dd14, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, + {"bodsleep", 3, _values_bodsleep_avr32dd14, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, + {"bodactive", 4, _values_bodactive_avr32dd14, "bodcfg", 1, 0x0c, 2, 0, "brownout detection in active/idle mode"}, + {"bodsampfreq", 2, _values_bodsampfreq_avr32dd14, "bodcfg", 1, 0x10, 4, 0, "brownout detection sampling frequency"}, + {"bodlevel", 4, _values_bodlevel_avr32dd14, "bodcfg", 1, 0xe0, 5, 0, "brownout detection level"}, + {"clksel", 2, _values_clksel_avr32dd14, "osccfg", 2, 0x07, 0, 0, "oscillator frequency"}, + {"eesave", 2, _values_eesave_attiny204, "syscfg0", 5, 0x01, 0, 0, "EEPROM after chip erase"}, + {"browsave", 0, NULL, "syscfg0", 5, 0x02, 1, 0, "Boot Row Save"}, + {"rstpincfg", 2, _values_rstpincfg_avr32dd14, "syscfg0", 5, 0x08, 3, 0, "reset pin configuration"}, + {"updipincfg", 2, _values_updipincfg_avr32dd14, "syscfg0", 5, 0x10, 4, 1, "UPDI pin configuration"}, + {"crcsel", 2, _values_crcsel_avr32dd14, "syscfg0", 5, 0x20, 5, 0, "CRC select"}, + {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, + {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 0, "startup time"}, + {"usbsink", 2, _values_usbsink_avr16du14, "syscfg1", 6, 0x08, 3, 1, "USB Voltage Regulator Current Sink Enable"}, + {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, + {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, + {"nvmlevel", 2, _values_nvmlevel_avr16du14, "pdicfg", 10, 0x03, 0, 3, "NVM protection level"}, + {"nvmkey", 2, _values_nvmkey_avr16du14, "pdicfg", 10, 0xfff0, 4, 0x00, "NVM protection activation key"}, + {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, +}; + // AVR16EB14 AVR16EB20 AVR16EB28 AVR16EB32 const Configitem_t cfgtab_avr16eb14[18] = { {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, @@ -12913,7 +13012,7 @@ const Configitem_t cfgtab_avr16eb14[18] = { {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, {"nvmlevel", 2, _values_nvmlevel_avr16eb14, "pdicfg", 10, 0x03, 0, 3, "NVM protection level"}, - {"nvmkey", 2, _values_nvmkey_avr16eb14, "pdicfg", 10, 0xfff0, 4, 0x00, "NVM protection activation key"}, + {"nvmkey", 2, _values_nvmkey_avr16du14, "pdicfg", 10, 0xfff0, 4, 0x00, "NVM protection activation key"}, {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, }; @@ -12962,30 +13061,6 @@ const Configitem_t cfgtab_avr32db28[16] = { {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, }; -// AVR64DU28 AVR64DU32 -const Configitem_t cfgtab_avr64du28[20] = { - {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, - {"wdtwindow", 12, _values_wdtwindow_avr32dd14, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, - {"bodsleep", 3, _values_bodsleep_avr32dd14, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, - {"bodactive", 4, _values_bodactive_avr32dd14, "bodcfg", 1, 0x0c, 2, 0, "brownout detection in active/idle mode"}, - {"bodsampfreq", 2, _values_bodsampfreq_avr32dd14, "bodcfg", 1, 0x10, 4, 0, "brownout detection sampling frequency"}, - {"bodlevel", 4, _values_bodlevel_avr32dd14, "bodcfg", 1, 0xe0, 5, 0, "brownout detection level"}, - {"clksel", 2, _values_clksel_avr32dd14, "osccfg", 2, 0x07, 0, 0, "oscillator frequency"}, - {"eesave", 2, _values_eesave_attiny204, "syscfg0", 5, 0x01, 0, 0, "EEPROM after chip erase"}, - {"browsave", 0, NULL, "syscfg0", 5, 0x02, 1, 0, "Boot Row Save"}, - {"rstpincfg", 2, _values_rstpincfg_avr32dd14, "syscfg0", 5, 0x08, 3, 0, "reset pin configuration"}, - {"updipincfg", 2, _values_updipincfg_avr32dd14, "syscfg0", 5, 0x10, 4, 1, "UPDI pin configuration"}, - {"crcsel", 2, _values_crcsel_avr32dd14, "syscfg0", 5, 0x20, 5, 0, "CRC select"}, - {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, - {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 0, "startup time"}, - {"usbsink", 2, _values_usbsink_avr64du28, "syscfg1", 6, 0x08, 3, 1, "USB Voltage Regulator Current Sink Enable"}, - {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, - {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, - {"nvmlevel", 2, _values_nvmlevel_avr64du28, "pdicfg", 10, 0x03, 0, 3, "NVM protection level"}, - {"nvmkey", 2, _values_nvmkey_avr16eb14, "pdicfg", 10, 0xfff0, 4, 0x00, "NVM protection activation key"}, - {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, -}; - // I/O Register files @@ -43978,6 +44053,381 @@ const Register_file_t rgftab_atmega3209[432] = { // I/O memory [0, 4351] {"nvmctrl.addr", 0x1008, 2, -1, -1, "address register (16 bits)"}, }; +// AVR16DU14 AVR32DU14 +const Register_file_t rgftab_avr16du14[371] = { // I/O memory [0, 4159] + {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, + {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, + {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, + {"vporta.intflags", 0x0003, 1, -1, 0x00, "interrupt flags register"}, + {"vportc.dir", 0x0008, 1, -1, 0x00, "data direction register"}, + {"vportc.out", 0x0009, 1, -1, 0x00, "I/O port output register"}, + {"vportc.in", 0x000a, 1, -1, 0x00, "I/O port input register"}, + {"vportc.intflags", 0x000b, 1, -1, 0x00, "interrupt flags register"}, + {"vportd.dir", 0x000c, 1, -1, 0x00, "data direction register"}, + {"vportd.out", 0x000d, 1, -1, 0x00, "I/O port output register"}, + {"vportd.in", 0x000e, 1, -1, 0x00, "I/O port input register"}, + {"vportd.intflags", 0x000f, 1, -1, 0x00, "interrupt flags register"}, + {"vportf.dir", 0x0014, 1, -1, 0x00, "data direction register"}, + {"vportf.out", 0x0015, 1, -1, 0x00, "I/O port output register"}, + {"vportf.in", 0x0016, 1, -1, 0x00, "I/O port input register"}, + {"vportf.intflags", 0x0017, 1, -1, 0x00, "interrupt flags register"}, + {"gpr.gpr0", 0x001c, 1, -1, -1, "general purpose register 0"}, + {"gpr.gpr1", 0x001d, 1, -1, -1, "general purpose register 1"}, + {"gpr.gpr2", 0x001e, 1, -1, -1, "general purpose register 2"}, + {"gpr.gpr3", 0x001f, 1, -1, -1, "general purpose register 3"}, + {"cpu.ccp", 0x0034, 1, -1, 0x00, "configuration change protection register"}, + {"cpu.rampz", 0x003b, 1, -1, 0x00, "extended Z register"}, + {"cpu.sp", 0x003d, 2, -1, 0x7fff, "stack pointer (16 bits)"}, + {"cpu.sreg", 0x003f, 1, -1, 0x00, "status register"}, + {"rstctrl.rstfr", 0x0040, 1, -1, 0x00, "reset flags register"}, + {"rstctrl.swrr", 0x0041, 1, -1, 0x00, "software reset register"}, + {"slpctrl.ctrla", 0x0050, 1, -1, 0x00, "control register A"}, + {"slpctrl.vregctrl", 0x0051, 1, -1, 0x00, "control B register"}, + {"clkctrl.mclkctrla", 0x0060, 1, -1, 0x00, "MCLK control A register"}, + {"clkctrl.mclkctrlb", 0x0061, 1, -1, 0x00, "MCLK control B register"}, + {"clkctrl.mclkctrlc", 0x0062, 1, -1, 0x00, "MCLK control C register"}, + {"clkctrl.mclkintctrl", 0x0063, 1, -1, 0x00, "MCLK interrupt control register"}, + {"clkctrl.mclkintflags", 0x0064, 1, -1, 0x00, "MCLK interrupt flags register"}, + {"clkctrl.mclkstatus", 0x0065, 1, -1, 0x00, "MCLK status register"}, + {"clkctrl.mclktimebase", 0x0066, 1, -1, 0x00, "MCLK timebase register"}, + {"clkctrl.oschfctrla", 0x0068, 1, -1, 0x0c, "OSCHF control A register"}, + {"clkctrl.oschftune", 0x0069, 1, -1, -1, "OSCHF tune register"}, + {"clkctrl.oschfstatus", 0x006a, 1, -1, -1, "OSCHF status register"}, + {"clkctrl.osc32kctrla", 0x0078, 1, -1, 0x00, "OSC32K control A register"}, + {"clkctrl.xosc32kctrla", 0x007c, 1, -1, 0x00, "XOSC32K control A register"}, + {"clkctrl.xoschfctrla", 0x0080, 1, -1, 0x00, "XOSC HF control A register"}, + {"clkctrl.usbpllstatus", 0x0085, 1, -1, 0x00, "PLL status register"}, + {"bod.ctrla", 0x00a0, 1, -1, 0x01, "control register A"}, + {"bod.ctrlb", 0x00a1, 1, -1, 0x00, "control register B"}, + {"bod.vlmctrla", 0x00a8, 1, -1, 0x00, "voltage level monitor control register"}, + {"bod.intctrl", 0x00a9, 1, -1, 0x00, "interrupt control register"}, + {"bod.intflags", 0x00aa, 1, -1, 0x00, "interrupt flags register"}, + {"bod.status", 0x00ab, 1, -1, 0x00, "status register"}, + {"vref.acref", 0x00b0, 1, -1, 0x00, "AC reference register"}, + {"wdt.ctrla", 0x0100, 1, -1, 0x00, "control register A"}, + {"wdt.status", 0x0101, 1, -1, 0x00, "status register"}, + {"cpuint.ctrla", 0x0110, 1, -1, 0x00, "control register A"}, + {"cpuint.status", 0x0111, 1, -1, 0x00, "status register"}, + {"cpuint.lvl0pri", 0x0112, 1, -1, 0x00, "interrupt level 0 priority register"}, + {"cpuint.lvl1vec", 0x0113, 1, -1, 0x00, "interrupt level 1 priority vector register"}, + {"crcscan.ctrla", 0x0120, 1, -1, 0x00, "control register A"}, + {"crcscan.ctrlb", 0x0121, 1, -1, 0x00, "control register B"}, + {"crcscan.status", 0x0122, 1, -1, 0x02, "status register"}, + {"rtc.ctrla", 0x0140, 1, -1, 0x00, "control register A"}, + {"rtc.status", 0x0141, 1, -1, 0x00, "status register"}, + {"rtc.intctrl", 0x0142, 1, -1, 0x00, "interrupt control register"}, + {"rtc.intflags", 0x0143, 1, -1, 0x00, "interrupt flags register"}, + {"rtc.temp", 0x0144, 1, -1, -1, "temporary register"}, + {"rtc.dbgctrl", 0x0145, 1, -1, 0x00, "debug control register"}, + {"rtc.calib", 0x0146, 1, -1, 0x00, "calibration register"}, + {"rtc.clksel", 0x0147, 1, -1, 0x00, "clock select register"}, + {"rtc.cnt", 0x0148, 2, -1, -1, "counter (16 bits)"}, + {"rtc.per", 0x014a, 2, -1, 0xffff, "period register (16 bits)"}, + {"rtc.cmp", 0x014c, 2, -1, -1, "compare register (16 bits)"}, + {"rtc.pitctrla", 0x0150, 1, -1, 0x00, "PIT control A register"}, + {"rtc.pitstatus", 0x0151, 1, -1, 0x00, "PIT status register"}, + {"rtc.pitintctrl", 0x0152, 1, -1, 0x00, "PIT interrupt control register"}, + {"rtc.pitintflags", 0x0153, 1, -1, 0x00, "PIT interrupt flags register"}, + {"rtc.pitdbgctrl", 0x0155, 1, -1, 0x00, "PIT debug control register"}, + {"rtc.pitevgenctrla", 0x0156, 1, -1, 0x00, "PIT event generation control A register"}, + {"ccl.ctrla", 0x01c0, 1, -1, 0x00, "control register A"}, + {"ccl.seqctrl0", 0x01c1, 1, -1, 0x00, "sequential control register 0"}, + {"ccl.seqctrl1", 0x01c2, 1, -1, 0x00, "sequential control register 1"}, + {"ccl.intctrl0", 0x01c5, 1, -1, 0x00, "interrupt control register 0"}, + {"ccl.intflags", 0x01c7, 1, -1, 0x00, "interrupt flags register"}, + {"ccl.lut0ctrla", 0x01c8, 1, -1, 0x00, "LUT 0 control A register"}, + {"ccl.lut0ctrlb", 0x01c9, 1, -1, 0x00, "LUT 0 control B register"}, + {"ccl.lut0ctrlc", 0x01ca, 1, -1, 0x00, "LUT 0 control C register"}, + {"ccl.truth0", 0x01cb, 1, -1, 0x00, "truth register 0"}, + {"ccl.lut1ctrla", 0x01cc, 1, -1, 0x00, "LUT 1 control A register"}, + {"ccl.lut1ctrlb", 0x01cd, 1, -1, 0x00, "LUT 1 control B register"}, + {"ccl.lut1ctrlc", 0x01ce, 1, -1, 0x00, "LUT 1 control C register"}, + {"ccl.truth1", 0x01cf, 1, -1, 0x00, "truth register 1"}, + {"ccl.lut2ctrla", 0x01d0, 1, -1, 0x00, "LUT 2 control A register"}, + {"ccl.lut2ctrlb", 0x01d1, 1, -1, 0x00, "LUT 2 control B register"}, + {"ccl.lut2ctrlc", 0x01d2, 1, -1, 0x00, "LUT 2 control C register"}, + {"ccl.truth2", 0x01d3, 1, -1, 0x00, "truth register 2"}, + {"ccl.lut3ctrla", 0x01d4, 1, -1, 0x00, "LUT 3 control A register"}, + {"ccl.lut3ctrlb", 0x01d5, 1, -1, 0x00, "LUT 3 control B register"}, + {"ccl.lut3ctrlc", 0x01d6, 1, -1, 0x00, "LUT 3 control C register"}, + {"ccl.truth3", 0x01d7, 1, -1, 0x00, "truth register 3"}, + {"evsys.sweventa", 0x0200, 1, -1, 0x00, "software event A register"}, + {"evsys.channel0", 0x0210, 1, -1, 0x00, "multiplexer channel 0 register"}, + {"evsys.channel1", 0x0211, 1, -1, 0x00, "multiplexer channel 1 register"}, + {"evsys.channel2", 0x0212, 1, -1, 0x00, "multiplexer channel 2 register"}, + {"evsys.channel3", 0x0213, 1, -1, 0x00, "multiplexer channel 3 register"}, + {"evsys.channel4", 0x0214, 1, -1, 0x00, "multiplexer channel 4 register"}, + {"evsys.channel5", 0x0215, 1, -1, 0x00, "multiplexer channel 5 register"}, + {"evsys.userccllut0a", 0x0220, 1, -1, 0x00, "user CCL LUT 0 event A register"}, + {"evsys.userccllut0b", 0x0221, 1, -1, 0x00, "user CCL LUT 0 event B register"}, + {"evsys.userccllut1a", 0x0222, 1, -1, 0x00, "user CCL LUT 1 event A register"}, + {"evsys.userccllut1b", 0x0223, 1, -1, 0x00, "user CCL LUT 1 event B register"}, + {"evsys.userccllut2a", 0x0224, 1, -1, 0x00, "user CCL LUT 2 event A register"}, + {"evsys.userccllut2b", 0x0225, 1, -1, 0x00, "user CCL LUT 2 event B register"}, + {"evsys.userccllut3a", 0x0226, 1, -1, 0x00, "user CCL LUT 3 event A register"}, + {"evsys.userccllut3b", 0x0227, 1, -1, 0x00, "user CCL LUT 3 event B register"}, + {"evsys.useradc0start", 0x0228, 1, -1, 0x00, "user ADC 0 start register"}, + {"evsys.userevsysevouta", 0x0229, 1, -1, 0x00, "user EVOUT port A register"}, + {"evsys.userevsysevoutd", 0x022a, 1, -1, 0x00, "user EVOUT port D register"}, + {"evsys.userevsysevoutf", 0x022b, 1, -1, 0x00, "user EVOUT port F register"}, + {"evsys.userusart0irda", 0x022c, 1, -1, 0x00, "user USART 0 IrDA event register"}, + {"evsys.userusart1irda", 0x022d, 1, -1, 0x00, "user USART 1 IrDA event register"}, + {"evsys.usertca0cnta", 0x022e, 1, -1, 0x00, "user TCA 0 event A register"}, + {"evsys.usertca0cntb", 0x022f, 1, -1, 0x00, "user TCA 0 event B register"}, + {"evsys.usertcb0capt", 0x0230, 1, -1, 0x00, "user TCB 0 capture register"}, + {"evsys.usertcb0count", 0x0231, 1, -1, 0x00, "user TCB 0 event register"}, + {"evsys.usertcb1capt", 0x0232, 1, -1, 0x00, "user TCB 1 capture register"}, + {"evsys.usertcb1count", 0x0233, 1, -1, 0x00, "user TCB 1 event register"}, + {"porta.dir", 0x0400, 1, -1, 0x00, "data direction register"}, + {"porta.dirset", 0x0401, 1, -1, 0x00, "data direction set register"}, + {"porta.dirclr", 0x0402, 1, -1, 0x00, "data direction clear register"}, + {"porta.dirtgl", 0x0403, 1, -1, 0x00, "data direction toggle register"}, + {"porta.out", 0x0404, 1, -1, 0x00, "I/O port output register"}, + {"porta.outset", 0x0405, 1, -1, 0x00, "I/O port output set register"}, + {"porta.outclr", 0x0406, 1, -1, 0x00, "I/O port output clear register"}, + {"porta.outtgl", 0x0407, 1, -1, 0x00, "I/O port output toggle register"}, + {"porta.in", 0x0408, 1, -1, 0x00, "I/O port input register"}, + {"porta.intflags", 0x0409, 1, -1, 0x00, "interrupt flags register"}, + {"porta.portctrl", 0x040a, 1, -1, 0x00, "port control register"}, + {"porta.pinconfig", 0x040b, 1, -1, 0x00, "pin control config register"}, + {"porta.pinctrlupd", 0x040c, 1, -1, 0x00, "pin control update register"}, + {"porta.pinctrlset", 0x040d, 1, -1, 0x00, "pin control set register"}, + {"porta.pinctrlclr", 0x040e, 1, -1, 0x00, "pin control clear register"}, + {"porta.pin0ctrl", 0x0410, 1, -1, 0x00, "pin 0 control register"}, + {"porta.pin1ctrl", 0x0411, 1, -1, 0x00, "pin 1 control register"}, + {"porta.pin2ctrl", 0x0412, 1, -1, 0x00, "pin 2 control register"}, + {"porta.pin3ctrl", 0x0413, 1, -1, 0x00, "pin 3 control register"}, + {"porta.pin4ctrl", 0x0414, 1, -1, 0x00, "pin 4 control register"}, + {"porta.pin5ctrl", 0x0415, 1, -1, 0x00, "pin 5 control register"}, + {"porta.pin6ctrl", 0x0416, 1, -1, 0x00, "pin 6 control register"}, + {"porta.pin7ctrl", 0x0417, 1, -1, 0x00, "pin 7 control register"}, + {"porta.evgenctrla", 0x0418, 1, -1, 0x00, "event generation control A register"}, + {"portc.dir", 0x0440, 1, -1, 0x00, "data direction register"}, + {"portc.dirset", 0x0441, 1, -1, 0x00, "data direction set register"}, + {"portc.dirclr", 0x0442, 1, -1, 0x00, "data direction clear register"}, + {"portc.dirtgl", 0x0443, 1, -1, 0x00, "data direction toggle register"}, + {"portc.out", 0x0444, 1, -1, 0x00, "I/O port output register"}, + {"portc.outset", 0x0445, 1, -1, 0x00, "I/O port output set register"}, + {"portc.outclr", 0x0446, 1, -1, 0x00, "I/O port output clear register"}, + {"portc.outtgl", 0x0447, 1, -1, 0x00, "I/O port output toggle register"}, + {"portc.in", 0x0448, 1, -1, 0x00, "I/O port input register"}, + {"portc.intflags", 0x0449, 1, -1, 0x00, "interrupt flags register"}, + {"portc.portctrl", 0x044a, 1, -1, 0x00, "port control register"}, + {"portc.pinconfig", 0x044b, 1, -1, 0x00, "pin control config register"}, + {"portc.pinctrlupd", 0x044c, 1, -1, 0x00, "pin control update register"}, + {"portc.pinctrlset", 0x044d, 1, -1, 0x00, "pin control set register"}, + {"portc.pinctrlclr", 0x044e, 1, -1, 0x00, "pin control clear register"}, + {"portc.pin0ctrl", 0x0450, 1, -1, 0x00, "pin 0 control register"}, + {"portc.pin1ctrl", 0x0451, 1, -1, 0x00, "pin 1 control register"}, + {"portc.pin2ctrl", 0x0452, 1, -1, 0x00, "pin 2 control register"}, + {"portc.pin3ctrl", 0x0453, 1, -1, 0x00, "pin 3 control register"}, + {"portc.pin4ctrl", 0x0454, 1, -1, 0x00, "pin 4 control register"}, + {"portc.pin5ctrl", 0x0455, 1, -1, 0x00, "pin 5 control register"}, + {"portc.pin6ctrl", 0x0456, 1, -1, 0x00, "pin 6 control register"}, + {"portc.pin7ctrl", 0x0457, 1, -1, 0x00, "pin 7 control register"}, + {"portc.evgenctrla", 0x0458, 1, -1, 0x00, "event generation control A register"}, + {"portd.dir", 0x0460, 1, -1, 0x00, "data direction register"}, + {"portd.dirset", 0x0461, 1, -1, 0x00, "data direction set register"}, + {"portd.dirclr", 0x0462, 1, -1, 0x00, "data direction clear register"}, + {"portd.dirtgl", 0x0463, 1, -1, 0x00, "data direction toggle register"}, + {"portd.out", 0x0464, 1, -1, 0x00, "I/O port output register"}, + {"portd.outset", 0x0465, 1, -1, 0x00, "I/O port output set register"}, + {"portd.outclr", 0x0466, 1, -1, 0x00, "I/O port output clear register"}, + {"portd.outtgl", 0x0467, 1, -1, 0x00, "I/O port output toggle register"}, + {"portd.in", 0x0468, 1, -1, 0x00, "I/O port input register"}, + {"portd.intflags", 0x0469, 1, -1, 0x00, "interrupt flags register"}, + {"portd.portctrl", 0x046a, 1, -1, 0x00, "port control register"}, + {"portd.pinconfig", 0x046b, 1, -1, 0x00, "pin control config register"}, + {"portd.pinctrlupd", 0x046c, 1, -1, 0x00, "pin control update register"}, + {"portd.pinctrlset", 0x046d, 1, -1, 0x00, "pin control set register"}, + {"portd.pinctrlclr", 0x046e, 1, -1, 0x00, "pin control clear register"}, + {"portd.pin0ctrl", 0x0470, 1, -1, 0x00, "pin 0 control register"}, + {"portd.pin1ctrl", 0x0471, 1, -1, 0x00, "pin 1 control register"}, + {"portd.pin2ctrl", 0x0472, 1, -1, 0x00, "pin 2 control register"}, + {"portd.pin3ctrl", 0x0473, 1, -1, 0x00, "pin 3 control register"}, + {"portd.pin4ctrl", 0x0474, 1, -1, 0x00, "pin 4 control register"}, + {"portd.pin5ctrl", 0x0475, 1, -1, 0x00, "pin 5 control register"}, + {"portd.pin6ctrl", 0x0476, 1, -1, 0x00, "pin 6 control register"}, + {"portd.pin7ctrl", 0x0477, 1, -1, 0x00, "pin 7 control register"}, + {"portd.evgenctrla", 0x0478, 1, -1, 0x00, "event generation control A register"}, + {"portf.dir", 0x04a0, 1, -1, 0x00, "data direction register"}, + {"portf.dirset", 0x04a1, 1, -1, 0x00, "data direction set register"}, + {"portf.dirclr", 0x04a2, 1, -1, 0x00, "data direction clear register"}, + {"portf.dirtgl", 0x04a3, 1, -1, 0x00, "data direction toggle register"}, + {"portf.out", 0x04a4, 1, -1, 0x00, "I/O port output register"}, + {"portf.outset", 0x04a5, 1, -1, 0x00, "I/O port output set register"}, + {"portf.outclr", 0x04a6, 1, -1, 0x00, "I/O port output clear register"}, + {"portf.outtgl", 0x04a7, 1, -1, 0x00, "I/O port output toggle register"}, + {"portf.in", 0x04a8, 1, -1, 0x00, "I/O port input register"}, + {"portf.intflags", 0x04a9, 1, -1, 0x00, "interrupt flags register"}, + {"portf.portctrl", 0x04aa, 1, -1, 0x00, "port control register"}, + {"portf.pinconfig", 0x04ab, 1, -1, 0x00, "pin control config register"}, + {"portf.pinctrlupd", 0x04ac, 1, -1, 0x00, "pin control update register"}, + {"portf.pinctrlset", 0x04ad, 1, -1, 0x00, "pin control set register"}, + {"portf.pinctrlclr", 0x04ae, 1, -1, 0x00, "pin control clear register"}, + {"portf.pin0ctrl", 0x04b0, 1, -1, 0x00, "pin 0 control register"}, + {"portf.pin1ctrl", 0x04b1, 1, -1, 0x00, "pin 1 control register"}, + {"portf.pin2ctrl", 0x04b2, 1, -1, 0x00, "pin 2 control register"}, + {"portf.pin3ctrl", 0x04b3, 1, -1, 0x00, "pin 3 control register"}, + {"portf.pin4ctrl", 0x04b4, 1, -1, 0x00, "pin 4 control register"}, + {"portf.pin5ctrl", 0x04b5, 1, -1, 0x00, "pin 5 control register"}, + {"portf.pin6ctrl", 0x04b6, 1, -1, 0x00, "pin 6 control register"}, + {"portf.pin7ctrl", 0x04b7, 1, -1, 0x00, "pin 7 control register"}, + {"portf.evgenctrla", 0x04b8, 1, -1, 0x00, "event generation control A register"}, + {"portmux.evsysroutea", 0x05e0, 1, -1, 0x00, "port multiplexer EVSYS register"}, + {"portmux.cclroutea", 0x05e1, 1, -1, 0x00, "CCL route A register"}, + {"portmux.usartroutea", 0x05e2, 1, -1, 0x00, "USART route A register"}, + {"portmux.spiroutea", 0x05e5, 1, -1, 0x00, "SPI route A register"}, + {"portmux.twiroutea", 0x05e6, 1, -1, 0x00, "TWI route A register"}, + {"portmux.tcaroutea", 0x05e7, 1, -1, 0x00, "TCA route A register"}, + {"adc0.ctrla", 0x0600, 1, -1, 0x00, "control register A"}, + {"adc0.ctrlb", 0x0601, 1, -1, 0x00, "control register B"}, + {"adc0.ctrlc", 0x0602, 1, -1, 0x00, "control register C"}, + {"adc0.ctrld", 0x0603, 1, -1, 0x00, "control register D"}, + {"adc0.ctrle", 0x0604, 1, -1, 0x00, "control register E"}, + {"adc0.ctrlf", 0x0605, 1, -1, 0x00, "control register F"}, + {"adc0.intctrl", 0x0606, 1, -1, 0x00, "interrupt control register"}, + {"adc0.intflags", 0x0607, 1, -1, 0x00, "interrupt flags register"}, + {"adc0.status", 0x0608, 1, -1, 0x00, "status register"}, + {"adc0.dbgctrl", 0x0609, 1, -1, 0x00, "debug control register"}, + {"adc0.command", 0x060a, 1, -1, 0x00, "command register"}, + {"adc0.muxpos", 0x060b, 1, -1, 0x00, "positive mux input register"}, + {"adc0.result", 0x060c, 2, -1, -1, "result register (32 bits)"}, + {"adc0.sample", 0x060e, 2, -1, 0x0000, "sample register (16 bits)"}, + {"adc0.winlt", 0x0610, 2, -1, -1, "window comparator low threshold register (16 bits)"}, + {"adc0.winht", 0x0612, 2, -1, -1, "window comparator high threshold register (16 bits)"}, + {"adc0.temp", 0x0614, 1, -1, 0x00, "temporary data register"}, + {"ac0.ctrla", 0x0680, 1, -1, 0x00, "control register A"}, + {"ac0.muxctrl", 0x0682, 1, -1, 0x00, "mux control A register"}, + {"ac0.dacref", 0x0685, 1, -1, 0xff, "DAC voltage reference register"}, + {"ac0.intctrl", 0x0686, 1, -1, 0x00, "interrupt control register"}, + {"ac0.status", 0x0687, 1, -1, 0x00, "status register"}, + {"usart0.rxdatal", 0x0800, 1, -1, 0x00, "receive data low byte"}, + {"usart0.rxdatah", 0x0801, 1, -1, 0x00, "receive data high byte"}, + {"usart0.txdatal", 0x0802, 1, -1, 0x00, "transmit data low byte"}, + {"usart0.txdatah", 0x0803, 1, -1, 0x00, "transmit data high byte"}, + {"usart0.status", 0x0804, 1, -1, 0x20, "status register"}, + {"usart0.ctrla", 0x0805, 1, -1, 0x00, "control register A"}, + {"usart0.ctrlb", 0x0806, 1, -1, 0x00, "control register B"}, + {"usart0.ctrlc", 0x0807, 1, -1, 0x03, "control register C"}, + {"usart0.baud", 0x0808, 2, -1, 0x0000, "baud rate register (16 bits)"}, + {"usart0.ctrld", 0x080a, 1, -1, 0x00, "control register D"}, + {"usart0.dbgctrl", 0x080b, 1, -1, 0x00, "debug control register"}, + {"usart0.evctrl", 0x080c, 1, -1, 0x00, "event control register"}, + {"usart0.txplctrl", 0x080d, 1, -1, 0x00, "IRCOM transmitter pulse length control register"}, + {"usart0.rxplctrl", 0x080e, 1, -1, 0x00, "IRCOM receiver pulse length control register"}, + {"usart1.rxdatal", 0x0820, 1, -1, 0x00, "receive data low byte"}, + {"usart1.rxdatah", 0x0821, 1, -1, 0x00, "receive data high byte"}, + {"usart1.txdatal", 0x0822, 1, -1, 0x00, "transmit data low byte"}, + {"usart1.txdatah", 0x0823, 1, -1, 0x00, "transmit data high byte"}, + {"usart1.status", 0x0824, 1, -1, 0x20, "status register"}, + {"usart1.ctrla", 0x0825, 1, -1, 0x00, "control register A"}, + {"usart1.ctrlb", 0x0826, 1, -1, 0x00, "control register B"}, + {"usart1.ctrlc", 0x0827, 1, -1, 0x03, "control register C"}, + {"usart1.baud", 0x0828, 2, -1, 0x0000, "baud rate register (16 bits)"}, + {"usart1.ctrld", 0x082a, 1, -1, 0x00, "control register D"}, + {"usart1.dbgctrl", 0x082b, 1, -1, 0x00, "debug control register"}, + {"usart1.evctrl", 0x082c, 1, -1, 0x00, "event control register"}, + {"usart1.txplctrl", 0x082d, 1, -1, 0x00, "IRCOM transmitter pulse length control register"}, + {"usart1.rxplctrl", 0x082e, 1, -1, 0x00, "IRCOM receiver pulse length control register"}, + {"twi0.ctrla", 0x0900, 1, -1, 0x00, "control register A"}, + {"twi0.dbgctrl", 0x0902, 1, -1, 0x00, "debug control register"}, + {"twi0.mctrla", 0x0903, 1, -1, 0x00, "host control A register"}, + {"twi0.mctrlb", 0x0904, 1, -1, 0x00, "host control B register"}, + {"twi0.hstatus", 0x0905, 1, -1, 0x00, "host status register"}, + {"twi0.mbaud", 0x0906, 1, -1, 0x00, "host baud rate register"}, + {"twi0.haddr", 0x0907, 1, -1, 0x00, "host address register"}, + {"twi0.hdata", 0x0908, 1, -1, 0x00, "host data register"}, + {"twi0.sctrla", 0x0909, 1, -1, 0x00, "client control A register"}, + {"twi0.sctrlb", 0x090a, 1, -1, 0x00, "client control B register"}, + {"twi0.sstatus", 0x090b, 1, -1, 0x00, "client status register"}, + {"twi0.saddr", 0x090c, 1, -1, 0x00, "client address register"}, + {"twi0.sdata", 0x090d, 1, -1, 0x00, "client data register"}, + {"twi0.saddrmask", 0x090e, 1, -1, 0x00, "client address mask register"}, + {"spi0.ctrla", 0x0940, 1, -1, 0x00, "control register A"}, + {"spi0.ctrlb", 0x0941, 1, -1, 0x00, "control register B"}, + {"spi0.intctrl", 0x0942, 1, -1, 0x00, "interrupt control register"}, + {"spi0.intflags", 0x0943, 1, -1, 0x00, "interrupt flags register"}, + {"spi0.data", 0x0944, 1, -1, -1, "data register"}, + {"tca0.ctrla", 0x0a00, 1, -1, 0x00, "control register A"}, + {"tca0.ctrlb", 0x0a01, 1, -1, 0x00, "control register B"}, + {"tca0.ctrlc", 0x0a02, 1, -1, 0x00, "control register C"}, + {"tca0.ctrld", 0x0a03, 1, -1, 0x00, "control register D"}, + {"tca0.ctrleclr", 0x0a04, 1, -1, 0x00, "control register E clear"}, + {"tca0.ctrleset", 0x0a05, 1, -1, 0x00, "control register E set"}, + {"tca0.ctrlfclr", 0x0a06, 1, -1, 0x00, "control register F clear"}, + {"tca0.ctrlfset", 0x0a07, 1, -1, 0x00, "control register F set"}, + {"tca0.evctrl", 0x0a09, 1, -1, 0x00, "event control register"}, + {"tca0.intctrl", 0x0a0a, 1, -1, 0x00, "interrupt control register"}, + {"tca0.intflags", 0x0a0b, 1, -1, 0x00, "interrupt flags register"}, + {"tca0.dbgctrl", 0x0a0e, 1, -1, 0x00, "debug control register"}, + {"tca0.temp", 0x0a0f, 1, -1, -1, "temporary register for 16-bit access"}, + {"tca0.cnt", 0x0a20, 2, -1, -1, "counter (16 bits)"}, + {"tca0.lcnt", 0x0a20, 1, -1, -1, "low byte counter"}, + {"tca0.hcnt", 0x0a21, 1, -1, -1, "high byte counter"}, + {"tca0.per", 0x0a26, 2, -1, -1, "period register (16 bits)"}, + {"tca0.lper", 0x0a26, 1, -1, -1, "low byte period register"}, + {"tca0.hper", 0x0a27, 1, -1, -1, "high byte period register"}, + {"tca0.cmp0", 0x0a28, 2, -1, -1, "compare 0 register (16 bits)"}, + {"tca0.lcmp0", 0x0a28, 1, -1, -1, "low byte compare register"}, + {"tca0.hcmp0", 0x0a29, 1, -1, -1, "high byte compare register 0"}, + {"tca0.cmp1", 0x0a2a, 2, -1, -1, "compare 1 register (16 bits)"}, + {"tca0.lcmp1", 0x0a2a, 1, -1, -1, "low byte compare register"}, + {"tca0.hcmp1", 0x0a2b, 1, -1, -1, "high byte compare register 1"}, + {"tca0.cmp2", 0x0a2c, 2, -1, -1, "compare 2 register (16 bits)"}, + {"tca0.lcmp2", 0x0a2c, 1, -1, -1, "low byte compare register"}, + {"tca0.hcmp2", 0x0a2d, 1, -1, -1, "high byte compare register 2"}, + {"tca0.perbuf", 0x0a36, 2, -1, -1, "period buffer register (16 bits)"}, + {"tca0.cmp0buf", 0x0a38, 2, -1, -1, "compare 0 buffer register (16 bits)"}, + {"tca0.cmp1buf", 0x0a3a, 2, -1, -1, "compare 1 buffer register (16 bits)"}, + {"tca0.cmp2buf", 0x0a3c, 2, -1, -1, "compare 2 buffer register (16 bits)"}, + {"tcb0.ctrla", 0x0b00, 1, -1, 0x00, "control register A"}, + {"tcb0.ctrlb", 0x0b01, 1, -1, 0x00, "control register B"}, + {"tcb0.evctrl", 0x0b04, 1, -1, 0x00, "event control register"}, + {"tcb0.intctrl", 0x0b05, 1, -1, 0x00, "interrupt control register"}, + {"tcb0.intflags", 0x0b06, 1, -1, 0x00, "interrupt flags register"}, + {"tcb0.status", 0x0b07, 1, -1, 0x00, "status register"}, + {"tcb0.dbgctrl", 0x0b08, 1, -1, 0x00, "debug control register"}, + {"tcb0.temp", 0x0b09, 1, -1, -1, "temporary register for 16-bit access"}, + {"tcb0.cnt", 0x0b0a, 2, -1, 0x0000, "counter (16 bits)"}, + {"tcb0.ccmp", 0x0b0c, 2, -1, -1, "compare or capture register (16 bits)"}, + {"tcb1.ctrla", 0x0b10, 1, -1, 0x00, "control register A"}, + {"tcb1.ctrlb", 0x0b11, 1, -1, 0x00, "control register B"}, + {"tcb1.evctrl", 0x0b14, 1, -1, 0x00, "event control register"}, + {"tcb1.intctrl", 0x0b15, 1, -1, 0x00, "interrupt control register"}, + {"tcb1.intflags", 0x0b16, 1, -1, 0x00, "interrupt flags register"}, + {"tcb1.status", 0x0b17, 1, -1, 0x00, "status register"}, + {"tcb1.dbgctrl", 0x0b18, 1, -1, 0x00, "debug control register"}, + {"tcb1.temp", 0x0b19, 1, -1, -1, "temporary register for 16-bit access"}, + {"tcb1.cnt", 0x0b1a, 2, -1, 0x0000, "counter (16 bits)"}, + {"tcb1.ccmp", 0x0b1c, 2, -1, -1, "compare or capture register (16 bits)"}, + {"usb0.ctrla", 0x0c00, 1, -1, 0x00, "control register A"}, + {"usb0.ctrlb", 0x0c01, 1, -1, 0x00, "control register B"}, + {"usb0.busstate", 0x0c02, 1, -1, 0x00, "bus state register"}, + {"usb0.addr", 0x0c03, 1, -1, 0x00, "address register"}, + {"usb0.fifowp", 0x0c04, 1, -1, 0xff, "FIFO write pointer register"}, + {"usb0.fiforp", 0x0c05, 1, -1, 0xff, "FIFO read pointer register"}, + {"usb0.epptr", 0x0c06, 2, -1, 0x0000, "endpoint configuration table pointer register (16 bits)"}, + {"usb0.intctrla", 0x0c08, 1, -1, 0x00, "interrupt control register A"}, + {"usb0.intctrlb", 0x0c09, 1, -1, 0x00, "interrupt control register B"}, + {"usb0.intflagsa", 0x0c0a, 1, -1, 0x00, "interrupt flags A register"}, + {"usb0.intflagsb", 0x0c0b, 1, -1, 0x00, "interrupt flags B register"}, + {"usb.status.outclr", 0x0c40, 1, -1, 0x00, "endpoint n OUT status clear register"}, + {"usb.status.outset", 0x0c41, 1, -1, 0x00, "endpoint n OUT status set register"}, + {"usb.status.inclr", 0x0c42, 1, -1, 0x00, "endpoint n IN status clear register"}, + {"usb.status.inset", 0x0c43, 1, -1, 0x00, "endpoint n IN status set register"}, + {"syscfg.revid", 0x0f01, 1, -1, -1, "revision ID register"}, + {"syscfg.vusbctrl", 0x0f06, 1, -1, 0x00, "USB voltage system control register"}, + {"nvmctrl.ctrla", 0x1000, 1, -1, 0x00, "control register A"}, + {"nvmctrl.ctrlb", 0x1001, 1, -1, 0x30, "control register B"}, + {"nvmctrl.ctrlc", 0x1002, 1, -1, 0x00, "control register C"}, + {"nvmctrl.intctrl", 0x1004, 1, -1, 0x00, "interrupt control register"}, + {"nvmctrl.intflags", 0x1005, 1, -1, 0x00, "interrupt flags register"}, + {"nvmctrl.status", 0x1006, 1, -1, 0x00, "status register"}, + {"nvmctrl.data", 0x1008, 4, -1, 0x00000000, "data register (32 bits)"}, + {"nvmctrl.addr", 0x100c, 4, -1, -1, "address register (32 bits)"}, +}; + // AVR16EB14 const Register_file_t rgftab_avr16eb14[391] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, @@ -44373,6 +44823,382 @@ const Register_file_t rgftab_avr16eb14[391] = { // I/O memory [0, 4159] {"nvmctrl.addr", 0x100c, 4, -1, 0x00000000, "address register (32 bits)"}, }; +// AVR16DU20 AVR16DU28 AVR16DU32 AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 AVR64DU32 +const Register_file_t rgftab_avr16du20[372] = { // I/O memory [0, 4159] + {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, + {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, + {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, + {"vporta.intflags", 0x0003, 1, -1, 0x00, "interrupt flags register"}, + {"vportc.dir", 0x0008, 1, -1, 0x00, "data direction register"}, + {"vportc.out", 0x0009, 1, -1, 0x00, "I/O port output register"}, + {"vportc.in", 0x000a, 1, -1, 0x00, "I/O port input register"}, + {"vportc.intflags", 0x000b, 1, -1, 0x00, "interrupt flags register"}, + {"vportd.dir", 0x000c, 1, -1, 0x00, "data direction register"}, + {"vportd.out", 0x000d, 1, -1, 0x00, "I/O port output register"}, + {"vportd.in", 0x000e, 1, -1, 0x00, "I/O port input register"}, + {"vportd.intflags", 0x000f, 1, -1, 0x00, "interrupt flags register"}, + {"vportf.dir", 0x0014, 1, -1, 0x00, "data direction register"}, + {"vportf.out", 0x0015, 1, -1, 0x00, "I/O port output register"}, + {"vportf.in", 0x0016, 1, -1, 0x00, "I/O port input register"}, + {"vportf.intflags", 0x0017, 1, -1, 0x00, "interrupt flags register"}, + {"gpr.gpr0", 0x001c, 1, -1, -1, "general purpose register 0"}, + {"gpr.gpr1", 0x001d, 1, -1, -1, "general purpose register 1"}, + {"gpr.gpr2", 0x001e, 1, -1, -1, "general purpose register 2"}, + {"gpr.gpr3", 0x001f, 1, -1, -1, "general purpose register 3"}, + {"cpu.ccp", 0x0034, 1, -1, 0x00, "configuration change protection register"}, + {"cpu.rampz", 0x003b, 1, -1, 0x00, "extended Z register"}, + {"cpu.sp", 0x003d, 2, -1, 0x7fff, "stack pointer (16 bits)"}, + {"cpu.sreg", 0x003f, 1, -1, 0x00, "status register"}, + {"rstctrl.rstfr", 0x0040, 1, -1, 0x00, "reset flags register"}, + {"rstctrl.swrr", 0x0041, 1, -1, 0x00, "software reset register"}, + {"slpctrl.ctrla", 0x0050, 1, -1, 0x00, "control register A"}, + {"slpctrl.vregctrl", 0x0051, 1, -1, 0x00, "control B register"}, + {"clkctrl.mclkctrla", 0x0060, 1, -1, 0x00, "MCLK control A register"}, + {"clkctrl.mclkctrlb", 0x0061, 1, -1, 0x00, "MCLK control B register"}, + {"clkctrl.mclkctrlc", 0x0062, 1, -1, 0x00, "MCLK control C register"}, + {"clkctrl.mclkintctrl", 0x0063, 1, -1, 0x00, "MCLK interrupt control register"}, + {"clkctrl.mclkintflags", 0x0064, 1, -1, 0x00, "MCLK interrupt flags register"}, + {"clkctrl.mclkstatus", 0x0065, 1, -1, 0x00, "MCLK status register"}, + {"clkctrl.mclktimebase", 0x0066, 1, -1, 0x00, "MCLK timebase register"}, + {"clkctrl.oschfctrla", 0x0068, 1, -1, 0x0c, "OSCHF control A register"}, + {"clkctrl.oschftune", 0x0069, 1, -1, -1, "OSCHF tune register"}, + {"clkctrl.oschfstatus", 0x006a, 1, -1, -1, "OSCHF status register"}, + {"clkctrl.osc32kctrla", 0x0078, 1, -1, 0x00, "OSC32K control A register"}, + {"clkctrl.xosc32kctrla", 0x007c, 1, -1, 0x00, "XOSC32K control A register"}, + {"clkctrl.xoschfctrla", 0x0080, 1, -1, 0x00, "XOSC HF control A register"}, + {"clkctrl.usbpllstatus", 0x0085, 1, -1, 0x00, "PLL status register"}, + {"bod.ctrla", 0x00a0, 1, -1, 0x01, "control register A"}, + {"bod.ctrlb", 0x00a1, 1, -1, 0x00, "control register B"}, + {"bod.vlmctrla", 0x00a8, 1, -1, 0x00, "voltage level monitor control register"}, + {"bod.intctrl", 0x00a9, 1, -1, 0x00, "interrupt control register"}, + {"bod.intflags", 0x00aa, 1, -1, 0x00, "interrupt flags register"}, + {"bod.status", 0x00ab, 1, -1, 0x00, "status register"}, + {"vref.acref", 0x00b0, 1, -1, 0x00, "AC reference register"}, + {"wdt.ctrla", 0x0100, 1, -1, 0x00, "control register A"}, + {"wdt.status", 0x0101, 1, -1, 0x00, "status register"}, + {"cpuint.ctrla", 0x0110, 1, -1, 0x00, "control register A"}, + {"cpuint.status", 0x0111, 1, -1, 0x00, "status register"}, + {"cpuint.lvl0pri", 0x0112, 1, -1, 0x00, "interrupt level 0 priority register"}, + {"cpuint.lvl1vec", 0x0113, 1, -1, 0x00, "interrupt level 1 priority vector register"}, + {"crcscan.ctrla", 0x0120, 1, -1, 0x00, "control register A"}, + {"crcscan.ctrlb", 0x0121, 1, -1, 0x00, "control register B"}, + {"crcscan.status", 0x0122, 1, -1, 0x02, "status register"}, + {"rtc.ctrla", 0x0140, 1, -1, 0x00, "control register A"}, + {"rtc.status", 0x0141, 1, -1, 0x00, "status register"}, + {"rtc.intctrl", 0x0142, 1, -1, 0x00, "interrupt control register"}, + {"rtc.intflags", 0x0143, 1, -1, 0x00, "interrupt flags register"}, + {"rtc.temp", 0x0144, 1, -1, -1, "temporary register"}, + {"rtc.dbgctrl", 0x0145, 1, -1, 0x00, "debug control register"}, + {"rtc.calib", 0x0146, 1, -1, 0x00, "calibration register"}, + {"rtc.clksel", 0x0147, 1, -1, 0x00, "clock select register"}, + {"rtc.cnt", 0x0148, 2, -1, -1, "counter (16 bits)"}, + {"rtc.per", 0x014a, 2, -1, 0xffff, "period register (16 bits)"}, + {"rtc.cmp", 0x014c, 2, -1, -1, "compare register (16 bits)"}, + {"rtc.pitctrla", 0x0150, 1, -1, 0x00, "PIT control A register"}, + {"rtc.pitstatus", 0x0151, 1, -1, 0x00, "PIT status register"}, + {"rtc.pitintctrl", 0x0152, 1, -1, 0x00, "PIT interrupt control register"}, + {"rtc.pitintflags", 0x0153, 1, -1, 0x00, "PIT interrupt flags register"}, + {"rtc.pitdbgctrl", 0x0155, 1, -1, 0x00, "PIT debug control register"}, + {"rtc.pitevgenctrla", 0x0156, 1, -1, 0x00, "PIT event generation control A register"}, + {"ccl.ctrla", 0x01c0, 1, -1, 0x00, "control register A"}, + {"ccl.seqctrl0", 0x01c1, 1, -1, 0x00, "sequential control register 0"}, + {"ccl.seqctrl1", 0x01c2, 1, -1, 0x00, "sequential control register 1"}, + {"ccl.intctrl0", 0x01c5, 1, -1, 0x00, "interrupt control register 0"}, + {"ccl.intflags", 0x01c7, 1, -1, 0x00, "interrupt flags register"}, + {"ccl.lut0ctrla", 0x01c8, 1, -1, 0x00, "LUT 0 control A register"}, + {"ccl.lut0ctrlb", 0x01c9, 1, -1, 0x00, "LUT 0 control B register"}, + {"ccl.lut0ctrlc", 0x01ca, 1, -1, 0x00, "LUT 0 control C register"}, + {"ccl.truth0", 0x01cb, 1, -1, 0x00, "truth register 0"}, + {"ccl.lut1ctrla", 0x01cc, 1, -1, 0x00, "LUT 1 control A register"}, + {"ccl.lut1ctrlb", 0x01cd, 1, -1, 0x00, "LUT 1 control B register"}, + {"ccl.lut1ctrlc", 0x01ce, 1, -1, 0x00, "LUT 1 control C register"}, + {"ccl.truth1", 0x01cf, 1, -1, 0x00, "truth register 1"}, + {"ccl.lut2ctrla", 0x01d0, 1, -1, 0x00, "LUT 2 control A register"}, + {"ccl.lut2ctrlb", 0x01d1, 1, -1, 0x00, "LUT 2 control B register"}, + {"ccl.lut2ctrlc", 0x01d2, 1, -1, 0x00, "LUT 2 control C register"}, + {"ccl.truth2", 0x01d3, 1, -1, 0x00, "truth register 2"}, + {"ccl.lut3ctrla", 0x01d4, 1, -1, 0x00, "LUT 3 control A register"}, + {"ccl.lut3ctrlb", 0x01d5, 1, -1, 0x00, "LUT 3 control B register"}, + {"ccl.lut3ctrlc", 0x01d6, 1, -1, 0x00, "LUT 3 control C register"}, + {"ccl.truth3", 0x01d7, 1, -1, 0x00, "truth register 3"}, + {"evsys.sweventa", 0x0200, 1, -1, 0x00, "software event A register"}, + {"evsys.channel0", 0x0210, 1, -1, 0x00, "multiplexer channel 0 register"}, + {"evsys.channel1", 0x0211, 1, -1, 0x00, "multiplexer channel 1 register"}, + {"evsys.channel2", 0x0212, 1, -1, 0x00, "multiplexer channel 2 register"}, + {"evsys.channel3", 0x0213, 1, -1, 0x00, "multiplexer channel 3 register"}, + {"evsys.channel4", 0x0214, 1, -1, 0x00, "multiplexer channel 4 register"}, + {"evsys.channel5", 0x0215, 1, -1, 0x00, "multiplexer channel 5 register"}, + {"evsys.userccllut0a", 0x0220, 1, -1, 0x00, "user CCL LUT 0 event A register"}, + {"evsys.userccllut0b", 0x0221, 1, -1, 0x00, "user CCL LUT 0 event B register"}, + {"evsys.userccllut1a", 0x0222, 1, -1, 0x00, "user CCL LUT 1 event A register"}, + {"evsys.userccllut1b", 0x0223, 1, -1, 0x00, "user CCL LUT 1 event B register"}, + {"evsys.userccllut2a", 0x0224, 1, -1, 0x00, "user CCL LUT 2 event A register"}, + {"evsys.userccllut2b", 0x0225, 1, -1, 0x00, "user CCL LUT 2 event B register"}, + {"evsys.userccllut3a", 0x0226, 1, -1, 0x00, "user CCL LUT 3 event A register"}, + {"evsys.userccllut3b", 0x0227, 1, -1, 0x00, "user CCL LUT 3 event B register"}, + {"evsys.useradc0start", 0x0228, 1, -1, 0x00, "user ADC 0 start register"}, + {"evsys.userevsysevouta", 0x0229, 1, -1, 0x00, "user EVOUT port A register"}, + {"evsys.userevsysevoutd", 0x022a, 1, -1, 0x00, "user EVOUT port D register"}, + {"evsys.userevsysevoutf", 0x022b, 1, -1, 0x00, "user EVOUT port F register"}, + {"evsys.userusart0irda", 0x022c, 1, -1, 0x00, "user USART 0 IrDA event register"}, + {"evsys.userusart1irda", 0x022d, 1, -1, 0x00, "user USART 1 IrDA event register"}, + {"evsys.usertca0cnta", 0x022e, 1, -1, 0x00, "user TCA 0 event A register"}, + {"evsys.usertca0cntb", 0x022f, 1, -1, 0x00, "user TCA 0 event B register"}, + {"evsys.usertcb0capt", 0x0230, 1, -1, 0x00, "user TCB 0 capture register"}, + {"evsys.usertcb0count", 0x0231, 1, -1, 0x00, "user TCB 0 event register"}, + {"evsys.usertcb1capt", 0x0232, 1, -1, 0x00, "user TCB 1 capture register"}, + {"evsys.usertcb1count", 0x0233, 1, -1, 0x00, "user TCB 1 event register"}, + {"porta.dir", 0x0400, 1, -1, 0x00, "data direction register"}, + {"porta.dirset", 0x0401, 1, -1, 0x00, "data direction set register"}, + {"porta.dirclr", 0x0402, 1, -1, 0x00, "data direction clear register"}, + {"porta.dirtgl", 0x0403, 1, -1, 0x00, "data direction toggle register"}, + {"porta.out", 0x0404, 1, -1, 0x00, "I/O port output register"}, + {"porta.outset", 0x0405, 1, -1, 0x00, "I/O port output set register"}, + {"porta.outclr", 0x0406, 1, -1, 0x00, "I/O port output clear register"}, + {"porta.outtgl", 0x0407, 1, -1, 0x00, "I/O port output toggle register"}, + {"porta.in", 0x0408, 1, -1, 0x00, "I/O port input register"}, + {"porta.intflags", 0x0409, 1, -1, 0x00, "interrupt flags register"}, + {"porta.portctrl", 0x040a, 1, -1, 0x00, "port control register"}, + {"porta.pinconfig", 0x040b, 1, -1, 0x00, "pin control config register"}, + {"porta.pinctrlupd", 0x040c, 1, -1, 0x00, "pin control update register"}, + {"porta.pinctrlset", 0x040d, 1, -1, 0x00, "pin control set register"}, + {"porta.pinctrlclr", 0x040e, 1, -1, 0x00, "pin control clear register"}, + {"porta.pin0ctrl", 0x0410, 1, -1, 0x00, "pin 0 control register"}, + {"porta.pin1ctrl", 0x0411, 1, -1, 0x00, "pin 1 control register"}, + {"porta.pin2ctrl", 0x0412, 1, -1, 0x00, "pin 2 control register"}, + {"porta.pin3ctrl", 0x0413, 1, -1, 0x00, "pin 3 control register"}, + {"porta.pin4ctrl", 0x0414, 1, -1, 0x00, "pin 4 control register"}, + {"porta.pin5ctrl", 0x0415, 1, -1, 0x00, "pin 5 control register"}, + {"porta.pin6ctrl", 0x0416, 1, -1, 0x00, "pin 6 control register"}, + {"porta.pin7ctrl", 0x0417, 1, -1, 0x00, "pin 7 control register"}, + {"porta.evgenctrla", 0x0418, 1, -1, 0x00, "event generation control A register"}, + {"portc.dir", 0x0440, 1, -1, 0x00, "data direction register"}, + {"portc.dirset", 0x0441, 1, -1, 0x00, "data direction set register"}, + {"portc.dirclr", 0x0442, 1, -1, 0x00, "data direction clear register"}, + {"portc.dirtgl", 0x0443, 1, -1, 0x00, "data direction toggle register"}, + {"portc.out", 0x0444, 1, -1, 0x00, "I/O port output register"}, + {"portc.outset", 0x0445, 1, -1, 0x00, "I/O port output set register"}, + {"portc.outclr", 0x0446, 1, -1, 0x00, "I/O port output clear register"}, + {"portc.outtgl", 0x0447, 1, -1, 0x00, "I/O port output toggle register"}, + {"portc.in", 0x0448, 1, -1, 0x00, "I/O port input register"}, + {"portc.intflags", 0x0449, 1, -1, 0x00, "interrupt flags register"}, + {"portc.portctrl", 0x044a, 1, -1, 0x00, "port control register"}, + {"portc.pinconfig", 0x044b, 1, -1, 0x00, "pin control config register"}, + {"portc.pinctrlupd", 0x044c, 1, -1, 0x00, "pin control update register"}, + {"portc.pinctrlset", 0x044d, 1, -1, 0x00, "pin control set register"}, + {"portc.pinctrlclr", 0x044e, 1, -1, 0x00, "pin control clear register"}, + {"portc.pin0ctrl", 0x0450, 1, -1, 0x00, "pin 0 control register"}, + {"portc.pin1ctrl", 0x0451, 1, -1, 0x00, "pin 1 control register"}, + {"portc.pin2ctrl", 0x0452, 1, -1, 0x00, "pin 2 control register"}, + {"portc.pin3ctrl", 0x0453, 1, -1, 0x00, "pin 3 control register"}, + {"portc.pin4ctrl", 0x0454, 1, -1, 0x00, "pin 4 control register"}, + {"portc.pin5ctrl", 0x0455, 1, -1, 0x00, "pin 5 control register"}, + {"portc.pin6ctrl", 0x0456, 1, -1, 0x00, "pin 6 control register"}, + {"portc.pin7ctrl", 0x0457, 1, -1, 0x00, "pin 7 control register"}, + {"portc.evgenctrla", 0x0458, 1, -1, 0x00, "event generation control A register"}, + {"portd.dir", 0x0460, 1, -1, 0x00, "data direction register"}, + {"portd.dirset", 0x0461, 1, -1, 0x00, "data direction set register"}, + {"portd.dirclr", 0x0462, 1, -1, 0x00, "data direction clear register"}, + {"portd.dirtgl", 0x0463, 1, -1, 0x00, "data direction toggle register"}, + {"portd.out", 0x0464, 1, -1, 0x00, "I/O port output register"}, + {"portd.outset", 0x0465, 1, -1, 0x00, "I/O port output set register"}, + {"portd.outclr", 0x0466, 1, -1, 0x00, "I/O port output clear register"}, + {"portd.outtgl", 0x0467, 1, -1, 0x00, "I/O port output toggle register"}, + {"portd.in", 0x0468, 1, -1, 0x00, "I/O port input register"}, + {"portd.intflags", 0x0469, 1, -1, 0x00, "interrupt flags register"}, + {"portd.portctrl", 0x046a, 1, -1, 0x00, "port control register"}, + {"portd.pinconfig", 0x046b, 1, -1, 0x00, "pin control config register"}, + {"portd.pinctrlupd", 0x046c, 1, -1, 0x00, "pin control update register"}, + {"portd.pinctrlset", 0x046d, 1, -1, 0x00, "pin control set register"}, + {"portd.pinctrlclr", 0x046e, 1, -1, 0x00, "pin control clear register"}, + {"portd.pin0ctrl", 0x0470, 1, -1, 0x00, "pin 0 control register"}, + {"portd.pin1ctrl", 0x0471, 1, -1, 0x00, "pin 1 control register"}, + {"portd.pin2ctrl", 0x0472, 1, -1, 0x00, "pin 2 control register"}, + {"portd.pin3ctrl", 0x0473, 1, -1, 0x00, "pin 3 control register"}, + {"portd.pin4ctrl", 0x0474, 1, -1, 0x00, "pin 4 control register"}, + {"portd.pin5ctrl", 0x0475, 1, -1, 0x00, "pin 5 control register"}, + {"portd.pin6ctrl", 0x0476, 1, -1, 0x00, "pin 6 control register"}, + {"portd.pin7ctrl", 0x0477, 1, -1, 0x00, "pin 7 control register"}, + {"portd.evgenctrla", 0x0478, 1, -1, 0x00, "event generation control A register"}, + {"portf.dir", 0x04a0, 1, -1, 0x00, "data direction register"}, + {"portf.dirset", 0x04a1, 1, -1, 0x00, "data direction set register"}, + {"portf.dirclr", 0x04a2, 1, -1, 0x00, "data direction clear register"}, + {"portf.dirtgl", 0x04a3, 1, -1, 0x00, "data direction toggle register"}, + {"portf.out", 0x04a4, 1, -1, 0x00, "I/O port output register"}, + {"portf.outset", 0x04a5, 1, -1, 0x00, "I/O port output set register"}, + {"portf.outclr", 0x04a6, 1, -1, 0x00, "I/O port output clear register"}, + {"portf.outtgl", 0x04a7, 1, -1, 0x00, "I/O port output toggle register"}, + {"portf.in", 0x04a8, 1, -1, 0x00, "I/O port input register"}, + {"portf.intflags", 0x04a9, 1, -1, 0x00, "interrupt flags register"}, + {"portf.portctrl", 0x04aa, 1, -1, 0x00, "port control register"}, + {"portf.pinconfig", 0x04ab, 1, -1, 0x00, "pin control config register"}, + {"portf.pinctrlupd", 0x04ac, 1, -1, 0x00, "pin control update register"}, + {"portf.pinctrlset", 0x04ad, 1, -1, 0x00, "pin control set register"}, + {"portf.pinctrlclr", 0x04ae, 1, -1, 0x00, "pin control clear register"}, + {"portf.pin0ctrl", 0x04b0, 1, -1, 0x00, "pin 0 control register"}, + {"portf.pin1ctrl", 0x04b1, 1, -1, 0x00, "pin 1 control register"}, + {"portf.pin2ctrl", 0x04b2, 1, -1, 0x00, "pin 2 control register"}, + {"portf.pin3ctrl", 0x04b3, 1, -1, 0x00, "pin 3 control register"}, + {"portf.pin4ctrl", 0x04b4, 1, -1, 0x00, "pin 4 control register"}, + {"portf.pin5ctrl", 0x04b5, 1, -1, 0x00, "pin 5 control register"}, + {"portf.pin6ctrl", 0x04b6, 1, -1, 0x00, "pin 6 control register"}, + {"portf.pin7ctrl", 0x04b7, 1, -1, 0x00, "pin 7 control register"}, + {"portf.evgenctrla", 0x04b8, 1, -1, 0x00, "event generation control A register"}, + {"portmux.evsysroutea", 0x05e0, 1, -1, 0x00, "port multiplexer EVSYS register"}, + {"portmux.cclroutea", 0x05e1, 1, -1, 0x00, "CCL route A register"}, + {"portmux.usartroutea", 0x05e2, 1, -1, 0x00, "USART route A register"}, + {"portmux.spiroutea", 0x05e5, 1, -1, 0x00, "SPI route A register"}, + {"portmux.twiroutea", 0x05e6, 1, -1, 0x00, "TWI route A register"}, + {"portmux.tcaroutea", 0x05e7, 1, -1, 0x00, "TCA route A register"}, + {"portmux.tcbroutea", 0x05e8, 1, -1, 0x00, "TCB route A register"}, + {"adc0.ctrla", 0x0600, 1, -1, 0x00, "control register A"}, + {"adc0.ctrlb", 0x0601, 1, -1, 0x00, "control register B"}, + {"adc0.ctrlc", 0x0602, 1, -1, 0x00, "control register C"}, + {"adc0.ctrld", 0x0603, 1, -1, 0x00, "control register D"}, + {"adc0.ctrle", 0x0604, 1, -1, 0x00, "control register E"}, + {"adc0.ctrlf", 0x0605, 1, -1, 0x00, "control register F"}, + {"adc0.intctrl", 0x0606, 1, -1, 0x00, "interrupt control register"}, + {"adc0.intflags", 0x0607, 1, -1, 0x00, "interrupt flags register"}, + {"adc0.status", 0x0608, 1, -1, 0x00, "status register"}, + {"adc0.dbgctrl", 0x0609, 1, -1, 0x00, "debug control register"}, + {"adc0.command", 0x060a, 1, -1, 0x00, "command register"}, + {"adc0.muxpos", 0x060b, 1, -1, 0x00, "positive mux input register"}, + {"adc0.result", 0x060c, 2, -1, -1, "result register (32 bits)"}, + {"adc0.sample", 0x060e, 2, -1, 0x0000, "sample register (16 bits)"}, + {"adc0.winlt", 0x0610, 2, -1, -1, "window comparator low threshold register (16 bits)"}, + {"adc0.winht", 0x0612, 2, -1, -1, "window comparator high threshold register (16 bits)"}, + {"adc0.temp", 0x0614, 1, -1, 0x00, "temporary data register"}, + {"ac0.ctrla", 0x0680, 1, -1, 0x00, "control register A"}, + {"ac0.muxctrl", 0x0682, 1, -1, 0x00, "mux control A register"}, + {"ac0.dacref", 0x0685, 1, -1, 0xff, "DAC voltage reference register"}, + {"ac0.intctrl", 0x0686, 1, -1, 0x00, "interrupt control register"}, + {"ac0.status", 0x0687, 1, -1, 0x00, "status register"}, + {"usart0.rxdatal", 0x0800, 1, -1, 0x00, "receive data low byte"}, + {"usart0.rxdatah", 0x0801, 1, -1, 0x00, "receive data high byte"}, + {"usart0.txdatal", 0x0802, 1, -1, 0x00, "transmit data low byte"}, + {"usart0.txdatah", 0x0803, 1, -1, 0x00, "transmit data high byte"}, + {"usart0.status", 0x0804, 1, -1, 0x20, "status register"}, + {"usart0.ctrla", 0x0805, 1, -1, 0x00, "control register A"}, + {"usart0.ctrlb", 0x0806, 1, -1, 0x00, "control register B"}, + {"usart0.ctrlc", 0x0807, 1, -1, 0x03, "control register C"}, + {"usart0.baud", 0x0808, 2, -1, 0x0000, "baud rate register (16 bits)"}, + {"usart0.ctrld", 0x080a, 1, -1, 0x00, "control register D"}, + {"usart0.dbgctrl", 0x080b, 1, -1, 0x00, "debug control register"}, + {"usart0.evctrl", 0x080c, 1, -1, 0x00, "event control register"}, + {"usart0.txplctrl", 0x080d, 1, -1, 0x00, "IRCOM transmitter pulse length control register"}, + {"usart0.rxplctrl", 0x080e, 1, -1, 0x00, "IRCOM receiver pulse length control register"}, + {"usart1.rxdatal", 0x0820, 1, -1, 0x00, "receive data low byte"}, + {"usart1.rxdatah", 0x0821, 1, -1, 0x00, "receive data high byte"}, + {"usart1.txdatal", 0x0822, 1, -1, 0x00, "transmit data low byte"}, + {"usart1.txdatah", 0x0823, 1, -1, 0x00, "transmit data high byte"}, + {"usart1.status", 0x0824, 1, -1, 0x20, "status register"}, + {"usart1.ctrla", 0x0825, 1, -1, 0x00, "control register A"}, + {"usart1.ctrlb", 0x0826, 1, -1, 0x00, "control register B"}, + {"usart1.ctrlc", 0x0827, 1, -1, 0x03, "control register C"}, + {"usart1.baud", 0x0828, 2, -1, 0x0000, "baud rate register (16 bits)"}, + {"usart1.ctrld", 0x082a, 1, -1, 0x00, "control register D"}, + {"usart1.dbgctrl", 0x082b, 1, -1, 0x00, "debug control register"}, + {"usart1.evctrl", 0x082c, 1, -1, 0x00, "event control register"}, + {"usart1.txplctrl", 0x082d, 1, -1, 0x00, "IRCOM transmitter pulse length control register"}, + {"usart1.rxplctrl", 0x082e, 1, -1, 0x00, "IRCOM receiver pulse length control register"}, + {"twi0.ctrla", 0x0900, 1, -1, 0x00, "control register A"}, + {"twi0.dbgctrl", 0x0902, 1, -1, 0x00, "debug control register"}, + {"twi0.mctrla", 0x0903, 1, -1, 0x00, "host control A register"}, + {"twi0.mctrlb", 0x0904, 1, -1, 0x00, "host control B register"}, + {"twi0.hstatus", 0x0905, 1, -1, 0x00, "host status register"}, + {"twi0.mbaud", 0x0906, 1, -1, 0x00, "host baud rate register"}, + {"twi0.haddr", 0x0907, 1, -1, 0x00, "host address register"}, + {"twi0.hdata", 0x0908, 1, -1, 0x00, "host data register"}, + {"twi0.sctrla", 0x0909, 1, -1, 0x00, "client control A register"}, + {"twi0.sctrlb", 0x090a, 1, -1, 0x00, "client control B register"}, + {"twi0.sstatus", 0x090b, 1, -1, 0x00, "client status register"}, + {"twi0.saddr", 0x090c, 1, -1, 0x00, "client address register"}, + {"twi0.sdata", 0x090d, 1, -1, 0x00, "client data register"}, + {"twi0.saddrmask", 0x090e, 1, -1, 0x00, "client address mask register"}, + {"spi0.ctrla", 0x0940, 1, -1, 0x00, "control register A"}, + {"spi0.ctrlb", 0x0941, 1, -1, 0x00, "control register B"}, + {"spi0.intctrl", 0x0942, 1, -1, 0x00, "interrupt control register"}, + {"spi0.intflags", 0x0943, 1, -1, 0x00, "interrupt flags register"}, + {"spi0.data", 0x0944, 1, -1, -1, "data register"}, + {"tca0.ctrla", 0x0a00, 1, -1, 0x00, "control register A"}, + {"tca0.ctrlb", 0x0a01, 1, -1, 0x00, "control register B"}, + {"tca0.ctrlc", 0x0a02, 1, -1, 0x00, "control register C"}, + {"tca0.ctrld", 0x0a03, 1, -1, 0x00, "control register D"}, + {"tca0.ctrleclr", 0x0a04, 1, -1, 0x00, "control register E clear"}, + {"tca0.ctrleset", 0x0a05, 1, -1, 0x00, "control register E set"}, + {"tca0.ctrlfclr", 0x0a06, 1, -1, 0x00, "control register F clear"}, + {"tca0.ctrlfset", 0x0a07, 1, -1, 0x00, "control register F set"}, + {"tca0.evctrl", 0x0a09, 1, -1, 0x00, "event control register"}, + {"tca0.intctrl", 0x0a0a, 1, -1, 0x00, "interrupt control register"}, + {"tca0.intflags", 0x0a0b, 1, -1, 0x00, "interrupt flags register"}, + {"tca0.dbgctrl", 0x0a0e, 1, -1, 0x00, "debug control register"}, + {"tca0.temp", 0x0a0f, 1, -1, -1, "temporary register for 16-bit access"}, + {"tca0.cnt", 0x0a20, 2, -1, -1, "counter (16 bits)"}, + {"tca0.lcnt", 0x0a20, 1, -1, -1, "low byte counter"}, + {"tca0.hcnt", 0x0a21, 1, -1, -1, "high byte counter"}, + {"tca0.per", 0x0a26, 2, -1, -1, "period register (16 bits)"}, + {"tca0.lper", 0x0a26, 1, -1, -1, "low byte period register"}, + {"tca0.hper", 0x0a27, 1, -1, -1, "high byte period register"}, + {"tca0.cmp0", 0x0a28, 2, -1, -1, "compare 0 register (16 bits)"}, + {"tca0.lcmp0", 0x0a28, 1, -1, -1, "low byte compare register"}, + {"tca0.hcmp0", 0x0a29, 1, -1, -1, "high byte compare register 0"}, + {"tca0.cmp1", 0x0a2a, 2, -1, -1, "compare 1 register (16 bits)"}, + {"tca0.lcmp1", 0x0a2a, 1, -1, -1, "low byte compare register"}, + {"tca0.hcmp1", 0x0a2b, 1, -1, -1, "high byte compare register 1"}, + {"tca0.cmp2", 0x0a2c, 2, -1, -1, "compare 2 register (16 bits)"}, + {"tca0.lcmp2", 0x0a2c, 1, -1, -1, "low byte compare register"}, + {"tca0.hcmp2", 0x0a2d, 1, -1, -1, "high byte compare register 2"}, + {"tca0.perbuf", 0x0a36, 2, -1, -1, "period buffer register (16 bits)"}, + {"tca0.cmp0buf", 0x0a38, 2, -1, -1, "compare 0 buffer register (16 bits)"}, + {"tca0.cmp1buf", 0x0a3a, 2, -1, -1, "compare 1 buffer register (16 bits)"}, + {"tca0.cmp2buf", 0x0a3c, 2, -1, -1, "compare 2 buffer register (16 bits)"}, + {"tcb0.ctrla", 0x0b00, 1, -1, 0x00, "control register A"}, + {"tcb0.ctrlb", 0x0b01, 1, -1, 0x00, "control register B"}, + {"tcb0.evctrl", 0x0b04, 1, -1, 0x00, "event control register"}, + {"tcb0.intctrl", 0x0b05, 1, -1, 0x00, "interrupt control register"}, + {"tcb0.intflags", 0x0b06, 1, -1, 0x00, "interrupt flags register"}, + {"tcb0.status", 0x0b07, 1, -1, 0x00, "status register"}, + {"tcb0.dbgctrl", 0x0b08, 1, -1, 0x00, "debug control register"}, + {"tcb0.temp", 0x0b09, 1, -1, -1, "temporary register for 16-bit access"}, + {"tcb0.cnt", 0x0b0a, 2, -1, 0x0000, "counter (16 bits)"}, + {"tcb0.ccmp", 0x0b0c, 2, -1, -1, "compare or capture register (16 bits)"}, + {"tcb1.ctrla", 0x0b10, 1, -1, 0x00, "control register A"}, + {"tcb1.ctrlb", 0x0b11, 1, -1, 0x00, "control register B"}, + {"tcb1.evctrl", 0x0b14, 1, -1, 0x00, "event control register"}, + {"tcb1.intctrl", 0x0b15, 1, -1, 0x00, "interrupt control register"}, + {"tcb1.intflags", 0x0b16, 1, -1, 0x00, "interrupt flags register"}, + {"tcb1.status", 0x0b17, 1, -1, 0x00, "status register"}, + {"tcb1.dbgctrl", 0x0b18, 1, -1, 0x00, "debug control register"}, + {"tcb1.temp", 0x0b19, 1, -1, -1, "temporary register for 16-bit access"}, + {"tcb1.cnt", 0x0b1a, 2, -1, 0x0000, "counter (16 bits)"}, + {"tcb1.ccmp", 0x0b1c, 2, -1, -1, "compare or capture register (16 bits)"}, + {"usb0.ctrla", 0x0c00, 1, -1, 0x00, "control register A"}, + {"usb0.ctrlb", 0x0c01, 1, -1, 0x00, "control register B"}, + {"usb0.busstate", 0x0c02, 1, -1, 0x00, "bus state register"}, + {"usb0.addr", 0x0c03, 1, -1, 0x00, "address register"}, + {"usb0.fifowp", 0x0c04, 1, -1, 0xff, "FIFO write pointer register"}, + {"usb0.fiforp", 0x0c05, 1, -1, 0xff, "FIFO read pointer register"}, + {"usb0.epptr", 0x0c06, 2, -1, 0x0000, "endpoint configuration table pointer register (16 bits)"}, + {"usb0.intctrla", 0x0c08, 1, -1, 0x00, "interrupt control register A"}, + {"usb0.intctrlb", 0x0c09, 1, -1, 0x00, "interrupt control register B"}, + {"usb0.intflagsa", 0x0c0a, 1, -1, 0x00, "interrupt flags A register"}, + {"usb0.intflagsb", 0x0c0b, 1, -1, 0x00, "interrupt flags B register"}, + {"usb.status.outclr", 0x0c40, 1, -1, 0x00, "endpoint n OUT status clear register"}, + {"usb.status.outset", 0x0c41, 1, -1, 0x00, "endpoint n OUT status set register"}, + {"usb.status.inclr", 0x0c42, 1, -1, 0x00, "endpoint n IN status clear register"}, + {"usb.status.inset", 0x0c43, 1, -1, 0x00, "endpoint n IN status set register"}, + {"syscfg.revid", 0x0f01, 1, -1, -1, "revision ID register"}, + {"syscfg.vusbctrl", 0x0f06, 1, -1, 0x00, "USB voltage system control register"}, + {"nvmctrl.ctrla", 0x1000, 1, -1, 0x00, "control register A"}, + {"nvmctrl.ctrlb", 0x1001, 1, -1, 0x30, "control register B"}, + {"nvmctrl.ctrlc", 0x1002, 1, -1, 0x00, "control register C"}, + {"nvmctrl.intctrl", 0x1004, 1, -1, 0x00, "interrupt control register"}, + {"nvmctrl.intflags", 0x1005, 1, -1, 0x00, "interrupt flags register"}, + {"nvmctrl.status", 0x1006, 1, -1, 0x00, "status register"}, + {"nvmctrl.data", 0x1008, 4, -1, 0x00000000, "data register (32 bits)"}, + {"nvmctrl.addr", 0x100c, 4, -1, -1, "address register (32 bits)"}, +}; + // AVR16EB20 AVR16EB28 AVR16EB32 const Register_file_t rgftab_avr16eb20[393] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, @@ -48698,382 +49524,6 @@ const Register_file_t rgftab_avr64da28[433] = { // I/O memory [0, 4159] {"nvmctrl.addr", 0x1008, 4, -1, -1, "address register (32 bits)"}, }; -// AVR64DU28 AVR64DU32 -const Register_file_t rgftab_avr64du28[372] = { // I/O memory [0, 4159] - {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, - {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, - {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, - {"vporta.intflags", 0x0003, 1, -1, 0x00, "interrupt flags register"}, - {"vportc.dir", 0x0008, 1, -1, 0x00, "data direction register"}, - {"vportc.out", 0x0009, 1, -1, 0x00, "I/O port output register"}, - {"vportc.in", 0x000a, 1, -1, 0x00, "I/O port input register"}, - {"vportc.intflags", 0x000b, 1, -1, 0x00, "interrupt flags register"}, - {"vportd.dir", 0x000c, 1, -1, 0x00, "data direction register"}, - {"vportd.out", 0x000d, 1, -1, 0x00, "I/O port output register"}, - {"vportd.in", 0x000e, 1, -1, 0x00, "I/O port input register"}, - {"vportd.intflags", 0x000f, 1, -1, 0x00, "interrupt flags register"}, - {"vportf.dir", 0x0014, 1, -1, 0x00, "data direction register"}, - {"vportf.out", 0x0015, 1, -1, 0x00, "I/O port output register"}, - {"vportf.in", 0x0016, 1, -1, 0x00, "I/O port input register"}, - {"vportf.intflags", 0x0017, 1, -1, 0x00, "interrupt flags register"}, - {"gpr.gpr0", 0x001c, 1, -1, -1, "general purpose register 0"}, - {"gpr.gpr1", 0x001d, 1, -1, -1, "general purpose register 1"}, - {"gpr.gpr2", 0x001e, 1, -1, -1, "general purpose register 2"}, - {"gpr.gpr3", 0x001f, 1, -1, -1, "general purpose register 3"}, - {"cpu.ccp", 0x0034, 1, -1, 0x00, "configuration change protection register"}, - {"cpu.rampz", 0x003b, 1, -1, 0x00, "extended Z register"}, - {"cpu.sp", 0x003d, 2, -1, 0x7fff, "stack pointer (16 bits)"}, - {"cpu.sreg", 0x003f, 1, -1, 0x00, "status register"}, - {"rstctrl.rstfr", 0x0040, 1, -1, 0x00, "reset flags register"}, - {"rstctrl.swrr", 0x0041, 1, -1, 0x00, "software reset register"}, - {"slpctrl.ctrla", 0x0050, 1, -1, 0x00, "control register A"}, - {"slpctrl.vregctrl", 0x0051, 1, -1, 0x00, "control B register"}, - {"clkctrl.mclkctrla", 0x0060, 1, -1, 0x00, "MCLK control A register"}, - {"clkctrl.mclkctrlb", 0x0061, 1, -1, 0x00, "MCLK control B register"}, - {"clkctrl.mclkctrlc", 0x0062, 1, -1, 0x00, "MCLK control C register"}, - {"clkctrl.mclkintctrl", 0x0063, 1, -1, 0x00, "MCLK interrupt control register"}, - {"clkctrl.mclkintflags", 0x0064, 1, -1, 0x00, "MCLK interrupt flags register"}, - {"clkctrl.mclkstatus", 0x0065, 1, -1, 0x00, "MCLK status register"}, - {"clkctrl.mclktimebase", 0x0066, 1, -1, 0x00, "MCLK timebase register"}, - {"clkctrl.oschfctrla", 0x0068, 1, -1, 0x0c, "OSCHF control A register"}, - {"clkctrl.oschftune", 0x0069, 1, -1, -1, "OSCHF tune register"}, - {"clkctrl.oschfstatus", 0x006a, 1, -1, -1, "OSCHF status register"}, - {"clkctrl.osc32kctrla", 0x0078, 1, -1, 0x00, "OSC32K control A register"}, - {"clkctrl.xosc32kctrla", 0x007c, 1, -1, 0x00, "XOSC32K control A register"}, - {"clkctrl.xoschfctrla", 0x0080, 1, -1, 0x00, "XOSC HF control A register"}, - {"clkctrl.usbpllstatus", 0x0085, 1, -1, 0x00, "PLL status register"}, - {"bod.ctrla", 0x00a0, 1, -1, 0x01, "control register A"}, - {"bod.ctrlb", 0x00a1, 1, -1, 0x00, "control register B"}, - {"bod.vlmctrla", 0x00a8, 1, -1, 0x00, "voltage level monitor control register"}, - {"bod.intctrl", 0x00a9, 1, -1, 0x00, "interrupt control register"}, - {"bod.intflags", 0x00aa, 1, -1, 0x00, "interrupt flags register"}, - {"bod.status", 0x00ab, 1, -1, 0x00, "status register"}, - {"vref.acref", 0x00b0, 1, -1, 0x00, "AC reference register"}, - {"wdt.ctrla", 0x0100, 1, -1, 0x00, "control register A"}, - {"wdt.status", 0x0101, 1, -1, 0x00, "status register"}, - {"cpuint.ctrla", 0x0110, 1, -1, 0x00, "control register A"}, - {"cpuint.status", 0x0111, 1, -1, 0x00, "status register"}, - {"cpuint.lvl0pri", 0x0112, 1, -1, 0x00, "interrupt level 0 priority register"}, - {"cpuint.lvl1vec", 0x0113, 1, -1, 0x00, "interrupt level 1 priority vector register"}, - {"crcscan.ctrla", 0x0120, 1, -1, 0x00, "control register A"}, - {"crcscan.ctrlb", 0x0121, 1, -1, 0x00, "control register B"}, - {"crcscan.status", 0x0122, 1, -1, 0x02, "status register"}, - {"rtc.ctrla", 0x0140, 1, -1, 0x00, "control register A"}, - {"rtc.status", 0x0141, 1, -1, 0x00, "status register"}, - {"rtc.intctrl", 0x0142, 1, -1, 0x00, "interrupt control register"}, - {"rtc.intflags", 0x0143, 1, -1, 0x00, "interrupt flags register"}, - {"rtc.temp", 0x0144, 1, -1, -1, "temporary register"}, - {"rtc.dbgctrl", 0x0145, 1, -1, 0x00, "debug control register"}, - {"rtc.calib", 0x0146, 1, -1, 0x00, "calibration register"}, - {"rtc.clksel", 0x0147, 1, -1, 0x00, "clock select register"}, - {"rtc.cnt", 0x0148, 2, -1, -1, "counter (16 bits)"}, - {"rtc.per", 0x014a, 2, -1, 0xffff, "period register (16 bits)"}, - {"rtc.cmp", 0x014c, 2, -1, -1, "compare register (16 bits)"}, - {"rtc.pitctrla", 0x0150, 1, -1, 0x00, "PIT control A register"}, - {"rtc.pitstatus", 0x0151, 1, -1, 0x00, "PIT status register"}, - {"rtc.pitintctrl", 0x0152, 1, -1, 0x00, "PIT interrupt control register"}, - {"rtc.pitintflags", 0x0153, 1, -1, 0x00, "PIT interrupt flags register"}, - {"rtc.pitdbgctrl", 0x0155, 1, -1, 0x00, "PIT debug control register"}, - {"rtc.pitevgenctrla", 0x0156, 1, -1, 0x00, "PIT event generation control A register"}, - {"ccl.ctrla", 0x01c0, 1, -1, 0x00, "control register A"}, - {"ccl.seqctrl0", 0x01c1, 1, -1, 0x00, "sequential control register 0"}, - {"ccl.seqctrl1", 0x01c2, 1, -1, 0x00, "sequential control register 1"}, - {"ccl.intctrl0", 0x01c5, 1, -1, 0x00, "interrupt control register 0"}, - {"ccl.intflags", 0x01c7, 1, -1, 0x00, "interrupt flags register"}, - {"ccl.lut0ctrla", 0x01c8, 1, -1, 0x00, "LUT 0 control A register"}, - {"ccl.lut0ctrlb", 0x01c9, 1, -1, 0x00, "LUT 0 control B register"}, - {"ccl.lut0ctrlc", 0x01ca, 1, -1, 0x00, "LUT 0 control C register"}, - {"ccl.truth0", 0x01cb, 1, -1, 0x00, "truth register 0"}, - {"ccl.lut1ctrla", 0x01cc, 1, -1, 0x00, "LUT 1 control A register"}, - {"ccl.lut1ctrlb", 0x01cd, 1, -1, 0x00, "LUT 1 control B register"}, - {"ccl.lut1ctrlc", 0x01ce, 1, -1, 0x00, "LUT 1 control C register"}, - {"ccl.truth1", 0x01cf, 1, -1, 0x00, "truth register 1"}, - {"ccl.lut2ctrla", 0x01d0, 1, -1, 0x00, "LUT 2 control A register"}, - {"ccl.lut2ctrlb", 0x01d1, 1, -1, 0x00, "LUT 2 control B register"}, - {"ccl.lut2ctrlc", 0x01d2, 1, -1, 0x00, "LUT 2 control C register"}, - {"ccl.truth2", 0x01d3, 1, -1, 0x00, "truth register 2"}, - {"ccl.lut3ctrla", 0x01d4, 1, -1, 0x00, "LUT 3 control A register"}, - {"ccl.lut3ctrlb", 0x01d5, 1, -1, 0x00, "LUT 3 control B register"}, - {"ccl.lut3ctrlc", 0x01d6, 1, -1, 0x00, "LUT 3 control C register"}, - {"ccl.truth3", 0x01d7, 1, -1, 0x00, "truth register 3"}, - {"evsys.sweventa", 0x0200, 1, -1, 0x00, "software event A register"}, - {"evsys.channel0", 0x0210, 1, -1, 0x00, "multiplexer channel 0 register"}, - {"evsys.channel1", 0x0211, 1, -1, 0x00, "multiplexer channel 1 register"}, - {"evsys.channel2", 0x0212, 1, -1, 0x00, "multiplexer channel 2 register"}, - {"evsys.channel3", 0x0213, 1, -1, 0x00, "multiplexer channel 3 register"}, - {"evsys.channel4", 0x0214, 1, -1, 0x00, "multiplexer channel 4 register"}, - {"evsys.channel5", 0x0215, 1, -1, 0x00, "multiplexer channel 5 register"}, - {"evsys.userccllut0a", 0x0220, 1, -1, 0x00, "user CCL LUT 0 event A register"}, - {"evsys.userccllut0b", 0x0221, 1, -1, 0x00, "user CCL LUT 0 event B register"}, - {"evsys.userccllut1a", 0x0222, 1, -1, 0x00, "user CCL LUT 1 event A register"}, - {"evsys.userccllut1b", 0x0223, 1, -1, 0x00, "user CCL LUT 1 event B register"}, - {"evsys.userccllut2a", 0x0224, 1, -1, 0x00, "user CCL LUT 2 event A register"}, - {"evsys.userccllut2b", 0x0225, 1, -1, 0x00, "user CCL LUT 2 event B register"}, - {"evsys.userccllut3a", 0x0226, 1, -1, 0x00, "user CCL LUT 3 event A register"}, - {"evsys.userccllut3b", 0x0227, 1, -1, 0x00, "user CCL LUT 3 event B register"}, - {"evsys.useradc0start", 0x0228, 1, -1, 0x00, "user ADC 0 start register"}, - {"evsys.userevsysevouta", 0x0229, 1, -1, 0x00, "user EVOUT port A register"}, - {"evsys.userevsysevoutd", 0x022a, 1, -1, 0x00, "user EVOUT port D register"}, - {"evsys.userevsysevoutf", 0x022b, 1, -1, 0x00, "user EVOUT port F register"}, - {"evsys.userusart0irda", 0x022c, 1, -1, 0x00, "user USART 0 IrDA event register"}, - {"evsys.userusart1irda", 0x022d, 1, -1, 0x00, "user USART 1 IrDA event register"}, - {"evsys.usertca0cnta", 0x022e, 1, -1, 0x00, "user TCA 0 event A register"}, - {"evsys.usertca0cntb", 0x022f, 1, -1, 0x00, "user TCA 0 event B register"}, - {"evsys.usertcb0capt", 0x0230, 1, -1, 0x00, "user TCB 0 capture register"}, - {"evsys.usertcb0count", 0x0231, 1, -1, 0x00, "user TCB 0 event register"}, - {"evsys.usertcb1capt", 0x0232, 1, -1, 0x00, "user TCB 1 capture register"}, - {"evsys.usertcb1count", 0x0233, 1, -1, 0x00, "user TCB 1 event register"}, - {"porta.dir", 0x0400, 1, -1, 0x00, "data direction register"}, - {"porta.dirset", 0x0401, 1, -1, 0x00, "data direction set register"}, - {"porta.dirclr", 0x0402, 1, -1, 0x00, "data direction clear register"}, - {"porta.dirtgl", 0x0403, 1, -1, 0x00, "data direction toggle register"}, - {"porta.out", 0x0404, 1, -1, 0x00, "I/O port output register"}, - {"porta.outset", 0x0405, 1, -1, 0x00, "I/O port output set register"}, - {"porta.outclr", 0x0406, 1, -1, 0x00, "I/O port output clear register"}, - {"porta.outtgl", 0x0407, 1, -1, 0x00, "I/O port output toggle register"}, - {"porta.in", 0x0408, 1, -1, 0x00, "I/O port input register"}, - {"porta.intflags", 0x0409, 1, -1, 0x00, "interrupt flags register"}, - {"porta.portctrl", 0x040a, 1, -1, 0x00, "port control register"}, - {"porta.pinconfig", 0x040b, 1, -1, 0x00, "pin control config register"}, - {"porta.pinctrlupd", 0x040c, 1, -1, 0x00, "pin control update register"}, - {"porta.pinctrlset", 0x040d, 1, -1, 0x00, "pin control set register"}, - {"porta.pinctrlclr", 0x040e, 1, -1, 0x00, "pin control clear register"}, - {"porta.pin0ctrl", 0x0410, 1, -1, 0x00, "pin 0 control register"}, - {"porta.pin1ctrl", 0x0411, 1, -1, 0x00, "pin 1 control register"}, - {"porta.pin2ctrl", 0x0412, 1, -1, 0x00, "pin 2 control register"}, - {"porta.pin3ctrl", 0x0413, 1, -1, 0x00, "pin 3 control register"}, - {"porta.pin4ctrl", 0x0414, 1, -1, 0x00, "pin 4 control register"}, - {"porta.pin5ctrl", 0x0415, 1, -1, 0x00, "pin 5 control register"}, - {"porta.pin6ctrl", 0x0416, 1, -1, 0x00, "pin 6 control register"}, - {"porta.pin7ctrl", 0x0417, 1, -1, 0x00, "pin 7 control register"}, - {"porta.evgenctrla", 0x0418, 1, -1, 0x00, "event generation control A register"}, - {"portc.dir", 0x0440, 1, -1, 0x00, "data direction register"}, - {"portc.dirset", 0x0441, 1, -1, 0x00, "data direction set register"}, - {"portc.dirclr", 0x0442, 1, -1, 0x00, "data direction clear register"}, - {"portc.dirtgl", 0x0443, 1, -1, 0x00, "data direction toggle register"}, - {"portc.out", 0x0444, 1, -1, 0x00, "I/O port output register"}, - {"portc.outset", 0x0445, 1, -1, 0x00, "I/O port output set register"}, - {"portc.outclr", 0x0446, 1, -1, 0x00, "I/O port output clear register"}, - {"portc.outtgl", 0x0447, 1, -1, 0x00, "I/O port output toggle register"}, - {"portc.in", 0x0448, 1, -1, 0x00, "I/O port input register"}, - {"portc.intflags", 0x0449, 1, -1, 0x00, "interrupt flags register"}, - {"portc.portctrl", 0x044a, 1, -1, 0x00, "port control register"}, - {"portc.pinconfig", 0x044b, 1, -1, 0x00, "pin control config register"}, - {"portc.pinctrlupd", 0x044c, 1, -1, 0x00, "pin control update register"}, - {"portc.pinctrlset", 0x044d, 1, -1, 0x00, "pin control set register"}, - {"portc.pinctrlclr", 0x044e, 1, -1, 0x00, "pin control clear register"}, - {"portc.pin0ctrl", 0x0450, 1, -1, 0x00, "pin 0 control register"}, - {"portc.pin1ctrl", 0x0451, 1, -1, 0x00, "pin 1 control register"}, - {"portc.pin2ctrl", 0x0452, 1, -1, 0x00, "pin 2 control register"}, - {"portc.pin3ctrl", 0x0453, 1, -1, 0x00, "pin 3 control register"}, - {"portc.pin4ctrl", 0x0454, 1, -1, 0x00, "pin 4 control register"}, - {"portc.pin5ctrl", 0x0455, 1, -1, 0x00, "pin 5 control register"}, - {"portc.pin6ctrl", 0x0456, 1, -1, 0x00, "pin 6 control register"}, - {"portc.pin7ctrl", 0x0457, 1, -1, 0x00, "pin 7 control register"}, - {"portc.evgenctrla", 0x0458, 1, -1, 0x00, "event generation control A register"}, - {"portd.dir", 0x0460, 1, -1, 0x00, "data direction register"}, - {"portd.dirset", 0x0461, 1, -1, 0x00, "data direction set register"}, - {"portd.dirclr", 0x0462, 1, -1, 0x00, "data direction clear register"}, - {"portd.dirtgl", 0x0463, 1, -1, 0x00, "data direction toggle register"}, - {"portd.out", 0x0464, 1, -1, 0x00, "I/O port output register"}, - {"portd.outset", 0x0465, 1, -1, 0x00, "I/O port output set register"}, - {"portd.outclr", 0x0466, 1, -1, 0x00, "I/O port output clear register"}, - {"portd.outtgl", 0x0467, 1, -1, 0x00, "I/O port output toggle register"}, - {"portd.in", 0x0468, 1, -1, 0x00, "I/O port input register"}, - {"portd.intflags", 0x0469, 1, -1, 0x00, "interrupt flags register"}, - {"portd.portctrl", 0x046a, 1, -1, 0x00, "port control register"}, - {"portd.pinconfig", 0x046b, 1, -1, 0x00, "pin control config register"}, - {"portd.pinctrlupd", 0x046c, 1, -1, 0x00, "pin control update register"}, - {"portd.pinctrlset", 0x046d, 1, -1, 0x00, "pin control set register"}, - {"portd.pinctrlclr", 0x046e, 1, -1, 0x00, "pin control clear register"}, - {"portd.pin0ctrl", 0x0470, 1, -1, 0x00, "pin 0 control register"}, - {"portd.pin1ctrl", 0x0471, 1, -1, 0x00, "pin 1 control register"}, - {"portd.pin2ctrl", 0x0472, 1, -1, 0x00, "pin 2 control register"}, - {"portd.pin3ctrl", 0x0473, 1, -1, 0x00, "pin 3 control register"}, - {"portd.pin4ctrl", 0x0474, 1, -1, 0x00, "pin 4 control register"}, - {"portd.pin5ctrl", 0x0475, 1, -1, 0x00, "pin 5 control register"}, - {"portd.pin6ctrl", 0x0476, 1, -1, 0x00, "pin 6 control register"}, - {"portd.pin7ctrl", 0x0477, 1, -1, 0x00, "pin 7 control register"}, - {"portd.evgenctrla", 0x0478, 1, -1, 0x00, "event generation control A register"}, - {"portf.dir", 0x04a0, 1, -1, 0x00, "data direction register"}, - {"portf.dirset", 0x04a1, 1, -1, 0x00, "data direction set register"}, - {"portf.dirclr", 0x04a2, 1, -1, 0x00, "data direction clear register"}, - {"portf.dirtgl", 0x04a3, 1, -1, 0x00, "data direction toggle register"}, - {"portf.out", 0x04a4, 1, -1, 0x00, "I/O port output register"}, - {"portf.outset", 0x04a5, 1, -1, 0x00, "I/O port output set register"}, - {"portf.outclr", 0x04a6, 1, -1, 0x00, "I/O port output clear register"}, - {"portf.outtgl", 0x04a7, 1, -1, 0x00, "I/O port output toggle register"}, - {"portf.in", 0x04a8, 1, -1, 0x00, "I/O port input register"}, - {"portf.intflags", 0x04a9, 1, -1, 0x00, "interrupt flags register"}, - {"portf.portctrl", 0x04aa, 1, -1, 0x00, "port control register"}, - {"portf.pinconfig", 0x04ab, 1, -1, 0x00, "pin control config register"}, - {"portf.pinctrlupd", 0x04ac, 1, -1, 0x00, "pin control update register"}, - {"portf.pinctrlset", 0x04ad, 1, -1, 0x00, "pin control set register"}, - {"portf.pinctrlclr", 0x04ae, 1, -1, 0x00, "pin control clear register"}, - {"portf.pin0ctrl", 0x04b0, 1, -1, 0x00, "pin 0 control register"}, - {"portf.pin1ctrl", 0x04b1, 1, -1, 0x00, "pin 1 control register"}, - {"portf.pin2ctrl", 0x04b2, 1, -1, 0x00, "pin 2 control register"}, - {"portf.pin3ctrl", 0x04b3, 1, -1, 0x00, "pin 3 control register"}, - {"portf.pin4ctrl", 0x04b4, 1, -1, 0x00, "pin 4 control register"}, - {"portf.pin5ctrl", 0x04b5, 1, -1, 0x00, "pin 5 control register"}, - {"portf.pin6ctrl", 0x04b6, 1, -1, 0x00, "pin 6 control register"}, - {"portf.pin7ctrl", 0x04b7, 1, -1, 0x00, "pin 7 control register"}, - {"portf.evgenctrla", 0x04b8, 1, -1, 0x00, "event generation control A register"}, - {"portmux.evsysroutea", 0x05e0, 1, -1, 0x00, "port multiplexer EVSYS register"}, - {"portmux.cclroutea", 0x05e1, 1, -1, 0x00, "CCL route A register"}, - {"portmux.usartroutea", 0x05e2, 1, -1, 0x00, "USART route A register"}, - {"portmux.spiroutea", 0x05e5, 1, -1, 0x00, "SPI route A register"}, - {"portmux.twiroutea", 0x05e6, 1, -1, 0x00, "TWI route A register"}, - {"portmux.tcaroutea", 0x05e7, 1, -1, 0x00, "TCA route A register"}, - {"portmux.tcbroutea", 0x05e8, 1, -1, 0x00, "TCB route A register"}, - {"adc0.ctrla", 0x0600, 1, -1, 0x00, "control register A"}, - {"adc0.ctrlb", 0x0601, 1, -1, 0x00, "control register B"}, - {"adc0.ctrlc", 0x0602, 1, -1, 0x00, "control register C"}, - {"adc0.ctrld", 0x0603, 1, -1, 0x00, "control register D"}, - {"adc0.ctrle", 0x0604, 1, -1, 0x00, "control register E"}, - {"adc0.ctrlf", 0x0605, 1, -1, 0x00, "control register F"}, - {"adc0.intctrl", 0x0606, 1, -1, 0x00, "interrupt control register"}, - {"adc0.intflags", 0x0607, 1, -1, 0x00, "interrupt flags register"}, - {"adc0.status", 0x0608, 1, -1, 0x00, "status register"}, - {"adc0.dbgctrl", 0x0609, 1, -1, 0x00, "debug control register"}, - {"adc0.command", 0x060a, 1, -1, 0x00, "command register"}, - {"adc0.muxpos", 0x060b, 1, -1, 0x00, "positive mux input register"}, - {"adc0.result", 0x060c, 2, -1, -1, "result register (32 bits)"}, - {"adc0.sample", 0x060e, 2, -1, 0x0000, "sample register (16 bits)"}, - {"adc0.winlt", 0x0610, 2, -1, -1, "window comparator low threshold register (16 bits)"}, - {"adc0.winht", 0x0612, 2, -1, -1, "window comparator high threshold register (16 bits)"}, - {"adc0.temp", 0x0614, 1, -1, 0x00, "temporary data register"}, - {"ac0.ctrla", 0x0680, 1, -1, 0x00, "control register A"}, - {"ac0.muxctrl", 0x0682, 1, -1, 0x00, "mux control A register"}, - {"ac0.dacref", 0x0685, 1, -1, 0xff, "DAC voltage reference register"}, - {"ac0.intctrl", 0x0686, 1, -1, 0x00, "interrupt control register"}, - {"ac0.status", 0x0687, 1, -1, 0x00, "status register"}, - {"usart0.rxdatal", 0x0800, 1, -1, 0x00, "receive data low byte"}, - {"usart0.rxdatah", 0x0801, 1, -1, 0x00, "receive data high byte"}, - {"usart0.txdatal", 0x0802, 1, -1, 0x00, "transmit data low byte"}, - {"usart0.txdatah", 0x0803, 1, -1, 0x00, "transmit data high byte"}, - {"usart0.status", 0x0804, 1, -1, 0x20, "status register"}, - {"usart0.ctrla", 0x0805, 1, -1, 0x00, "control register A"}, - {"usart0.ctrlb", 0x0806, 1, -1, 0x00, "control register B"}, - {"usart0.ctrlc", 0x0807, 1, -1, 0x03, "control register C"}, - {"usart0.baud", 0x0808, 2, -1, 0x0000, "baud rate register (16 bits)"}, - {"usart0.ctrld", 0x080a, 1, -1, 0x00, "control register D"}, - {"usart0.dbgctrl", 0x080b, 1, -1, 0x00, "debug control register"}, - {"usart0.evctrl", 0x080c, 1, -1, 0x00, "event control register"}, - {"usart0.txplctrl", 0x080d, 1, -1, 0x00, "IRCOM transmitter pulse length control register"}, - {"usart0.rxplctrl", 0x080e, 1, -1, 0x00, "IRCOM receiver pulse length control register"}, - {"usart1.rxdatal", 0x0820, 1, -1, 0x00, "receive data low byte"}, - {"usart1.rxdatah", 0x0821, 1, -1, 0x00, "receive data high byte"}, - {"usart1.txdatal", 0x0822, 1, -1, 0x00, "transmit data low byte"}, - {"usart1.txdatah", 0x0823, 1, -1, 0x00, "transmit data high byte"}, - {"usart1.status", 0x0824, 1, -1, 0x20, "status register"}, - {"usart1.ctrla", 0x0825, 1, -1, 0x00, "control register A"}, - {"usart1.ctrlb", 0x0826, 1, -1, 0x00, "control register B"}, - {"usart1.ctrlc", 0x0827, 1, -1, 0x03, "control register C"}, - {"usart1.baud", 0x0828, 2, -1, 0x0000, "baud rate register (16 bits)"}, - {"usart1.ctrld", 0x082a, 1, -1, 0x00, "control register D"}, - {"usart1.dbgctrl", 0x082b, 1, -1, 0x00, "debug control register"}, - {"usart1.evctrl", 0x082c, 1, -1, 0x00, "event control register"}, - {"usart1.txplctrl", 0x082d, 1, -1, 0x00, "IRCOM transmitter pulse length control register"}, - {"usart1.rxplctrl", 0x082e, 1, -1, 0x00, "IRCOM receiver pulse length control register"}, - {"twi0.ctrla", 0x0900, 1, -1, 0x00, "control register A"}, - {"twi0.dbgctrl", 0x0902, 1, -1, 0x00, "debug control register"}, - {"twi0.mctrla", 0x0903, 1, -1, 0x00, "host control A register"}, - {"twi0.mctrlb", 0x0904, 1, -1, 0x00, "host control B register"}, - {"twi0.hstatus", 0x0905, 1, -1, 0x00, "host status register"}, - {"twi0.mbaud", 0x0906, 1, -1, 0x00, "host baud rate register"}, - {"twi0.haddr", 0x0907, 1, -1, 0x00, "host address register"}, - {"twi0.hdata", 0x0908, 1, -1, 0x00, "host data register"}, - {"twi0.sctrla", 0x0909, 1, -1, 0x00, "client control A register"}, - {"twi0.sctrlb", 0x090a, 1, -1, 0x00, "client control B register"}, - {"twi0.sstatus", 0x090b, 1, -1, 0x00, "client status register"}, - {"twi0.saddr", 0x090c, 1, -1, 0x00, "client address register"}, - {"twi0.sdata", 0x090d, 1, -1, 0x00, "client data register"}, - {"twi0.saddrmask", 0x090e, 1, -1, 0x00, "client address mask register"}, - {"spi0.ctrla", 0x0940, 1, -1, 0x00, "control register A"}, - {"spi0.ctrlb", 0x0941, 1, -1, 0x00, "control register B"}, - {"spi0.intctrl", 0x0942, 1, -1, 0x00, "interrupt control register"}, - {"spi0.intflags", 0x0943, 1, -1, 0x00, "interrupt flags register"}, - {"spi0.data", 0x0944, 1, -1, -1, "data register"}, - {"tca0.ctrla", 0x0a00, 1, -1, 0x00, "control register A"}, - {"tca0.ctrlb", 0x0a01, 1, -1, 0x00, "control register B"}, - {"tca0.ctrlc", 0x0a02, 1, -1, 0x00, "control register C"}, - {"tca0.ctrld", 0x0a03, 1, -1, 0x00, "control register D"}, - {"tca0.ctrleclr", 0x0a04, 1, -1, 0x00, "control register E clear"}, - {"tca0.ctrleset", 0x0a05, 1, -1, 0x00, "control register E set"}, - {"tca0.ctrlfclr", 0x0a06, 1, -1, 0x00, "control register F clear"}, - {"tca0.ctrlfset", 0x0a07, 1, -1, 0x00, "control register F set"}, - {"tca0.evctrl", 0x0a09, 1, -1, 0x00, "event control register"}, - {"tca0.intctrl", 0x0a0a, 1, -1, 0x00, "interrupt control register"}, - {"tca0.intflags", 0x0a0b, 1, -1, 0x00, "interrupt flags register"}, - {"tca0.dbgctrl", 0x0a0e, 1, -1, 0x00, "debug control register"}, - {"tca0.temp", 0x0a0f, 1, -1, -1, "temporary register for 16-bit access"}, - {"tca0.cnt", 0x0a20, 2, -1, -1, "counter (16 bits)"}, - {"tca0.lcnt", 0x0a20, 1, -1, -1, "low byte counter"}, - {"tca0.hcnt", 0x0a21, 1, -1, -1, "high byte counter"}, - {"tca0.per", 0x0a26, 2, -1, -1, "period register (16 bits)"}, - {"tca0.lper", 0x0a26, 1, -1, -1, "low byte period register"}, - {"tca0.hper", 0x0a27, 1, -1, -1, "high byte period register"}, - {"tca0.cmp0", 0x0a28, 2, -1, -1, "compare 0 register (16 bits)"}, - {"tca0.lcmp0", 0x0a28, 1, -1, -1, "low byte compare register"}, - {"tca0.hcmp0", 0x0a29, 1, -1, -1, "high byte compare register 0"}, - {"tca0.cmp1", 0x0a2a, 2, -1, -1, "compare 1 register (16 bits)"}, - {"tca0.lcmp1", 0x0a2a, 1, -1, -1, "low byte compare register"}, - {"tca0.hcmp1", 0x0a2b, 1, -1, -1, "high byte compare register 1"}, - {"tca0.cmp2", 0x0a2c, 2, -1, -1, "compare 2 register (16 bits)"}, - {"tca0.lcmp2", 0x0a2c, 1, -1, -1, "low byte compare register"}, - {"tca0.hcmp2", 0x0a2d, 1, -1, -1, "high byte compare register 2"}, - {"tca0.perbuf", 0x0a36, 2, -1, -1, "period buffer register (16 bits)"}, - {"tca0.cmp0buf", 0x0a38, 2, -1, -1, "compare 0 buffer register (16 bits)"}, - {"tca0.cmp1buf", 0x0a3a, 2, -1, -1, "compare 1 buffer register (16 bits)"}, - {"tca0.cmp2buf", 0x0a3c, 2, -1, -1, "compare 2 buffer register (16 bits)"}, - {"tcb0.ctrla", 0x0b00, 1, -1, 0x00, "control register A"}, - {"tcb0.ctrlb", 0x0b01, 1, -1, 0x00, "control register B"}, - {"tcb0.evctrl", 0x0b04, 1, -1, 0x00, "event control register"}, - {"tcb0.intctrl", 0x0b05, 1, -1, 0x00, "interrupt control register"}, - {"tcb0.intflags", 0x0b06, 1, -1, 0x00, "interrupt flags register"}, - {"tcb0.status", 0x0b07, 1, -1, 0x00, "status register"}, - {"tcb0.dbgctrl", 0x0b08, 1, -1, 0x00, "debug control register"}, - {"tcb0.temp", 0x0b09, 1, -1, -1, "temporary register for 16-bit access"}, - {"tcb0.cnt", 0x0b0a, 2, -1, 0x0000, "counter (16 bits)"}, - {"tcb0.ccmp", 0x0b0c, 2, -1, -1, "compare or capture register (16 bits)"}, - {"tcb1.ctrla", 0x0b10, 1, -1, 0x00, "control register A"}, - {"tcb1.ctrlb", 0x0b11, 1, -1, 0x00, "control register B"}, - {"tcb1.evctrl", 0x0b14, 1, -1, 0x00, "event control register"}, - {"tcb1.intctrl", 0x0b15, 1, -1, 0x00, "interrupt control register"}, - {"tcb1.intflags", 0x0b16, 1, -1, 0x00, "interrupt flags register"}, - {"tcb1.status", 0x0b17, 1, -1, 0x00, "status register"}, - {"tcb1.dbgctrl", 0x0b18, 1, -1, 0x00, "debug control register"}, - {"tcb1.temp", 0x0b19, 1, -1, -1, "temporary register for 16-bit access"}, - {"tcb1.cnt", 0x0b1a, 2, -1, 0x0000, "counter (16 bits)"}, - {"tcb1.ccmp", 0x0b1c, 2, -1, -1, "compare or capture register (16 bits)"}, - {"usb0.ctrla", 0x0c00, 1, -1, 0x00, "control register A"}, - {"usb0.ctrlb", 0x0c01, 1, -1, 0x00, "control register B"}, - {"usb0.busstate", 0x0c02, 1, -1, 0x00, "bus state register"}, - {"usb0.addr", 0x0c03, 1, -1, 0x00, "address register"}, - {"usb0.fifowp", 0x0c04, 1, -1, 0xff, "FIFO write pointer register"}, - {"usb0.fiforp", 0x0c05, 1, -1, 0xff, "FIFO read pointer register"}, - {"usb0.epptr", 0x0c06, 2, -1, 0x0000, "endpoint configuration table pointer register (16 bits)"}, - {"usb0.intctrla", 0x0c08, 1, -1, 0x00, "interrupt control register A"}, - {"usb0.intctrlb", 0x0c09, 1, -1, 0x00, "interrupt control register B"}, - {"usb0.intflagsa", 0x0c0a, 1, -1, 0x00, "interrupt flags A register"}, - {"usb0.intflagsb", 0x0c0b, 1, -1, 0x00, "interrupt flags B register"}, - {"usb.status.outclr", 0x0c40, 1, -1, 0x00, "endpoint n OUT status clear register"}, - {"usb.status.outset", 0x0c41, 1, -1, 0x00, "endpoint n OUT status set register"}, - {"usb.status.inclr", 0x0c42, 1, -1, 0x00, "endpoint n IN status clear register"}, - {"usb.status.inset", 0x0c43, 1, -1, 0x00, "endpoint n IN status set register"}, - {"syscfg.revid", 0x0f01, 1, -1, -1, "revision ID register"}, - {"syscfg.vusbctrl", 0x0f06, 1, -1, 0x00, "USB voltage system control register"}, - {"nvmctrl.ctrla", 0x1000, 1, -1, 0x00, "control register A"}, - {"nvmctrl.ctrlb", 0x1001, 1, -1, 0x30, "control register B"}, - {"nvmctrl.ctrlc", 0x1002, 1, -1, 0x00, "control register C"}, - {"nvmctrl.intctrl", 0x1004, 1, -1, 0x00, "interrupt control register"}, - {"nvmctrl.intflags", 0x1005, 1, -1, 0x00, "interrupt flags register"}, - {"nvmctrl.status", 0x1006, 1, -1, 0x00, "status register"}, - {"nvmctrl.data", 0x1008, 4, -1, 0x00000000, "data register (32 bits)"}, - {"nvmctrl.addr", 0x100c, 4, -1, -1, "address register (32 bits)"}, -}; - // AVR64DA32 AVR128DA32 const Register_file_t rgftab_avr64da32[448] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index 95d61279..fbfb56f2 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -12,7 +12,7 @@ * Meta-author Stefan Rueger * * v 1.3 - * 13.04.2024 + * 08.05.2024 * */ @@ -82,7 +82,7 @@ typedef struct { // Value of -1 typically means unknown #define UB_N_MCU 2040 // mcuid is in 0..2039 -extern const uPcore_t uP_table[386]; +extern const uPcore_t uP_table[394]; // MCU id: running number in arbitrary order; once assigned never change for backward compatibility @@ -425,25 +425,33 @@ extern const uPcore_t uP_table[386]; #define id_avr8ea28 327u #define id_avr8ea32 328u #define id_avr16dd14 329u +#define id_avr16du14 386u #define id_avr16eb14 380u #define id_avr16dd20 330u +#define id_avr16du20 387u #define id_avr16eb20 381u #define id_avr16dd28 331u +#define id_avr16du28 388u #define id_avr16ea28 332u #define id_avr16eb28 382u #define id_avr16dd32 333u +#define id_avr16du32 389u #define id_avr16ea32 334u #define id_avr16eb32 383u #define id_avr16ea48 335u #define id_avr32dd14 336u +#define id_avr32du14 390u #define id_avr32dd20 337u +#define id_avr32du20 391u #define id_avr32da28 338u #define id_avr32db28 339u #define id_avr32dd28 340u +#define id_avr32du28 392u #define id_avr32ea28 341u #define id_avr32da32 342u #define id_avr32db32 343u #define id_avr32dd32 344u +#define id_avr32du32 393u #define id_avr32ea32 345u #define id_avr32da48 346u #define id_avr32db48 347u @@ -797,25 +805,33 @@ extern const uPcore_t uP_table[386]; #define vts_atmega4808 36 #define vts_atmega4809 40 #define vts_avr16dd14 36 +#define vts_avr16du14 34 #define vts_avr16eb14 31 #define vts_avr16dd20 36 +#define vts_avr16du20 34 #define vts_avr16eb20 31 #define vts_avr16dd28 36 +#define vts_avr16du28 34 #define vts_avr16ea28 37 #define vts_avr16eb28 31 #define vts_avr16dd32 36 +#define vts_avr16du32 34 #define vts_avr16ea32 37 #define vts_avr16eb32 31 #define vts_avr16ea48 45 #define vts_avr32dd14 36 +#define vts_avr32du14 34 #define vts_avr32dd20 36 +#define vts_avr32du20 34 #define vts_avr32da28 41 #define vts_avr32db28 42 #define vts_avr32dd28 36 +#define vts_avr32du28 34 #define vts_avr32ea28 37 #define vts_avr32da32 44 #define vts_avr32db32 44 #define vts_avr32dd32 36 +#define vts_avr32du32 34 #define vts_avr32ea32 37 #define vts_avr32da48 58 #define vts_avr32db48 61 @@ -1169,25 +1185,33 @@ extern const uPcore_t uP_table[386]; #define vbu_atmega4808 36 #define vbu_atmega4809 40 #define vbu_avr16dd14 36 +#define vbu_avr16du14 34 #define vbu_avr16eb14 31 #define vbu_avr16dd20 36 +#define vbu_avr16du20 34 #define vbu_avr16eb20 31 #define vbu_avr16dd28 36 +#define vbu_avr16du28 34 #define vbu_avr16ea28 37 #define vbu_avr16eb28 31 #define vbu_avr16dd32 36 +#define vbu_avr16du32 34 #define vbu_avr16ea32 37 #define vbu_avr16eb32 31 #define vbu_avr16ea48 45 #define vbu_avr32dd14 36 +#define vbu_avr32du14 34 #define vbu_avr32dd20 36 +#define vbu_avr32du20 34 #define vbu_avr32da28 41 #define vbu_avr32db28 42 #define vbu_avr32dd28 36 +#define vbu_avr32du28 34 #define vbu_avr32ea28 37 #define vbu_avr32da32 41 #define vbu_avr32db32 44 #define vbu_avr32dd32 36 +#define vbu_avr32du32 34 #define vbu_avr32ea32 37 #define vbu_avr32da48 58 #define vbu_avr32db48 59 @@ -1669,6 +1693,14 @@ extern const char * const vtab_avr64dd32[36]; extern const char * const vtab_avr64du32[34]; #define vtab_avr64du28 vtab_avr64du32 +#define vtab_avr32du32 vtab_avr64du32 +#define vtab_avr32du28 vtab_avr64du32 +#define vtab_avr32du20 vtab_avr64du32 +#define vtab_avr32du14 vtab_avr64du32 +#define vtab_avr16du32 vtab_avr64du32 +#define vtab_avr16du28 vtab_avr64du32 +#define vtab_avr16du20 vtab_avr64du32 +#define vtab_avr16du14 vtab_avr64du32 extern const char * const vtab_avr64ea32[37]; #define vtab_avr64ea28 vtab_avr64ea32 @@ -2167,6 +2199,17 @@ extern const Configitem_t cfgtab_atmega808[15]; #define cfgtab_atmega4808 cfgtab_atmega808 #define cfgtab_atmega4809 cfgtab_atmega808 +extern const Configitem_t cfgtab_avr16du14[20]; +#define cfgtab_avr16du20 cfgtab_avr16du14 +#define cfgtab_avr16du28 cfgtab_avr16du14 +#define cfgtab_avr16du32 cfgtab_avr16du14 +#define cfgtab_avr32du14 cfgtab_avr16du14 +#define cfgtab_avr32du20 cfgtab_avr16du14 +#define cfgtab_avr32du28 cfgtab_avr16du14 +#define cfgtab_avr32du32 cfgtab_avr16du14 +#define cfgtab_avr64du28 cfgtab_avr16du14 +#define cfgtab_avr64du32 cfgtab_avr16du14 + extern const Configitem_t cfgtab_avr16eb14[18]; #define cfgtab_avr16eb20 cfgtab_avr16eb14 #define cfgtab_avr16eb28 cfgtab_avr16eb14 @@ -2196,9 +2239,6 @@ extern const Configitem_t cfgtab_avr32db28[16]; #define cfgtab_avr128db48 cfgtab_avr32db28 #define cfgtab_avr128db64 cfgtab_avr32db28 -extern const Configitem_t cfgtab_avr64du28[20]; -#define cfgtab_avr64du32 cfgtab_avr64du28 - // I/O Register files extern const Register_file_t rgftab_atmega328[81]; @@ -2654,8 +2694,20 @@ extern const Register_file_t rgftab_atmega3208[406]; extern const Register_file_t rgftab_atmega3209[432]; #define rgftab_atmega4809 rgftab_atmega3209 +extern const Register_file_t rgftab_avr16du14[371]; +#define rgftab_avr32du14 rgftab_avr16du14 + extern const Register_file_t rgftab_avr16eb14[391]; +extern const Register_file_t rgftab_avr16du20[372]; +#define rgftab_avr16du28 rgftab_avr16du20 +#define rgftab_avr16du32 rgftab_avr16du20 +#define rgftab_avr32du20 rgftab_avr16du20 +#define rgftab_avr32du28 rgftab_avr16du20 +#define rgftab_avr32du32 rgftab_avr16du20 +#define rgftab_avr64du28 rgftab_avr16du20 +#define rgftab_avr64du32 rgftab_avr16du20 + extern const Register_file_t rgftab_avr16eb20[393]; #define rgftab_avr16eb28 rgftab_avr16eb20 #define rgftab_avr16eb32 rgftab_avr16eb20 @@ -2688,9 +2740,6 @@ extern const Register_file_t rgftab_avr32db48[643]; extern const Register_file_t rgftab_avr64da28[433]; #define rgftab_avr128da28 rgftab_avr64da28 -extern const Register_file_t rgftab_avr64du28[372]; -#define rgftab_avr64du32 rgftab_avr64du28 - extern const Register_file_t rgftab_avr64da32[448]; #define rgftab_avr128da32 rgftab_avr64da32 From d8d47127d9fcede90fa6f18d6d0efe9e68ad2c89 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 8 May 2024 19:01:00 +0100 Subject: [PATCH 018/422] Update avrdude.conf with new AVRnnDUnn parts --- src/avrdude.conf.in | 126 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 10513680..48d68769 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -24411,6 +24411,132 @@ part parent "64du28" # 64du32 signature = 0x1e 0x96 0x21; ; +#------------------------------------------------------------ +# AVR16DU14 +#------------------------------------------------------------ + +part parent "64du28" # 16du14 + desc = "AVR16DU14"; + id = "16du14"; + variants = + "AVR16DU14-SOIC: DIP14, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 386; + signature = 0x1e 0x94 0x3b; + + memory "flash" + size = 0x4000; + ; + + memory "sram" + size = 2048; + offset = 0x7800; + ; +; + +#------------------------------------------------------------ +# AVR16DU20 +#------------------------------------------------------------ + +part parent "16du14" # 16du20 + desc = "AVR16DU20"; + id = "16du20"; + variants = + "AVR16DU20-SSOP: DIP20, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "AVR16DU20-VQFN: QFP20, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 387; + signature = 0x1e 0x94 0x3a; +; + +#------------------------------------------------------------ +# AVR16DU28 +#------------------------------------------------------------ + +part parent "16du14" # 16du28 + desc = "AVR16DU28"; + id = "16du28"; + variants = + "AVR16DU28-SSOP/SPDIP: DIP28, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "AVR16DU28-VQFN: QFP28, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 388; + signature = 0x1e 0x94 0x39; +; + +#------------------------------------------------------------ +# AVR16DU32 +#------------------------------------------------------------ + +part parent "16du14" # 16du32 + desc = "AVR16DU32"; + id = "16du32"; + variants = + "AVR16DU32-VQFN/TQFP: QFP32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 389; + signature = 0x1e 0x94 0x38; +; + +#------------------------------------------------------------ +# AVR32DU14 +#------------------------------------------------------------ + +part parent "64du28" # 32du14 + desc = "AVR32DU14"; + id = "32du14"; + variants = + "AVR32DU14-SOIC: DIP14, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 390; + signature = 0x1e 0x95 0x4f; + + memory "flash" + size = 0x8000; + ; + + memory "sram" + size = 4096; + offset = 0x7000; + ; +; + +#------------------------------------------------------------ +# AVR32DU20 +#------------------------------------------------------------ + +part parent "32du14" # 32du20 + desc = "AVR32DU20"; + id = "32du20"; + variants = + "AVR32DU20-SSOP: DIP20, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "AVR32DU20-VQFN: QFP20, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 391; + signature = 0x1e 0x95 0x4e; +; + +#------------------------------------------------------------ +# AVR32DU28 +#------------------------------------------------------------ + +part parent "32du14" # 32du28 + desc = "AVR32DU28"; + id = "32du28"; + variants = + "AVR32DU28-SSOP/SPDIP: DIP28, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "AVR32DU28-VQFN: QFP28, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 392; + signature = 0x1e 0x95 0x40; +; + +#------------------------------------------------------------ +# AVR32DU32 +#------------------------------------------------------------ + +part parent "32du14" # 32du32 + desc = "AVR32DU32"; + id = "32du32"; + variants = + "AVR32DU32-VQFN/TQFP: QFP32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 393; + signature = 0x1e 0x95 0x3f; +; + #------------------------------------------------------------ # AVR-Ex family common values #------------------------------------------------------------ From d425e737a46a07caacba91f3e2d901a6e5c792cf Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 8 May 2024 19:58:07 +0100 Subject: [PATCH 019/422] Remove static variable in winconf.c --- src/confwin.c | 24 +++++------------------- src/libavrdude.h | 3 +-- src/main.c | 4 ++-- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/confwin.c b/src/confwin.c index e7f11364..c5322cea 100644 --- a/src/confwin.c +++ b/src/confwin.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Eric B. Weddington + * Copyright (C) 2024 Stefan Rueger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,24 +27,10 @@ #define WIN32_LEAN_AND_MEAN #include -static char *filename; - -void win_sys_config_set(char sys_config[PATH_MAX]) -{ - sys_config[0] = 0; - - /* Use Windows API call to search for the Windows default system config file.*/ - SearchPath(NULL, SYSTEM_CONF_FILE, NULL, PATH_MAX, sys_config, &filename); - return; -} - -void win_usr_config_set(char usr_config[PATH_MAX]) -{ - usr_config[0] = 0; - - /* Use Windows API call to search for the Windows default user config file. */ - SearchPath(NULL, USER_CONF_FILE, NULL, PATH_MAX, usr_config, &filename); - return; +// Store the full path of a file using a registry-dependent system search path +int win_set_path(char *path, int n, const char *file) { + *path = 0; + return SearchPath(NULL, file, NULL, n, path, NULL); } #endif diff --git a/src/libavrdude.h b/src/libavrdude.h index 11c8278a..c288b14a 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1581,8 +1581,7 @@ extern cx_t *cx; extern "C" { #endif -void win_sys_config_set(char sys_config[PATH_MAX]); -void win_usr_config_set(char usr_config[PATH_MAX]); +int win_set_path(char *path, int n, const char *file); #ifdef __cplusplus } diff --git a/src/main.c b/src/main.c index e65088c9..313fcdf9 100644 --- a/src/main.c +++ b/src/main.c @@ -750,7 +750,7 @@ int main(int argc, char * argv []) // Determine the location of personal configuration file #if defined(WIN32) - win_usr_config_set(usr_config); + win_set_path(usr_config, sizeof usr_config, USER_CONF_FILE); #else usr_config[0] = 0; if(!concatpath(usr_config, getenv("XDG_CONFIG_HOME"), XDG_USER_CONF_FILE, sizeof usr_config)) @@ -1024,7 +1024,7 @@ int main(int argc, char * argv []) if (!sys_config_found) { // 3. Check CONFIG_DIR/avrdude.conf #if defined(WIN32) - win_sys_config_set(sys_config); + win_set_path(sys_config, sizeof sys_config, SYSTEM_CONF_FILE); #else strcpy(sys_config, CONFIG_DIR); i = strlen(sys_config); From 161f763507ecb8ca1e16c8c6f92584d15387338b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 8 May 2024 22:10:06 +0100 Subject: [PATCH 020/422] Consolidate functions returning a prog_modes string --- src/avr.c | 84 ++++++++++++++++++++++++-------------------- src/avrpart.c | 2 +- src/developer_opts.c | 43 ++--------------------- src/libavrdude.h | 3 +- src/term.c | 2 +- 5 files changed, 51 insertions(+), 83 deletions(-) diff --git a/src/avr.c b/src/avr.c index 61c8872e..039e488e 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1443,10 +1443,12 @@ int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles) { /* - * Returns a string in closed-circuit space with a comma-separated list of - * programming modes; variant creates the list in subtly different way - * - 0: PM_SPM prints bootloader, pm == 0 prints "?" - * - 1: PM_SPM prints SPM, pm == 0 prints "0" + * Returns a string in closed-circuit space with a list of programming + * modes encoded in pm; variant creates the list in subtly different ways: + * - variants == 0: PM_SPM prints bootloader + * - variants == 1: PM_SPM prints SPM + * - variants == 2: rather than a comma-separated list it's | PM_... separated + * If pm is 0 (no programming modes) returns "0" */ static char *prog_modes_string(int pm, int variant) { // Return string is overwritten after a few calls @@ -1457,48 +1459,52 @@ static char *prog_modes_string(int pm, int variant) { if((size_t) (type - cx->avr_space) > sizeof cx->avr_space - 128) type = cx->avr_space; - strcpy(type, variant? "0": "?"); - if(variant == 0 && (pm & PM_SPM)) - strcat(type, ", bootloader"); - if(pm & PM_TPI) - strcat(type, ", TPI"); - if(pm & PM_ISP) - strcat(type, ", ISP"); - if(pm & PM_PDI) - strcat(type, ", PDI"); - if(pm & PM_UPDI) - strcat(type, ", UPDI"); - if(pm & PM_HVSP) - strcat(type, ", HVSP"); - if(pm & PM_HVPP) - strcat(type, ", HVPP"); - if(pm & PM_debugWIRE) - strcat(type, ", debugWIRE"); - if(pm & PM_JTAG) - strcat(type, ", JTAG"); - if(pm & PM_JTAGmkI) - strcat(type, ", JTAGmkI"); - if(pm & PM_XMEGAJTAG) - strcat(type, ", XMEGAJTAG"); - if(pm & PM_AVR32JTAG) - strcat(type, ", AVR32JTAG"); - if(pm & PM_aWire) - strcat(type, ", aWire"); - if(variant == 1 && (pm & PM_SPM)) - strcat(type, ", SPM"); + const char *spm = variant? "SPM": "bootloader"; + const char *sep = variant == 2? " | PM_": ", "; + int skip = 3 + (variant == 2); - cx->avr_s = type + (type[1] == 0? 0: 3); + strcpy(type, "0"); + if(pm & PM_SPM) + strcat(strcat(type, sep), spm); + if(pm & PM_TPI) + strcat(strcat(type, sep), "TPI"); + if(pm & PM_ISP) + strcat(strcat(type, sep), "ISP"); + if(pm & PM_PDI) + strcat(strcat(type, sep), "PDI"); + if(pm & PM_UPDI) + strcat(strcat(type, sep), "UPDI"); + if(pm & PM_HVSP) + strcat(strcat(type, sep), "HVSP"); + if(pm & PM_HVPP) + strcat(strcat(type, sep), "HVPP"); + if(pm & PM_debugWIRE) + strcat(strcat(type, sep), "debugWIRE"); + if(pm & PM_JTAG) + strcat(strcat(type, sep), "JTAG"); + if(pm & PM_JTAGmkI) + strcat(strcat(type, sep), "JTAGmkI"); + if(pm & PM_XMEGAJTAG) + strcat(strcat(type, sep), "XMEGAJTAG"); + if(pm & PM_AVR32JTAG) + strcat(strcat(type, sep), "AVR32JTAG"); + if(pm & PM_aWire) + strcat(strcat(type, sep), "aWire"); + + cx->avr_s = type + (type[1] == 0? 0: skip); return cx->avr_s; } -// Returns a string in closed-circuit space with list of programming modes or "0" -char *avr_prog_modes_str(int pm) { +char *avr_prog_modes(int pm) { // PM_SPM prints bootloader + return prog_modes_string(pm, 0); +} + +char *str_prog_modes(int pm) { // PM_SPM prints SPM return prog_modes_string(pm, 1); } -// Returns a string in closed-circuit space with list of programming modes or "?" -char *avr_prog_modes(int pm) { - return prog_modes_string(pm, 0); +char *dev_prog_modes(int pm) { // Symbolic C code of prog_modes + return prog_modes_string(pm, 2); } diff --git a/src/avrpart.c b/src/avrpart.c index c4023843..779a803a 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -1086,7 +1086,7 @@ void sort_avrparts(LISTID avrparts) void avr_display(FILE *f, const AVRPART *p, const char *prefix, int verbose) { fprintf(f, "%sAVR Part : %s\n", prefix, p->desc); - fprintf(f, "%sProgramming modes : %s\n", prefix, avr_prog_modes_str(p->prog_modes)); + fprintf(f, "%sProgramming modes : %s\n", prefix, str_prog_modes(p->prog_modes)); if(verbose > 1) { avr_mem_display(f, p, prefix); diff --git a/src/developer_opts.c b/src/developer_opts.c index 3d28bc61..a155dfd2 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -133,43 +133,6 @@ static void printallopcodes(const AVRPART *p, const char *d, OPCODE * const *opa } - -// Programming modes - -static char *prog_modes_str(int pm) { - static char type[1024]; - - strcpy(type, "0"); - if(pm & PM_SPM) - strcat(type, " | PM_SPM"); - if(pm & PM_TPI) - strcat(type, " | PM_TPI"); - if(pm & PM_ISP) - strcat(type, " | PM_ISP"); - if(pm & PM_PDI) - strcat(type, " | PM_PDI"); - if(pm & PM_UPDI) - strcat(type, " | PM_UPDI"); - if(pm & PM_HVSP) - strcat(type, " | PM_HVSP"); - if(pm & PM_HVPP) - strcat(type, " | PM_HVPP"); - if(pm & PM_debugWIRE) - strcat(type, " | PM_debugWIRE"); - if(pm & PM_JTAG) - strcat(type, " | PM_JTAG"); - if(pm & PM_JTAGmkI) - strcat(type, " | PM_JTAGmkI"); - if(pm & PM_XMEGAJTAG) - strcat(type, " | PM_XMEGAJTAG"); - if(pm & PM_AVR32JTAG) - strcat(type, " | PM_AVR32JTAG"); - if(pm & PM_aWire) - strcat(type, " | PM_aWire"); - - return type + (type[1] == 0? 0: 4); -} - static char *extra_features_str(int m) { static char mode[1024]; @@ -620,7 +583,7 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool } _if_partout_str(strcmp, cfg_escape(p->family_id), family_id); - _if_partout_str(intcmp, mmt_strdup(prog_modes_str(p->prog_modes)), prog_modes); + _if_partout_str(intcmp, mmt_strdup(dev_prog_modes(p->prog_modes)), prog_modes); if(p->mcuid == 21) { _if_partout_str(intcmp, mmt_strdup("XVII + IV"), mcuid); } else { @@ -1124,7 +1087,7 @@ void dev_output_part_defs(char *partdesc) { nfuses, ok, p->flags, - prog_modes_str(p->prog_modes), + dev_prog_modes(p->prog_modes), p->config_file, p->lineno ); } @@ -1318,7 +1281,7 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas _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)); - _if_pgmout_str(intcmp, mmt_strdup(prog_modes_str(pgm->prog_modes)), prog_modes); + _if_pgmout_str(intcmp, mmt_strdup(dev_prog_modes(pgm->prog_modes)), prog_modes); _if_pgmout_str(boolcmp, mmt_strdup(pgm->is_serialadapter? "yes": "no"), is_serialadapter); _if_pgmout_str(intcmp, mmt_strdup(extra_features_str(pgm->extra_features)), extra_features); if(!base || base->conntype != pgm->conntype) diff --git a/src/libavrdude.h b/src/libavrdude.h index c288b14a..bd1f1169 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -573,8 +573,7 @@ AVRPART * locate_part(const LISTID parts, const char *partdesc); AVRPART * locate_part_by_avr910_devcode(const LISTID parts, int devcode); AVRPART * locate_part_by_signature(const LISTID parts, unsigned char *sig, int sigsize); AVRPART * locate_part_by_signature_pm(const LISTID parts, unsigned char *sig, int sigsize, int prog_modes); -char *avr_prog_modes(int pm); -char *avr_prog_modes_str(int pm); +char *avr_prog_modes(int pm), *str_prog_modes(int pm), *dev_prog_modes(int pm); void avr_display(FILE *f, const AVRPART *p, const char *prefix, int verbose); int avr_variants_display(FILE *f, const AVRPART *p, const char *prefix); diff --git a/src/term.c b/src/term.c index 4ee0bc73..d39d7850 100644 --- a/src/term.c +++ b/src/term.c @@ -1890,7 +1890,7 @@ static int cmd_part(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha else if(onlyvariants) avr_variants_display(stdout, p, ""); else { - term_out("%s with programming modes %s\n", p->desc, avr_prog_modes_str(p->prog_modes)); + term_out("%s with programming modes %s\n", p->desc, str_prog_modes(p->prog_modes)); avr_mem_display(stdout, p, ""); avr_variants_display(stdout, p, ""); } From 0c565354aa4f2d5bf475197e535f36f745764d8a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 8 May 2024 22:23:24 +0100 Subject: [PATCH 021/422] Make two static structs read-only in developer_opts.c --- src/developer_opts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index a155dfd2..d3b6d9a6 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -59,14 +59,14 @@ // - Output again with -p*/s or -c*/s (no /i) and use that for final avrdude.conf // - Remove entries from below tables -static struct { +static const struct { const char *pgmid, *var, *value; } pgminj[] = { // Add triples here, eg, {"stk500v2", "prog_modes", "PM_TPI|PM_ISP"}, {NULL, NULL, NULL}, }; -static struct { +static const struct { const char *mcu, *var, *value; } ptinj[] = { // Add triples here, eg, {"ATmega328P", "mcuid", "999"}, From 6d8fce594c7bb474468b88f358f76ece1ca93e44 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 8 May 2024 22:32:27 +0100 Subject: [PATCH 022/422] Put static variable of dfu.c into context structure --- src/dfu.c | 10 ++++------ src/libavrdude.h | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/dfu.c b/src/dfu.c index bfc6bdf2..c83145a6 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -88,8 +88,6 @@ int dfu_upload(struct dfu_dev *dfu, void * ptr, int size) { * is sent to the device. */ -static uint16_t wIndex = 0; - /* INTERNAL FUNCTION PROTOTYPES */ @@ -325,10 +323,10 @@ int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size) int result; pmsg_trace("dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n", - wIndex, ptr, size); + cx->dfu_wIndex, ptr, size); result = usb_control_msg(dfu->dev_handle, - USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_DNLOAD, wIndex++, 0, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_DNLOAD, cx->dfu_wIndex++, 0, ptr, size, dfu->timeout); if (result < 0) { @@ -354,10 +352,10 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size) int result; pmsg_trace("dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n", - wIndex, ptr, size); + cx->dfu_wIndex, ptr, size); result = usb_control_msg(dfu->dev_handle, - 0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_UPLOAD, wIndex++, 0, + 0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_UPLOAD, cx->dfu_wIndex++, 0, ptr, size, dfu->timeout); if (result < 0) { diff --git a/src/libavrdude.h b/src/libavrdude.h index bd1f1169..f0d851ed 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1568,6 +1568,9 @@ typedef struct { LISTID cfg_pushedcomms; // Temporarily pushed main comments int cfg_pushed; // ... for memory sections int cfg_init_search; // used in cfg_comp_search() + + // Static variable from dfu.c + uint16_t dfu_wIndex; // A running number for USB messages } cx_t; extern cx_t *cx; From b25c28aea78ec864cb2eadbc5758e1b59edbd5f5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 9 May 2024 10:49:40 +0100 Subject: [PATCH 023/422] Guard against out-of-range pin_name in config_gram.y --- src/config_gram.y | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config_gram.y b/src/config_gram.y index 1cac8e58..1d345c4b 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -549,7 +549,10 @@ pin_number_non_empty: pin_number: pin_number_non_empty | - /* empty */ { pin_clear_all(&(current_prog->pin[pin_name])); } + /* empty */ { + if(pin_name >= 0 && pin_name < N_PINS) + pin_clear_all(&(current_prog->pin[pin_name])); + } ; pin_list_element: @@ -568,7 +571,10 @@ pin_list_non_empty: pin_list: pin_list_non_empty | - /* empty */ { pin_clear_all(&(current_prog->pin[pin_name])); } + /* empty */ { + if(pin_name >= 0 && pin_name < N_PINS) + pin_clear_all(&(current_prog->pin[pin_name])); + } ; prog_parm_pins: From fb1a63b1897679a5133547affc0f21d9705bd269 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 9 May 2024 10:58:08 +0100 Subject: [PATCH 024/422] Add author to config_gram.y for contributions from 2022 --- src/config_gram.y | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config_gram.y b/src/config_gram.y index 1d345c4b..1a9650eb 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -2,6 +2,7 @@ * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2006 Joerg Wunsch + * Copyright (C) 2022- Stefan Rueger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From c2264ad5a99c361e60728e7cf0cdf5b4c05d33c4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 9 May 2024 11:05:35 +0100 Subject: [PATCH 025/422] Put static variable of config_gram.y into context structure --- src/config_gram.y | 2 +- src/libavrdude.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/config_gram.y b/src/config_gram.y index 1a9650eb..99732fa5 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -51,7 +51,7 @@ static int assign_pin_list(int invert); static int which_opcode(TOKEN * opcode); static int parse_cmdbits(OPCODE * op, int opnum); -static int pin_name; +#define pin_name (cx->cfgy_pin_name) %} %token K_NULL; diff --git a/src/libavrdude.h b/src/libavrdude.h index f0d851ed..d121c8c1 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1571,6 +1571,9 @@ typedef struct { // Static variable from dfu.c uint16_t dfu_wIndex; // A running number for USB messages + + // Static variable from config_gram.y + int cfgy_pin_name; // Temporary variable for grammar parsing } cx_t; extern cx_t *cx; From bf414c7c58d4f3420dccd4135fe334fc1a8b9c33 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 9 May 2024 11:06:50 +0100 Subject: [PATCH 026/422] Make static function greppable in fileio.c --- src/fileio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 694af668..e461c9c8 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -740,8 +740,7 @@ static int srec2b(const char *infile, FILE * inf, * the entire ELF file "as is" (including things like the program * header table itself). */ -static inline -int is_section_in_segment(Elf32_Shdr *sh, Elf32_Phdr *ph) +static inline int is_section_in_segment(Elf32_Shdr *sh, Elf32_Phdr *ph) { if (sh->sh_offset < ph->p_offset) return 0; From e6503115f7b6bfd59a354610bf503ded00434f28 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 9 May 2024 17:25:38 +0100 Subject: [PATCH 027/422] Use pins_to_strdup() instead of pins_to_str() The latter returns a string in a static buffer that is overwritten by the next call. Unfortunately, this function was used more than once in arguments of the *same* msg_error(), which would have given a wrong error message. pins_to_strdup() returns a string to malloc'd space that needs freeing. --- src/avrftdi.c | 27 ++++++++++++++++----------- src/pgm.c | 34 ++++++---------------------------- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index 29d6fb6a..f48eafaa 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -601,21 +601,26 @@ static int avrftdi_pin_setup(const PROGRAMMER *pgm) { avrftdi_check_pins_bb(pgm, true); imsg_error("pin configuration for FTDI MPSSE must be:\n"); if (pgm->flag == PGM_FL_IS_JTAG) { - imsg_error("%s: 0, %s: 1, %s: 2, %s :3 (is: %s, %s, %s, %s)\n", + char *ptck = pins_to_strdup(&pgm->pin[PIN_JTAG_TCK]), + *ptdi = pins_to_strdup(&pgm->pin[PIN_JTAG_TDI]), + *ptdo = pins_to_strdup(&pgm->pin[PIN_JTAG_TDO]), + *ptms = pins_to_strdup(&pgm->pin[PIN_JTAG_TMS]); + imsg_error("%s: 0; %s: 1; %s: 2; %s: 3 (is: %s; %s; %s; %s)\n", avr_pin_name(PIN_JTAG_TCK), avr_pin_name(PIN_JTAG_TDI), avr_pin_name(PIN_JTAG_TDO), avr_pin_name(PIN_JTAG_TMS), - pins_to_str(&pgm->pin[PIN_JTAG_TCK]), - pins_to_str(&pgm->pin[PIN_JTAG_TDI]), - pins_to_str(&pgm->pin[PIN_JTAG_TDO]), - pins_to_str(&pgm->pin[PIN_JTAG_TMS])); + *ptck? ptck: "?", *ptdi? ptdi: "?", + *ptdo? ptdo: "?", *ptms? ptms: "?"); + free(ptck); free(ptdi); free(ptdo); free(ptms); } else { - imsg_error("%s: 0, %s: 1, %s: 2 (is: %s, %s, %s)\n", - avr_pin_name(PIN_AVR_SCK), - avr_pin_name(PIN_AVR_SDO), + char *psck = pins_to_strdup(&pgm->pin[PIN_AVR_SCK]), + *psdo = pins_to_strdup(&pgm->pin[PIN_AVR_SDO]), + *psdi = pins_to_strdup(&pgm->pin[PIN_AVR_SDI]); + imsg_error("%s: 0; %s: 1; %s: 2 (is: %s; %s; %s)\n", + avr_pin_name(PIN_AVR_SCK), avr_pin_name(PIN_AVR_SDO), avr_pin_name(PIN_AVR_SDI), - pins_to_str(&pgm->pin[PIN_AVR_SCK]), - pins_to_str(&pgm->pin[PIN_AVR_SDO]), - pins_to_str(&pgm->pin[PIN_AVR_SDI])); + *psck? psck: "?", *psdo? psdo: "?", + *psdi? psdi: "?"); + free(psck); free(psdo); free(psdi); } imsg_error("if other pin configuration is used, fallback to slower bitbanging mode is used\n"); diff --git a/src/pgm.c b/src/pgm.c index b2ea5045..dc8acf0e 100644 --- a/src/pgm.c +++ b/src/pgm.c @@ -287,34 +287,12 @@ void programmer_display(PROGRAMMER *pgm, const char * p) { void pgm_display_generic_mask(const PROGRAMMER *pgm, const char *p, unsigned int show) { - if(show & (1<pin[PPI_AVR_VCC])); - if(show & (1<pin[PPI_AVR_BUFF])); - if(show & (1<pin[PIN_AVR_RESET])); - if(show & (1<pin[PIN_AVR_SCK])); - if(show & (1<pin[PIN_AVR_SDO])); - if(show & (1<pin[PIN_AVR_SDI])); - if(show & (1<pin[PIN_JTAG_TCK])); - if(show & (1<pin[PIN_JTAG_TDI])); - if(show & (1<pin[PIN_JTAG_TDO])); - if(show & (1<pin[PIN_JTAG_TMS])); - if(show & (1<pin[PIN_LED_ERR])); - if(show & (1<pin[PIN_LED_RDY])); - if(show & (1<pin[PIN_LED_PGM])); - if(show & (1<pin[PIN_LED_VFY])); + for(int pbit = 1; pbit < N_PINS; pbit++) + if(show & (1<pin + pbit); + msg_info("%s %-6s = %s\n", p, avr_pin_name(pbit), *pinstr? pinstr: "(not used)"); + free(pinstr); + } } void pgm_display_generic(const PROGRAMMER *pgm, const char *p) { From c5c49d7efd96b556843cdf1e5f18379734b41296 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 9 May 2024 17:30:44 +0100 Subject: [PATCH 028/422] Remove unused function pin_to_str() ... as it was used wrongly and led to errors. Better to use pin_to_strdup() --- src/libavrdude.h | 9 --------- src/pindefs.c | 34 ---------------------------------- 2 files changed, 43 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index d121c8c1..ac3037d1 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -744,15 +744,6 @@ const char * avr_pin_name(int pinname); */ const char * avr_pin_lcname(int pinname); -/** - * This function returns a string of defined pins, eg, ~1,2,~4,~5,7 or " (not used)" - * Another execution of this function will overwrite the previous result in the static buffer. - * - * @param[in] pindef the pin definition for which we want the string representation - * @returns pointer to a static string. - */ -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 "" * diff --git a/src/pindefs.c b/src/pindefs.c index e71c92c8..4de9b9bd 100644 --- a/src/pindefs.c +++ b/src/pindefs.c @@ -315,40 +315,6 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const return rv; } -/** - * This function returns a string of defined pins, eg, ~1,2,~4,~5,7 or " (not used)" - * Another execution of this function will overwrite the previous result in the static buffer. - * - * @param[in] pindef the pin definition for which we want the string representation - * @returns pointer to a static string. - */ -const char * pins_to_str(const struct pindef_t * const pindef) { - static char buf[(PIN_MAX + 1) * 5]; // should be enough for PIN_MAX=255 - char *p = buf; - int n; - int pin; - const char * fmt; - - buf[0] = 0; - for(pin = PIN_MIN; pin <= PIN_MAX; pin++) { - int index = pin / PIN_FIELD_ELEMENT_SIZE; - int bit = pin % PIN_FIELD_ELEMENT_SIZE; - if(pindef->mask[index] & (1 << bit)) { - if(pindef->inverse[index] & (1 << bit)) { - fmt = (buf[0] == 0) ? "~%d" : ",~%d"; - } else { - fmt = (buf[0] == 0) ? " %d" : ",%d"; - } - n = sprintf(p, fmt, pin); - p += n; - } - } - - if(buf[0] == 0) - return " (not used)"; - - return buf; -} /** * This function returns a string of defined pins, eg, ~1, 2, ~4, ~5, 7 or "" From 4ccbf49f0f76c89ff389df339fcca440acd87668 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 9 May 2024 19:03:34 +0100 Subject: [PATCH 029/422] Change pinmask_to_str() to pinmask_to_strdup() No longer is the string returned in static space (which the next call overwrites); instead a mmt_strdup()'d string is returned that needs mmt_free()'ing. --- src/avrftdi.c | 9 +++++---- src/libavrdude.h | 11 +++++------ src/pindefs.c | 46 ++++++++++++++++++++++++---------------------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index f48eafaa..0faa6bb3 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -222,10 +222,11 @@ static int set_pin(const PROGRAMMER *pgm, int pinfunc, int value) { return 0; } - pmsg_debug("setting pin %s (%s) as %s: %s (%s active)\n", - pinmask_to_str(pin.mask), ftdi_pin_name(pdata, pin), - avr_pin_name(pinfunc), - (value) ? "high" : "low", (pin.inverse[0]) ? "low" : "high"); + char *pmsk = pinmask_to_strdup(pin.mask); + pmsg_debug("setting pin %s (%s) as %s: %s (%s active)\n", pmsk, + ftdi_pin_name(pdata, pin), avr_pin_name(pinfunc), + (value) ? "high" : "low", (pin.inverse[0]) ? "low" : "high"); + mmt_free(pmsk); pdata->pin_value = SET_BITS_0(pdata->pin_value, pgm, pinfunc, value); diff --git a/src/libavrdude.h b/src/libavrdude.h index ac3037d1..c53cf429 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -748,19 +748,18 @@ const char * avr_pin_lcname(int pinname); * 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 - * @returns a pointer to a string, which was created by strdup + * @returns a string that was created by mmt_strdup() */ char *pins_to_strdup(const struct pindef_t * const pindef); /** - * This function returns a string representation of pins in the mask, eg, 1,3,5-7,9,12 - * Another execution of this function will overwrite the previous result in the static buffer. - * Consecutive pin number are represented as start-end. + * This function returns a string representation of pins in the mask, eg, 1, 3, 5-7, 9, 12 + * Consecutive pin numbers are represented as start-end. * * @param[in] pinmask the pin mask for which we want the string representation - * @returns pointer to a static string. + * @returns a string that was created by mmt_strdup() */ -const char * pinmask_to_str(const pinmask_t * const pinmask); +char *pinmask_to_strdup(const pinmask_t * const pinmask); /* formerly serial.h */ diff --git a/src/pindefs.c b/src/pindefs.c index 4de9b9bd..5548a7b0 100644 --- a/src/pindefs.c +++ b/src/pindefs.c @@ -152,19 +152,17 @@ int pgm_fill_old_pins(PROGRAMMER * const pgm) { } /** - * This function returns a string representation of pins in the mask eg. 1,3,5-7,9,12 - * Another execution of this function will overwrite the previous result in the static buffer. - * Consecutive pin number are represented as start-end. + * This function returns a string representation of pins in the mask eg. 1, 3, 5-7, 9, 12 + * Consecutive pin numbers are represented as start-end. * * @param[in] pinmask the pin mask for which we want the string representation - * @returns pointer to a static string. + * @returns a string that was created by mmt_strdup() */ -const char * pinmask_to_str(const pinmask_t * const pinmask) { - static char buf[(PIN_MAX + 1) * 5]; // should be enough for PIN_MAX=255 +char *pinmask_to_strdup(const pinmask_t * const pinmask) { + char buf[6 * (PIN_MAX + 1)]; char *p = buf; int n; int pin; - const char * fmt; int start = -1; int end = -1; @@ -189,11 +187,8 @@ const char * pinmask_to_str(const pinmask_t * const pinmask) { start = pin; end = start; } - if(output) { - fmt = (buf[0] == 0) ? "%d" : ",%d"; - n = sprintf(p, fmt, pin); - p += n; - } + if(output) + p += n = sprintf(p, *buf? ", %d": "%d", pin); } } if(start != end) { @@ -201,10 +196,7 @@ const char * pinmask_to_str(const pinmask_t * const pinmask) { p += n; } - if(buf[0] == 0) - return "(no pins)"; - - return buf; + return mmt_strdup(*buf? buf: "(no pins)"); } @@ -277,26 +269,36 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const } if(invalid) { if(output) { + char *mskinvalid = pinmask_to_strdup(invalid_used); pmsg_error("%s: these pins are not valid pins for this function: %s\n", - avr_pin_name(pinname), pinmask_to_str(invalid_used)); + avr_pin_name(pinname), mskinvalid); + mmt_free(mskinvalid); + char *mskvalid = pinmask_to_strdup(valid_pins->mask); pmsg_notice("%s: valid pins for this function are: %s\n", - avr_pin_name(pinname), pinmask_to_str(valid_pins->mask)); + avr_pin_name(pinname), mskvalid); + mmt_free(mskvalid); } is_ok = false; } if(inverse) { if(output) { + char *mskinvalidinv = pinmask_to_strdup(inverse_used); pmsg_error("%s: these pins are not usable as inverse pins for this function: %s\n", - avr_pin_name(pinname), pinmask_to_str(inverse_used)); + avr_pin_name(pinname), mskinvalidinv); + mmt_free(mskinvalidinv); + char *mskvalidinv = pinmask_to_strdup(valid_pins->inverse); pmsg_notice("%s: valid inverse pins for this function are: %s\n", - avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse)); + avr_pin_name(pinname), mskvalidinv); + mmt_free(mskvalidinv); } is_ok = false; } if(used) { if(output) { + char *pmsk = pinmask_to_strdup(already_used); pmsg_error("%s: these pins are set for other functions too: %s\n", - avr_pin_name(pinname), pinmask_to_str(already_used)); + avr_pin_name(pinname), pmsk); + mmt_free(pmsk); is_ok = false; } } @@ -320,7 +322,7 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const * 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 - * @returns a pointer to a string, which was created by mmt_strdup() + * @returns a string that was created by mmt_strdup() */ char *pins_to_strdup(const struct pindef_t * const pindef) { char buf[6*(PIN_MAX+1)], *p = buf; From 943133088740452a74d6f58967141a01a36b680d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 9 May 2024 19:07:43 +0100 Subject: [PATCH 030/422] Change free() to mmt_free() --- src/avrftdi.c | 4 ++-- src/pgm.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index 0faa6bb3..8adede7d 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -611,7 +611,7 @@ static int avrftdi_pin_setup(const PROGRAMMER *pgm) { avr_pin_name(PIN_JTAG_TDO), avr_pin_name(PIN_JTAG_TMS), *ptck? ptck: "?", *ptdi? ptdi: "?", *ptdo? ptdo: "?", *ptms? ptms: "?"); - free(ptck); free(ptdi); free(ptdo); free(ptms); + mmt_free(ptck); mmt_free(ptdi); mmt_free(ptdo); mmt_free(ptms); } else { char *psck = pins_to_strdup(&pgm->pin[PIN_AVR_SCK]), *psdo = pins_to_strdup(&pgm->pin[PIN_AVR_SDO]), @@ -621,7 +621,7 @@ static int avrftdi_pin_setup(const PROGRAMMER *pgm) { avr_pin_name(PIN_AVR_SDI), *psck? psck: "?", *psdo? psdo: "?", *psdi? psdi: "?"); - free(psck); free(psdo); free(psdi); + mmt_free(psck); mmt_free(psdo); mmt_free(psdi); } imsg_error("if other pin configuration is used, fallback to slower bitbanging mode is used\n"); diff --git a/src/pgm.c b/src/pgm.c index dc8acf0e..fae3f2b5 100644 --- a/src/pgm.c +++ b/src/pgm.c @@ -291,7 +291,7 @@ void pgm_display_generic_mask(const PROGRAMMER *pgm, const char *p, unsigned int if(show & (1<pin + pbit); msg_info("%s %-6s = %s\n", p, avr_pin_name(pbit), *pinstr? pinstr: "(not used)"); - free(pinstr); + mmt_free(pinstr); } } From e72d67285959ff5f7bc9b9f0071ccb90fa43b422 Mon Sep 17 00:00:00 2001 From: Funkeleinhorn Date: Thu, 9 May 2024 22:46:39 +0200 Subject: [PATCH 031/422] Move serprog enable logic to pgm->initialize() This commits moves the logic to enable the serprog programmer to be ready for programming to the initalize() function as it seems to be the counterpart of disable() and is called directly before programming starts. This allows to open() a serprog programmer without blocking the SPI bus as 0x15 S_PIN_STATE and 0x18 S_CS_MODE is only called in initalize before the actual programming starts. --- src/serprog.c | 78 +++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index 66ec8762..e40321d6 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -273,40 +273,6 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { return 0; } -static void serprog_enable(PROGRAMMER *pgm, const AVRPART *p) { - unsigned char buf[32]; - // set active chip select - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { - memset(buf, 0, sizeof(buf)); - buf[0] = my.cs; - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot change CS\n"); - } - } - - // set full duplex - memset(buf, 0, sizeof(buf)); - buf[0] = SPI_MODE_FULL_DUPLEX; - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot set SPI full duplex mode\n"); - } - - // set output - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { - memset(buf, 0, sizeof(buf)); - buf[0] = 1; // Pin state enable - if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot enable pin state\n"); - } - } - - // enable the CS / reset pin - const unsigned char cs_mode = CS_MODE_SELECTED; - if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { - pmsg_error("cannot enable the reset pin\n"); - } -} - static void serprog_disable(const PROGRAMMER *pgm) { unsigned char buf[32]; // switch cs to auto @@ -347,14 +313,51 @@ static int serprog_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned } static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *p) { - int tries, ret; - if (p->prog_modes & PM_TPI) { /* We do not support TPI. This is a dedicated SPI thing */ pmsg_error("the %s programmer does not support TPI\n", pgmid); return -1; } + unsigned char buf[32]; + + // set active chip select + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { + memset(buf, 0, sizeof(buf)); + buf[0] = my.cs; + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { + pmsg_error("cannot change CS\n"); + return -1; + } + } + + // set full duplex + memset(buf, 0, sizeof(buf)); + buf[0] = SPI_MODE_FULL_DUPLEX; + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { + pmsg_error("cannot set SPI full duplex mode\n"); + return -1; + } + + // set output + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { + memset(buf, 0, sizeof(buf)); + buf[0] = 1; // Pin state enable + if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { + pmsg_error("cannot enable pin state\n"); + return -1; + } + } + + // enable the CS / reset pin + const unsigned char cs_mode = CS_MODE_SELECTED; + if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { + pmsg_error("cannot enable the reset pin\n"); + return -1; + } + + int tries, ret; + //enable programming on the part tries = 0; do { @@ -435,6 +438,9 @@ static int serprog_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { static void serprog_display(const PROGRAMMER *pgm, const char *p) { } +static void serprog_enable(PROGRAMMER *pgm, const AVRPART *p) { +} + static void serprog_setup(PROGRAMMER *pgm) { pgm->cookie = mmt_malloc(sizeof(struct pdata)); } From c411555d2719c69e9ae66b5707c0c298609e9a47 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 00:16:00 +0100 Subject: [PATCH 032/422] Differentiate cause of Cannot find programmer id --- src/main.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 49dae75f..e0287693 100644 --- a/src/main.c +++ b/src/main.c @@ -512,7 +512,9 @@ static int suggest_programmers(const char *programmer, LISTID programmers) { return n; } -static void programmer_not_found(const char *programmer, PROGRAMMER *pgm, int pmode) { +static void programmer_not_found(const char *programmer, const PROGRAMMER *pgm, const AVRPART *pt) { + int pmode = pt? pt->prog_modes: ~0; + if(!programmer || !*programmer) { pmsg_error("no programmer has been specified on the command line or in the\n"); imsg_error("config file(s); specify one using the -c option and try again\n"); @@ -554,9 +556,15 @@ static void programmer_not_found(const char *programmer, PROGRAMMER *pgm, int pm } } } else if(!pgm || !pgm->id || !lsize(pgm->id)) { - pmsg_error("cannot find programmer id %s\n", programmer); - suggest_programmers(programmer, programmers); - msg_info("use -c? to see all possible programmers\n"); + PROGRAMMER *pg = locate_programmer(programmers, programmer); + if(!pgm && pt && pg && !(pg->prog_modes & pmode)) { + pmsg_error("programmer %s and part %s have no programming modes in common\n", programmer, pt->desc); + msg_info("use -c? -p %s to see all possible programmers for %s\n", pt->desc, pt->desc); + } else { + pmsg_error("cannot find programmer id %s\n", programmer); + suggest_programmers(programmer, programmers); + msg_info("use -c? to see all possible programmers\n"); + } } else pmsg_error("programmer %s lacks %s setting\n", programmer, !pgm->prog_modes? "prog_modes": !pgm->initpgm? "type": "some"); @@ -1153,7 +1161,7 @@ int main(int argc, char * argv []) if(pgmid && *pgmid && explicit_c) { PROGRAMMER *pgm = locate_programmer_starts_set(programmers, pgmid, &pgmid, NULL); if(!pgm || !is_programmer(pgm)) { - programmer_not_found(pgmid, pgm, ~0); + programmer_not_found(pgmid, pgm, NULL); exit(1); } msg_error("\nValid parts for programmer %s are:\n", pgmid); @@ -1196,14 +1204,14 @@ int main(int argc, char * argv []) msg_notice("\n"); if(!pgmid || !*pgmid) { - programmer_not_found(NULL, NULL, ~0); + programmer_not_found(NULL, NULL, NULL); exit(1); } p = partdesc && *partdesc? locate_part(part_list, partdesc): NULL; pgm = locate_programmer_starts_set(programmers, pgmid, &pgmid, p); if (pgm == NULL || !is_programmer(pgm)) { - programmer_not_found(pgmid, pgm, p? p->prog_modes: ~0); + programmer_not_found(pgmid, pgm, p); exit(1); } From 443962e5773710d1aef9045bea6ff0e41d1df246 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 00:17:09 +0100 Subject: [PATCH 033/422] Improve error message when usb device not found in avrftdi.c --- src/avrftdi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index 29d6fb6a..a7867f66 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -708,7 +708,7 @@ static int avrftdi_open(PROGRAMMER *pgm, const char *port) { // Todo: use desc and index argument, currently set to NULL and 0 err = ftdi_usb_open_desc_index(pdata->ftdic, vid, pid, NULL, serial, 0); if(err) { - pmsg_error("error %d occurred: %s\n", err, ftdi_get_error_string(pdata->ftdic)); + pmsg_error("%s (%d)\n", ftdi_get_error_string(pdata->ftdic), err); // usb_dev is initialized to the last usb device from probing pdata->ftdic->usb_dev = NULL; return err; From 292947d9a888e0a080bcfd35903f0fd2f1463061 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 10:29:38 +0100 Subject: [PATCH 034/422] Put static variable of ppi.c into context structure --- src/libavrdude.h | 3 +++ src/ppi.c | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index c53cf429..3411c1b8 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1564,6 +1564,9 @@ typedef struct { // Static variable from config_gram.y int cfgy_pin_name; // Temporary variable for grammar parsing + + // Static variable from ppi.c + unsigned char ppi_shadow[3]; } cx_t; extern cx_t *cx; diff --git a/src/ppi.c b/src/ppi.c index ef2c9ef9..e883553f 100644 --- a/src/ppi.c +++ b/src/ppi.c @@ -54,7 +54,6 @@ enum { static int ppi_shadow_access(const union filedescriptor *fdp, int reg, unsigned char *v, unsigned char action) { - static unsigned char shadow[3]; int shadow_num; switch (reg) { @@ -75,14 +74,14 @@ static int ppi_shadow_access(const union filedescriptor *fdp, int reg, switch (action) { case PPI_SHADOWREAD: - *v = shadow[shadow_num]; + *v = cx->ppi_shadow[shadow_num]; break; case PPI_READ: DO_PPI_READ(fdp->ifd, reg, v); - shadow[shadow_num]=*v; + cx->ppi_shadow[shadow_num]=*v; break; case PPI_WRITE: - shadow[shadow_num]=*v; + cx->ppi_shadow[shadow_num]=*v; DO_PPI_WRITE(fdp->ifd, reg, v); break; } From 80251073cd37d4c52f7a2bcb6fbc80a7f9a196ff Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 11:00:18 +0100 Subject: [PATCH 035/422] Put static variables of ser_avrdoper.c into context structure --- src/libavrdude.h | 5 +++++ src/ser_avrdoper.c | 22 +++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 3411c1b8..6df3788f 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1567,6 +1567,11 @@ typedef struct { // Static variable from ppi.c unsigned char ppi_shadow[3]; + + // Static variables from ser_avrdoper.c + unsigned char sad_avrdoperRxBuffer[280]; // Buffer for receiving data + int sad_avrdoperRxLength; // Amount of valid bytes in rx buffer + int sad_avrdoperRxPosition; // Amount of bytes already consumed in rx buffer } cx_t; extern cx_t *cx; diff --git a/src/ser_avrdoper.c b/src/ser_avrdoper.c index 48f17dbd..9e745c31 100644 --- a/src/ser_avrdoper.c +++ b/src/ser_avrdoper.c @@ -57,10 +57,6 @@ static const int reportDataSizes[4] = {13, 29, 61, 125}; -static unsigned char avrdoperRxBuffer[280]; /* buffer for receive data */ -static int avrdoperRxLength = 0; /* amount of valid bytes in rx buffer */ -static int avrdoperRxPosition = 0; /* amount of bytes already consumed in rx buffer */ - /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ @@ -275,11 +271,11 @@ static int avrdoper_send(const union filedescriptor *fdp, const unsigned char *b static int avrdoperFillBuffer(const union filedescriptor *fdp) { int bytesPending = reportDataSizes[1]; /* guess how much data is buffered in device */ - avrdoperRxPosition = avrdoperRxLength = 0; + cx->sad_avrdoperRxPosition = cx->sad_avrdoperRxLength = 0; while(bytesPending > 0){ int len, usbErr, lenIndex = chooseDataSize(bytesPending); unsigned char buffer[128]; - len = sizeof(avrdoperRxBuffer) - avrdoperRxLength; /* bytes remaining */ + len = sizeof(cx->sad_avrdoperRxBuffer) - cx->sad_avrdoperRxLength; /* bytes remaining */ if(reportDataSizes[lenIndex] + 2 > len) /* requested data would not fit into buffer */ break; len = reportDataSizes[lenIndex] + 2; @@ -294,12 +290,12 @@ static int avrdoperFillBuffer(const union filedescriptor *fdp) { bytesPending = buffer[1] - len; /* amount still buffered */ if(len > buffer[1]) /* cut away padding */ len = buffer[1]; - if(avrdoperRxLength + len > (int) sizeof(avrdoperRxBuffer)){ + if(cx->sad_avrdoperRxLength + len > (int) sizeof(cx->sad_avrdoperRxBuffer)){ pmsg_error("buffer overflow\n"); return -1; } - memcpy(avrdoperRxBuffer + avrdoperRxLength, buffer + 2, len); - avrdoperRxLength += len; + memcpy(cx->sad_avrdoperRxBuffer + cx->sad_avrdoperRxLength, buffer + 2, len); + cx->sad_avrdoperRxLength += len; } return 0; } @@ -310,17 +306,17 @@ static int avrdoper_recv(const union filedescriptor *fdp, unsigned char *buf, si int remaining = buflen; while(remaining > 0){ - int len, available = avrdoperRxLength - avrdoperRxPosition; + int len, available = cx->sad_avrdoperRxLength - cx->sad_avrdoperRxPosition; if(available <= 0){ /* buffer is empty */ if (avrdoperFillBuffer(fdp) < 0) return -1; continue; } len = remaining < available ? remaining : available; - memcpy(p, avrdoperRxBuffer + avrdoperRxPosition, len); + memcpy(p, cx->sad_avrdoperRxBuffer + cx->sad_avrdoperRxPosition, len); p += len; remaining -= len; - avrdoperRxPosition += len; + cx->sad_avrdoperRxPosition += len; } if(verbose > 3) dumpBlock("Receive", buf, buflen); @@ -334,7 +330,7 @@ static int avrdoper_drain(const union filedescriptor *fdp, int display) do{ if (avrdoperFillBuffer(fdp) < 0) return -1; - }while(avrdoperRxLength > 0); + }while(cx->sad_avrdoperRxLength > 0); return 0; } From 5dc019c721ab5ff45595205b5843728aa94aba0f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 12:07:46 +0100 Subject: [PATCH 036/422] Harden avrdude against early pmsg_...() calls --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 313fcdf9..68e7689e 100644 --- a/src/main.c +++ b/src/main.c @@ -52,7 +52,7 @@ #include "config.h" #include "developer_opts.h" -char * progname; +char * progname = "avrdude"; char progbuf[PATH_MAX]; /* temporary buffer of spaces the same length as progname; used for lining up multiline messages */ From 9d15a167e74293f025deba7dc560e964afcaf20e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 13:03:05 +0100 Subject: [PATCH 037/422] Provide avr_cc_buffer(n) for allocating n bytes in temporary buffer --- src/avr.c | 31 ++++++++++++++++++++++--------- src/libavrdude.h | 6 +++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/avr.c b/src/avr.c index 039e488e..53a7b395 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1442,6 +1442,26 @@ int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles) { } +// Return temporary string buffer with n bytes from a closed-circuit space +char *avr_cc_buffer(size_t n) { + if(n > sizeof cx->avr_space) { + pmsg_error("requested size %lu too big for cx->avr_space[%lu] (change source)\n", + (unsigned long) n, (unsigned long) sizeof cx->avr_space); + cx->avr_s = cx->avr_space; + n = sizeof cx->avr_space; + } else if(!cx->avr_s) + cx->avr_s = cx->avr_space; + + cx->avr_s += strlen(cx->avr_s) + 1; // Move behind string from last call + + // Rewind if too little space left + if((size_t) (cx->avr_s - cx->avr_space) > sizeof cx->avr_space - n) + cx->avr_s = cx->avr_space; + + memset(cx->avr_s, 0, n); + return cx->avr_s; +} + /* * Returns a string in closed-circuit space with a list of programming * modes encoded in pm; variant creates the list in subtly different ways: @@ -1451,13 +1471,7 @@ int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles) { * If pm is 0 (no programming modes) returns "0" */ static char *prog_modes_string(int pm, int variant) { - // Return string is overwritten after a few calls - if(!cx->avr_s) - cx->avr_s = cx->avr_space; - char *type = cx->avr_s + strlen(cx->avr_s) + 1; - // Overwrite space once only 128 bytes left - if((size_t) (type - cx->avr_space) > sizeof cx->avr_space - 128) - type = cx->avr_space; + char *type = avr_cc_buffer(256); // Longest returned string has 142 chars const char *spm = variant? "SPM": "bootloader"; const char *sep = variant == 2? " | PM_": ", "; @@ -1491,8 +1505,7 @@ static char *prog_modes_string(int pm, int variant) { if(pm & PM_aWire) strcat(strcat(type, sep), "aWire"); - cx->avr_s = type + (type[1] == 0? 0: skip); - return cx->avr_s; + return type + (type[1] == 0? 0: skip); } char *avr_prog_modes(int pm) { // PM_SPM prints bootloader diff --git a/src/libavrdude.h b/src/libavrdude.h index 6df3788f..9b25c496 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1515,6 +1515,8 @@ int terminal_line(const PROGRAMMER *pgm, const AVRPART *p, const char *line); char *terminal_get_input(const char *prompt); void terminal_setup_update_progress(void); +char *avr_cc_buffer(size_t n); + #ifdef __cplusplus } #endif @@ -1530,11 +1532,13 @@ void terminal_setup_update_progress(void); */ typedef struct { + // Closed-circuit space for returning strings in a persistent buffer + char *avr_s, avr_space[8192]; + // Static variables from avr.c int avr_disableffopt; // Disables trailing 0xff flash optimisation uint64_t avr_epoch; // Epoch for avr_ustimestamp() int avr_epoch_init; // Whether above epoch is initialised - char avr_space[1024], *avr_s; // Closed-circuit space for avr+prog_modes() int avr_last_percent; // Last valid percentage for report_progress() double avr_start_time; // Start time in s of report_progress() activity From e85ecfa503093aa67643528d7743ece37b2c84e0 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 13:07:22 +0100 Subject: [PATCH 038/422] Utilise is_memset() in avrcache/developer_opts --- src/avrcache.c | 19 ++++++------------- src/developer_opts.c | 9 ++------- src/libavrdude.h | 2 +- src/strutil.c | 2 +- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/avrcache.c b/src/avrcache.c index f509fff1..38aa4f8c 100644 --- a/src/avrcache.c +++ b/src/avrcache.c @@ -330,13 +330,6 @@ error: } -// Does the memory region only haxe 0xff? -static int _is_all_0xff(const void *p, size_t n) { - const unsigned char *q = (const unsigned char *) p; - return n <= 0 || (*q == 0xff && memcmp(q, q+1, n-1) == 0); -} - - // A coarse guess where any bootloader might start (prob underestimates the start) static int guessBootStart(const PROGRAMMER *pgm, const AVRPART *p) { int bootstart = 0; @@ -539,7 +532,7 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) { } else if(mems[i].iseeprom) { // Don't know whether chip erase has zapped EEPROM for(int n = 0; n < cp->size; n += cp->page_size) { - if(!_is_all_0xff(cp->copy + n, cp->page_size)) { // First page that had EEPROM data + if(!is_memset(cp->copy + n, 0xff, cp->page_size)) { // First page that had EEPROM data if(avr_read_page_default(pgm, p, mem, n, cp->copy + n) < 0) { report_progress(1, -1, NULL); if(quell_progress) @@ -547,8 +540,8 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) { pmsg_error("EEPROM read failed at addr 0x%04x\n", n); return LIBAVRDUDE_GENERAL_FAILURE; } - // EEPROM zapped by chip erase? Set all copy to 0xff - if(_is_all_0xff(cp->copy + n, cp->page_size)) + // EEPROM zapped by chip erase? Set all of copy to 0xff + if(is_memset(cp->copy + n, 0xff, cp->page_size)) memset(cp->copy, 0xff, cp->size); break; } @@ -729,10 +722,10 @@ int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p) { bool erasedee = 0; for(int pgno = 0, n = 0; n < cp->size; pgno++, n += cp->page_size) { if(cp->iscached[pgno]) { - if(!_is_all_0xff(cp->copy + n, cp->page_size)) { // Page has EEPROM data? + if(!is_memset(cp->copy + n, 0xff, cp->page_size)) { // Page has EEPROM data? if(avr_read_page_default(pgm, p, mem, n, cp->copy + n) < 0) return LIBAVRDUDE_GENERAL_FAILURE; - erasedee = _is_all_0xff(cp->copy + n, cp->page_size); + erasedee = is_memset(cp->copy + n, 0xff, cp->page_size); break; } } @@ -788,7 +781,7 @@ int avr_page_erase_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM if(loadCachePage(cp, pgm, p, mem, (int) addr, cacheaddr, 0) < 0) return LIBAVRDUDE_GENERAL_FAILURE; - if(!_is_all_0xff(cp->cont + (cacheaddr & ~(cp->page_size-1)), cp->page_size)) + if(!is_memset(cp->cont + (cacheaddr & ~(cp->page_size-1)), 0xff, cp->page_size)) return LIBAVRDUDE_GENERAL_FAILURE; return LIBAVRDUDE_SUCCESS; diff --git a/src/developer_opts.c b/src/developer_opts.c index d3b6d9a6..94d810d8 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -492,11 +492,6 @@ static void dev_raw_dump(const void *v, int nbytes, const char *name, const char } } -static int _is_all_zero(const void *p, size_t n) { - const char *q = (const char *) p; - return n <= 0 || (*q == 0 && memcmp(q, q+1, n-1) == 0); -} - static char *opsnm(const char *pre, int opnum) { static char ret[128]; sprintf(ret, "%.31s.%.95s", pre, opcodename(opnum)); @@ -510,7 +505,7 @@ static void dev_part_raw(const AVRPART *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; idesc, opsnm("part", i), 1); for(int i=0; idesc, nm, i+2); dev_raw_dump(&dp.mems[i].base, sizeof dp.mems[i].base, part->desc, nm, i+2); for(int j=0; jdesc, opsnm(nm, j), i+2); } } diff --git a/src/libavrdude.h b/src/libavrdude.h index 9b25c496..4c1f9b99 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1484,7 +1484,7 @@ const char *str_outname(const char *fn); const char *str_interval(int a, int b); bool is_bigendian(void); void change_endian(void *p, int size); -int memall(const void *p, char c, size_t n); +int is_memset(const void *p, char c, size_t n); unsigned long long int str_ull(const char *str, char **endptr, int base); Str2data *str_todata(const char *str, int type, const AVRPART *part, const char *memstr); void str_freedata(Str2data *sd); diff --git a/src/strutil.c b/src/strutil.c index 63291a2d..511de2f4 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -470,7 +470,7 @@ static int is_mantissa_only(char *p) { } // Return 1 if all n bytes in memory pointed to by p are c, 0 otherwise -int memall(const void *p, char c, size_t n) { +int is_memset(const void *p, char c, size_t n) { const char *q = (const char *) p; return n <= 0 || (*q == c && memcmp(q, q+1, n-1) == 0); } From 3bbb0930f5f48298c50638b4a8d88069b821b227 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 13:29:24 +0100 Subject: [PATCH 039/422] Provide safety margin for avr_cc_buffer(n) --- src/avr.c | 16 +++++++++++----- src/libavrdude.h | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/avr.c b/src/avr.c index 53a7b395..d45b70f6 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1444,18 +1444,24 @@ int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles) { // Return temporary string buffer with n bytes from a closed-circuit space char *avr_cc_buffer(size_t n) { - if(n > sizeof cx->avr_space) { - pmsg_error("requested size %lu too big for cx->avr_space[%lu] (change source)\n", - (unsigned long) n, (unsigned long) sizeof cx->avr_space); + size_t avail = sizeof cx->avr_space - AVR_SAFETY_MARGIN; + if(!is_memset(cx->avr_space + avail, 0, AVR_SAFETY_MARGIN)) { + pmsg_warning("avr_cc_buffer(n) overran; n chosen too small in previous calls? Change and recompile\n"); + memset(cx->avr_space + avail, 0, AVR_SAFETY_MARGIN); + } + + if(n > avail) { + pmsg_error("requested size %lu too big for cx->avr_space[%lu+AVR_SAFETY_MARGIN] (change source)\n", + (unsigned long) n, (unsigned long) avail); cx->avr_s = cx->avr_space; - n = sizeof cx->avr_space; + n = avail; } else if(!cx->avr_s) cx->avr_s = cx->avr_space; cx->avr_s += strlen(cx->avr_s) + 1; // Move behind string from last call // Rewind if too little space left - if((size_t) (cx->avr_s - cx->avr_space) > sizeof cx->avr_space - n) + if((size_t) (cx->avr_s - cx->avr_space) > avail - n) cx->avr_s = cx->avr_space; memset(cx->avr_s, 0, n); diff --git a/src/libavrdude.h b/src/libavrdude.h index 4c1f9b99..1cc87c9b 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1533,7 +1533,8 @@ char *avr_cc_buffer(size_t n); typedef struct { // Closed-circuit space for returning strings in a persistent buffer - char *avr_s, avr_space[8192]; +#define AVR_SAFETY_MARGIN 128 + char *avr_s, avr_space[8192+AVR_SAFETY_MARGIN]; // Static variables from avr.c int avr_disableffopt; // Disables trailing 0xff flash optimisation From 9fb2f422469dab7d89050a3ade3935c42240909f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 13:34:25 +0100 Subject: [PATCH 040/422] Use avr_cc_buffer() instead of static buffer for returning a string --- src/ser_avrdoper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ser_avrdoper.c b/src/ser_avrdoper.c index 9e745c31..42e66f1b 100644 --- a/src/ser_avrdoper.c +++ b/src/ser_avrdoper.c @@ -185,19 +185,18 @@ static void dumpBlock(const char *prefix, const unsigned char *buf, int len) } } -static char *usbErrorText(int usbErrno) -{ - static char buffer[32]; - +static const char *usbErrorText(int usbErrno) { switch(usbErrno){ case USB_ERROR_NONE: return "Success"; case USB_ERROR_ACCESS: return "Access denied"; case USB_ERROR_NOTFOUND:return "Device not found"; case USB_ERROR_BUSY: return "Device is busy"; case USB_ERROR_IO: return "I/O Error"; - default: + default: { + char *buffer = avr_cc_buffer(32); sprintf(buffer, "Unknown error %d", usbErrno); return buffer; + } } } From 2c8c0a79a18f7687cd112bcc8428789967ede5d5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 13:36:52 +0100 Subject: [PATCH 041/422] Improve error messaging --- src/ser_avrdoper.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ser_avrdoper.c b/src/ser_avrdoper.c index 42e66f1b..fb9aa001 100644 --- a/src/ser_avrdoper.c +++ b/src/ser_avrdoper.c @@ -187,14 +187,14 @@ static void dumpBlock(const char *prefix, const unsigned char *buf, int len) static const char *usbErrorText(int usbErrno) { switch(usbErrno){ - case USB_ERROR_NONE: return "Success"; - case USB_ERROR_ACCESS: return "Access denied"; - case USB_ERROR_NOTFOUND:return "Device not found"; - case USB_ERROR_BUSY: return "Device is busy"; + case USB_ERROR_NONE: return "success"; + case USB_ERROR_ACCESS: return "access denied"; + case USB_ERROR_NOTFOUND:return "device not found"; + case USB_ERROR_BUSY: return "device is busy"; case USB_ERROR_IO: return "I/O Error"; default: { char *buffer = avr_cc_buffer(32); - sprintf(buffer, "Unknown error %d", usbErrno); + sprintf(buffer, "unknown error %d", usbErrno); return buffer; } } @@ -210,7 +210,7 @@ static int avrdoper_open(const char *port, union pinfo pinfo, union filedescript rval = usbOpenDevice(fdp, USB_VENDOR_ID, vname, USB_PRODUCT_ID, devname, 1); if(rval != 0){ - pmsg_ext_error("%s\n", usbErrorText(rval)); + pmsg_ext_error("USB %s\n", usbErrorText(rval)); return -1; } return 0; @@ -256,7 +256,7 @@ static int avrdoper_send(const union filedescriptor *fdp, const unsigned char *b rval = usbSetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, (char *)buffer, reportDataSizes[lenIndex] + 2); if(rval != 0){ - pmsg_error("%s\n", usbErrorText(rval)); + pmsg_error("USB %s\n", usbErrorText(rval)); return -1; } buflen -= thisLen; @@ -281,7 +281,7 @@ static int avrdoperFillBuffer(const union filedescriptor *fdp) { usbErr = usbGetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, lenIndex + 1, (char *)buffer, &len); if(usbErr != 0){ - pmsg_error("%s\n", usbErrorText(usbErr)); + pmsg_error("USB %s\n", usbErrorText(usbErr)); return -1; } msg_trace("Received %d bytes data chunk of total %d\n", len - 2, buffer[1]); From b4ed989c99ea7fcc44e0f9fa7db82e1150ac46e4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 14:10:37 +0100 Subject: [PATCH 042/422] Make static struct const in serbb_posix.c --- src/serbb_posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/serbb_posix.c b/src/serbb_posix.c index 868ec21e..b4306df1 100644 --- a/src/serbb_posix.c +++ b/src/serbb_posix.c @@ -62,11 +62,11 @@ static struct termios oldmode; #define DB9PINS 9 -static int serregbits[DB9PINS + 1] = +static const int serregbits[DB9PINS + 1] = { 0, TIOCM_CD, 0, 0, TIOCM_DTR, 0, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS, TIOCM_RI }; #ifdef DEBUG -static char *serpins[DB9PINS + 1] = +static const char *serpins[DB9PINS + 1] = { "NONE", "CD", "RXD", "TXD", "DTR", "GND", "DSR", "RTS", "CTS", "RI" }; #endif From fbf9a9f539976837995908c409cb614df5f50dca Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 14:12:54 +0100 Subject: [PATCH 043/422] Move static variables into PDATA in serbb_posix.c --- src/serbb_posix.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/serbb_posix.c b/src/serbb_posix.c index b4306df1..877fc1a5 100644 --- a/src/serbb_posix.c +++ b/src/serbb_posix.c @@ -44,7 +44,13 @@ #undef DEBUG -static struct termios oldmode; +struct pdata { + struct termios oldmode; +}; + +// Use private programmer data as if they were a global structure my +#define my (*(struct pdata *)(pgm->cookie)) + /* serial port/pin mapping @@ -243,7 +249,7 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) { pmsg_ext_error("%s, tcgetattr(): %s\n", port, strerror(errno)); return(-1); } - oldmode = mode; + my.oldmode = mode; mode.c_iflag = IGNBRK | IGNPAR; mode.c_oflag = 0; @@ -277,13 +283,22 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) { static void serbb_close(PROGRAMMER *pgm) { if (pgm->fd.ifd != -1) { - (void)tcsetattr(pgm->fd.ifd, TCSANOW, &oldmode); + (void) tcsetattr(pgm->fd.ifd, TCSANOW, &my.oldmode); pgm->setpin(pgm, PIN_AVR_RESET, 1); close(pgm->fd.ifd); } return; } +static void serbb_setup(PROGRAMMER *pgm) { + pgm->cookie = mmt_malloc(sizeof(struct pdata)); +} + +static void serbb_teardown(PROGRAMMER *pgm) { + mmt_free(pgm->cookie); + pgm->cookie = NULL; +} + const char serbb_desc[] = "Serial port bitbanging"; void serbb_initpgm(PROGRAMMER *pgm) { @@ -291,6 +306,8 @@ void serbb_initpgm(PROGRAMMER *pgm) { pgm_fill_old_pins(pgm); // TODO to be removed if old pin data no longer needed + pgm->setup = serbb_setup; + pgm->teardown = serbb_teardown; pgm->rdy_led = bitbang_rdy_led; pgm->err_led = bitbang_err_led; pgm->pgm_led = bitbang_pgm_led; From 8a807b8a53aeb424ffef9361520de2cdf477db85 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 14:27:15 +0100 Subject: [PATCH 044/422] Move static variables into PDATA in serbb_win32.c --- src/serbb_win32.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/serbb_win32.c b/src/serbb_win32.c index 4722f611..d779bd62 100644 --- a/src/serbb_win32.c +++ b/src/serbb_win32.c @@ -40,8 +40,12 @@ #include "bitbang.h" #include "serbb.h" -/* cached status lines */ -static int dtr, rts, txd; +struct pdata { + int dtr, rts, txd; // Cached status lines +}; + +// Use private programmer data as if they were a global structure my +#define my (*(struct pdata *)(pgm->cookie)) #define W32SERBUFSIZE 1024 @@ -85,13 +89,13 @@ static int serbb_setpin(const PROGRAMMER *pgm, int pinfunc, int value) { case 3: /* txd */ dwFunc = value? SETBREAK: CLRBREAK; name = value? "SETBREAK": "CLRBREAK"; - txd = value; + my.txd = value; break; case 4: /* dtr */ dwFunc = value? SETDTR: CLRDTR; name = value? "SETDTR": "CLRDTR"; - dtr = value; + my.dtr = value; break; case 7: /* rts */ @@ -191,15 +195,15 @@ static int serbb_getpin(const PROGRAMMER *pgm, int pinfunc) { switch (pin) { case 3: /* txd */ - rv = txd; + rv = my.txd; name = "TXD"; break; case 4: /* dtr */ - rv = dtr; + rv = my.dtr; name = "DTR"; break; case 7: /* rts */ - rv = rts; + rv = my.rts; name = "RTS"; break; default: @@ -303,7 +307,7 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) { pgm->fd.pfd = (void *)hComPort; - dtr = rts = txd = 0; + my.dtr = my.rts = my.txd = 0; return 0; } @@ -320,6 +324,15 @@ static void serbb_close(PROGRAMMER *pgm) { hComPort = INVALID_HANDLE_VALUE; } +static void serbb_setup(PROGRAMMER *pgm) { + pgm->cookie = mmt_malloc(sizeof(struct pdata)); +} + +static void serbb_teardown(PROGRAMMER *pgm) { + mmt_free(pgm->cookie); + pgm->cookie = NULL; +} + const char serbb_desc[] = "Serial port bitbanging"; void serbb_initpgm(PROGRAMMER *pgm) { @@ -327,6 +340,8 @@ void serbb_initpgm(PROGRAMMER *pgm) { pgm_fill_old_pins(pgm); // TODO to be removed if old pin data no longer needed + pgm->setup = serbb_setup; + pgm->teardown = serbb_teardown; pgm->rdy_led = bitbang_rdy_led; pgm->err_led = bitbang_err_led; pgm->pgm_led = bitbang_pgm_led; From 70e18698521101af7fbf38a8a0b09c5dd6976cc2 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 14:27:39 +0100 Subject: [PATCH 045/422] Fix rts cache value in serbb_setpin() for serbb_win32.c --- src/serbb_win32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/serbb_win32.c b/src/serbb_win32.c index d779bd62..b0b14a35 100644 --- a/src/serbb_win32.c +++ b/src/serbb_win32.c @@ -101,6 +101,7 @@ static int serbb_setpin(const PROGRAMMER *pgm, int pinfunc, int value) { case 7: /* rts */ dwFunc = value? SETRTS: CLRRTS; name = value? "SETRTS": "CLRRTS"; + my.rts = value; break; default: From 93ba3e9feb9153a646329e77c9aaa09b8b601dc6 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 17:14:15 +0100 Subject: [PATCH 046/422] Make static structure const in ser_posix.c --- src/ser_posix.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/ser_posix.c b/src/ser_posix.c index 2147e435..452f46c5 100644 --- a/src/ser_posix.c +++ b/src/ser_posix.c @@ -59,9 +59,7 @@ struct baud_mapping { speed_t speed; }; -/* There are a lot more baud rates we could handle, but what's the point? */ - -static struct baud_mapping baud_lookup_table [] = { +static const struct baud_mapping baud_lookup_table [] = { { 300, B300 }, { 600, B600 }, { 1200, B1200 }, @@ -125,24 +123,16 @@ static struct termios original_termios; static int saved_original_termios; static speed_t serial_baud_lookup(long baud, bool *nonstandard) { - struct baud_mapping *map = baud_lookup_table; - *nonstandard = false; - while (map->baud) { + for(const struct baud_mapping *map = baud_lookup_table; map->baud; map++) if (map->baud == baud) return map->speed; - map++; - } - /* - * If a non-standard BAUD rate is used, issue - * a warning (if we are verbose) and return the raw rate - */ + // Return the raw rate when asked for non-standard baud rate pmsg_notice2("serial_baud_lookup(): using non-standard baud rate: %ld\n", baud); *nonstandard = true; - return baud; } From f833691e000b02909f2fe8eae7d203a7e96ad848 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 17:14:48 +0100 Subject: [PATCH 047/422] Make static structure const in ser_win32.c --- src/ser_win32.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/ser_win32.c b/src/ser_win32.c index 18909b38..041ddfd9 100644 --- a/src/ser_win32.c +++ b/src/ser_win32.c @@ -50,7 +50,7 @@ static unsigned char serial_over_ethernet = 0; /* HANDLE hComPort=INVALID_HANDLE_VALUE; */ -static struct baud_mapping baud_lookup_table [] = { +static const struct baud_mapping baud_lookup_table [] = { { 300, CBR_300 }, { 600, CBR_600 }, { 1200, CBR_1200 }, @@ -64,20 +64,12 @@ static struct baud_mapping baud_lookup_table [] = { { 0, 0 } /* Terminator. */ }; -static DWORD serial_baud_lookup(long baud) -{ - struct baud_mapping *map = baud_lookup_table; - - while (map->baud) { +static DWORD serial_baud_lookup(long baud) { + for(const struct baud_mapping *map = baud_lookup_table; map->baud; map++) if (map->baud == baud) return map->speed; - map++; - } - /* - * If a non-standard BAUD rate is used, issue - * a warning (if we are verbose) and return the raw rate - */ + // Return the raw rate when asked for non-standard baud rate pmsg_notice2("serial_baud_lookup(): using non-standard baud rate: %ld", baud); return baud; From 366d9bb66e9f18c39a4fca64053263bb3804a22e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 17:18:27 +0100 Subject: [PATCH 048/422] Fix argument type for str_sprintf() --- src/strutil.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/strutil.c b/src/strutil.c index 511de2f4..1983bce4 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -724,10 +724,11 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m if(is_signed && is_out_of_range) Warning("%s out of int%d range, interpreted as %d-byte %lld%sU", - stri, sd->size*8, sd->size, sd->ll, sd->size == 4? "L": sd->size==2? "H": "HH"); + stri, sd->size*8, sd->size, (long long int) sd->ll, + sd->size == 4? "L": sd->size==2? "H": "HH"); else if(is_out_of_range) Warning("%s out of uint%d range, interpreted as %d-byte %llu", - stri, sd->size*8, sd->size, sd->ull); + stri, sd->size*8, sd->size, (long long unsigned int) sd->ull); else if(is_outside_int64_t) Warning("%s out of int64 range (consider U suffix)", stri); From 9a908a24f91ed475af192f1c813bab4ee5274079 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 17:18:54 +0100 Subject: [PATCH 049/422] Add argument checks for str_sprintf() --- src/libavrdude.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 1cc87c9b..957acb9a 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1470,7 +1470,11 @@ int str_casematch(const char *pattern, const char *string); int str_matched_by(const char *string, const char *pattern); int str_casematched_by(const char *string, const char *pattern); int str_is_pattern(const char *str); -char *str_sprintf(const char *fmt, ...); +char *str_sprintf(const char *fmt, ...) +#if defined(__GNUC__) // Ask gcc to check whether format and parameters match + __attribute__ ((format (printf, 1, 2))) +#endif +; char *str_fgets(FILE *fp, const char **errpp); char *str_lc(char *s); char *str_uc(char *s); From e652726e1b2fa068cd472e09e1b035c3a2651aa7 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 17:28:37 +0100 Subject: [PATCH 050/422] Put static variables of ser_posix.c into context structure --- src/libavrdude.h | 10 ++++++++++ src/ser_posix.c | 23 ++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 957acb9a..cbebf271 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -26,6 +26,9 @@ #include #include #include +#if !defined(WIN32) +#include +#endif #ifdef LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS #error LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS is defined. Do not do that. @@ -1581,6 +1584,13 @@ typedef struct { unsigned char sad_avrdoperRxBuffer[280]; // Buffer for receiving data int sad_avrdoperRxLength; // Amount of valid bytes in rx buffer int sad_avrdoperRxPosition; // Amount of bytes already consumed in rx buffer + + // Static variables from ser_win32.c/ser_posix.c +#if defined(WIN32) +#else + struct termios ser_original_termios; + int ser_saved_original_termios; +#endif } cx_t; extern cx_t *cx; diff --git a/src/ser_posix.c b/src/ser_posix.c index 452f46c5..60668cc7 100644 --- a/src/ser_posix.c +++ b/src/ser_posix.c @@ -119,9 +119,6 @@ static const struct baud_mapping baud_lookup_table [] = { { 0, 0 } /* Terminator. */ }; -static struct termios original_termios; -static int saved_original_termios; - static speed_t serial_baud_lookup(long baud, bool *nonstandard) { *nonstandard = false; @@ -158,9 +155,8 @@ static int ser_setparams(const union filedescriptor *fd, long baud, unsigned lon /* * copy termios for ser_close if we haven't already */ - if (! saved_original_termios++) { - original_termios = termios; - } + if(!cx->ser_saved_original_termios++) + cx->ser_original_termios = termios; if (cflags & SERIAL_CREAD) { termios.c_cflag |= CREAD; @@ -403,15 +399,12 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f } static void ser_close(union filedescriptor *fd) { - /* - * restore original termios settings from ser_open - */ - if (saved_original_termios) { - int rc = tcsetattr(fd->ifd, TCSANOW | TCSADRAIN, &original_termios); - if (rc) { + // Restore original termios settings from ser_open + if(cx->ser_saved_original_termios) { + int rc = tcsetattr(fd->ifd, TCSANOW | TCSADRAIN, &cx->ser_original_termios); + if(rc) pmsg_ext_error("cannot reset attributes for device: %s\n", strerror(errno)); - } - saved_original_termios = 0; + cx->ser_saved_original_termios = 0; } close(fd->ifd); @@ -419,7 +412,7 @@ static void ser_close(union filedescriptor *fd) { // Close but don't restore attributes static void ser_rawclose(union filedescriptor *fd) { - saved_original_termios = 0; + cx->ser_saved_original_termios = 0; close(fd->ifd); } From bf7062cf6d39e0f237526d8f55bb8f12baffdfc6 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 17:38:18 +0100 Subject: [PATCH 051/422] Put static variables of ser_win32.c into context structure --- src/libavrdude.h | 1 + src/ser_win32.c | 124 ++++++++++++++++++++++------------------------- 2 files changed, 58 insertions(+), 67 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index cbebf271..f9e7ea61 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1587,6 +1587,7 @@ typedef struct { // Static variables from ser_win32.c/ser_posix.c #if defined(WIN32) + unsigned char ser_serial_over_ethernet; #else struct termios ser_original_termios; int ser_saved_original_termios; diff --git a/src/ser_win32.c b/src/ser_win32.c index 041ddfd9..95ef8fc4 100644 --- a/src/ser_win32.c +++ b/src/ser_win32.c @@ -46,8 +46,6 @@ struct baud_mapping { DWORD speed; }; -static unsigned char serial_over_ethernet = 0; - /* HANDLE hComPort=INVALID_HANDLE_VALUE; */ static const struct baud_mapping baud_lookup_table [] = { @@ -88,57 +86,55 @@ static BOOL serial_w32SetTimeOut(HANDLE hComPort, DWORD timeout) // in ms } static int ser_setparams(const union filedescriptor *fd, long baud, unsigned long cflags) { - if (serial_over_ethernet) { + if(cx->ser_serial_over_ethernet) return -ENOTTY; - } else { - DCB dcb; - HANDLE hComPort = (HANDLE)fd->pfd; - ZeroMemory (&dcb, sizeof(DCB)); - dcb.DCBlength = sizeof(DCB); - dcb.BaudRate = serial_baud_lookup (baud); - dcb.fBinary = 1; - dcb.fDtrControl = DTR_CONTROL_DISABLE; - dcb.fRtsControl = RTS_CONTROL_DISABLE; - switch ((cflags & (SERIAL_CS5 | SERIAL_CS6 | SERIAL_CS7 | SERIAL_CS8))) { - case SERIAL_CS5: - dcb.ByteSize = 5; - break; - case SERIAL_CS6: - dcb.ByteSize = 6; - break; - case SERIAL_CS7: - dcb.ByteSize = 7; - break; - case SERIAL_CS8: - dcb.ByteSize = 8; - break; - } - switch ((cflags & (SERIAL_NO_PARITY | SERIAL_PARENB | SERIAL_PARODD))) { - case SERIAL_NO_PARITY: - dcb.Parity = NOPARITY; - break; - case SERIAL_PARENB: - dcb.Parity = EVENPARITY; - break; - case SERIAL_PARODD: - dcb.Parity = ODDPARITY; - break; - } - switch ((cflags & (SERIAL_NO_CSTOPB | SERIAL_CSTOPB))) { - case SERIAL_NO_CSTOPB: - dcb.StopBits = ONESTOPBIT; - break; - case SERIAL_CSTOPB: - dcb.StopBits = TWOSTOPBITS; - break; - } + DCB dcb; + HANDLE hComPort = (HANDLE)fd->pfd; - if (!SetCommState(hComPort, &dcb)) - return -1; - - return 0; + ZeroMemory (&dcb, sizeof(DCB)); + dcb.DCBlength = sizeof(DCB); + dcb.BaudRate = serial_baud_lookup (baud); + dcb.fBinary = 1; + dcb.fDtrControl = DTR_CONTROL_DISABLE; + dcb.fRtsControl = RTS_CONTROL_DISABLE; + switch ((cflags & (SERIAL_CS5 | SERIAL_CS6 | SERIAL_CS7 | SERIAL_CS8))) { + case SERIAL_CS5: + dcb.ByteSize = 5; + break; + case SERIAL_CS6: + dcb.ByteSize = 6; + break; + case SERIAL_CS7: + dcb.ByteSize = 7; + break; + case SERIAL_CS8: + dcb.ByteSize = 8; + break; } + switch ((cflags & (SERIAL_NO_PARITY | SERIAL_PARENB | SERIAL_PARODD))) { + case SERIAL_NO_PARITY: + dcb.Parity = NOPARITY; + break; + case SERIAL_PARENB: + dcb.Parity = EVENPARITY; + break; + case SERIAL_PARODD: + dcb.Parity = ODDPARITY; + break; + } + switch ((cflags & (SERIAL_NO_CSTOPB | SERIAL_CSTOPB))) { + case SERIAL_NO_CSTOPB: + dcb.StopBits = ONESTOPBIT; + break; + case SERIAL_CSTOPB: + dcb.StopBits = TWOSTOPBITS; + break; + } + if (!SetCommState(hComPort, &dcb)) + return -1; + + return 0; } static int net_open(const char *port, union filedescriptor *fdp) { @@ -223,7 +219,7 @@ static int net_open(const char *port, union filedescriptor *fdp) { fdp->ifd = fd; - serial_over_ethernet = 1; + cx->ser_serial_over_ethernet = 1; return 0; } @@ -300,7 +296,7 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f static void ser_close(union filedescriptor *fd) { - if (serial_over_ethernet) { + if (cx->ser_serial_over_ethernet) { closesocket(fd->ifd); WSACleanup(); } else { @@ -313,20 +309,15 @@ static void ser_close(union filedescriptor *fd) { } static int ser_set_dtr_rts(const union filedescriptor *fd, int is_on) { - if (serial_over_ethernet) { + if(cx->ser_serial_over_ethernet) return 0; - } else { - HANDLE hComPort=(HANDLE)fd->pfd; - if (is_on) { - EscapeCommFunction(hComPort, SETDTR); - EscapeCommFunction(hComPort, SETRTS); - } else { - EscapeCommFunction(hComPort, CLRDTR); - EscapeCommFunction(hComPort, CLRRTS); - } - return 0; - } + HANDLE hComPort=(HANDLE)fd->pfd; + + EscapeCommFunction(hComPort, is_on? SETDTR: CLRDTR); + EscapeCommFunction(hComPort, is_on? SETRTS: CLRRTS); + + return 0; } static int net_send(const union filedescriptor *fd, const unsigned char *buf, size_t len) { @@ -370,7 +361,7 @@ static int net_send(const union filedescriptor *fd, const unsigned char *buf, si static int ser_send(const union filedescriptor *fd, const unsigned char *buf, size_t len) { - if (serial_over_ethernet) + if(cx->ser_serial_over_ethernet) return net_send(fd, buf, len); DWORD written; @@ -481,7 +472,7 @@ reselect: } static int ser_recv(const union filedescriptor *fd, unsigned char *buf, size_t buflen) { - if (serial_over_ethernet) + if(cx->ser_serial_over_ethernet) return net_recv(fd, buf, buflen); DWORD read; @@ -603,9 +594,8 @@ static int net_drain(const union filedescriptor *fd, int display) { } static int ser_drain(const union filedescriptor *fd, int display) { - if (serial_over_ethernet) { + if(cx->ser_serial_over_ethernet) return net_drain(fd, display); - } // int rc; unsigned char buf[10]; From 0bc312a9cca0def97dbc09e36c0bbf15f1ad6887 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 17:56:27 +0100 Subject: [PATCH 052/422] Rewrite str_interval() as str_ccinterval() removing static buffer --- src/libavrdude.h | 2 +- src/strutil.c | 19 +++++-------------- src/update.c | 4 ++-- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index f9e7ea61..9f49fc7d 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1488,7 +1488,7 @@ char *str_endnumber(const char *str); const char *str_plural(int x); const char *str_inname(const char *fn); const char *str_outname(const char *fn); -const char *str_interval(int a, int b); +const char *str_ccinterval(int a, int b); bool is_bigendian(void); void change_endian(void *p, int size); int is_memset(const void *p, char c, size_t n); diff --git a/src/strutil.c b/src/strutil.c index 1983bce4..40b19daf 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -412,21 +412,12 @@ const char *str_outname(const char *fn) { return !fn? "???": strcmp(fn, "-")? fn: ""; } -// Return sth like "[0, 0x1ff]" -const char *str_interval(int a, int b) { - // Cyclic buffer for 20+ temporary interval strings each max 41 bytes at 64-bit int - static char space[20*41 + 80], *sp; - if(!sp || sp-space > (int) sizeof space - 80) - sp = space; +// Return sth like "[0, 0x1ff]" in closed-circuit space +const char *str_ccinterval(int a, int b) { + char *ret = avr_cc_buffer(45); // Interval strings each max 45 bytes at 64-bit int - char *ret = sp; - - sprintf(sp, a<16? "[%d": "[0x%x", a); - sp += strlen(sp); - sprintf(sp, b<16? ", %d]": ", 0x%x]", b); - - // Advance beyond return string in temporary ring buffer - sp += strlen(sp)+1; + sprintf(ret, a<16? "[%d": "[0x%x", a); + sprintf(ret+strlen(ret), b<16? ", %d]": ", 0x%x]", b); return ret; } diff --git a/src/update.c b/src/update.c index c99663ce..91554918 100644 --- a/src/update.c +++ b/src/update.c @@ -443,7 +443,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat imsg_info("with %d byte%s in %d section%s within %s\n", fs.nbytes, str_plural(fs.nbytes), fs.nsections, str_plural(fs.nsections), - str_interval(fs.firstaddr, fs.lastaddr)); + str_ccinterval(fs.firstaddr, fs.lastaddr)); if(mem->page_size > 1) { imsg_info("using %d page%s and %d pad byte%s", fs.npages, str_plural(fs.npages), @@ -471,7 +471,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat imsg_notice2("with %d byte%s in %d section%s within %s\n", fs_patched.nbytes, str_plural(fs_patched.nbytes), fs_patched.nsections, str_plural(fs_patched.nsections), - str_interval(fs_patched.firstaddr, fs_patched.lastaddr)); + str_ccinterval(fs_patched.firstaddr, fs_patched.lastaddr)); if(mem->page_size > 1) { imsg_notice2("using %d page%s and %d pad byte%s", fs_patched.npages, str_plural(fs_patched.npages), From de82f8f7e9ec48da5cb7dfa9ce7ec995bc7ff2a5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 17:58:50 +0100 Subject: [PATCH 053/422] Comment use of static variable as r/o cache --- src/strutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strutil.c b/src/strutil.c index 40b19daf..26110862 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1167,7 +1167,7 @@ static size_t csubs(size_t w, unsigned char c1, unsigned char c2) { if(w < 8) w = 8; - static size_t wmat[128][128]; + static size_t wmat[128][128]; // Compute once, read-only cache if(!wmat[0][1]) // Initialize weight matrix for(size_t k1 = 0; k1 < 128; k1++) for(size_t k2 = 0; k2 < 128; k2++) From 500ab6a460c3236d252d188f365a4f90bb96ff48 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 18:22:57 +0100 Subject: [PATCH 054/422] Rope str_sprintf() into mmt_...() family of functions --- src/avrdude.h | 1 + src/avrpart.c | 4 ++-- src/main.c | 4 ++-- src/serialadapter.c | 8 ++++---- src/strutil.c | 4 ++-- src/update.c | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/avrdude.h b/src/avrdude.h index 0ee28466..336690a1 100644 --- a/src/avrdude.h +++ b/src/avrdude.h @@ -44,6 +44,7 @@ extern const char *pgmid; // Programmer -c string #define mmt_strdup(s) cfg_strdup(__func__, s) #define mmt_malloc(n) cfg_malloc(__func__, n) #define mmt_realloc(p, n) cfg_realloc(__func__, p, n) +#define mmt_sprintf(...) str_sprintf(__VA_ARGS__) #define mmt_free(p) free(p) int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int msgmode, int msglvl, const char *format, ...) diff --git a/src/avrpart.c b/src/avrpart.c index 779a803a..3fa0b507 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -766,7 +766,7 @@ int avr_set_config_value(const PROGRAMMER *pgm, const AVRPART *p, const char *cn static char *print_num(const char *fmt, int n) { - return str_sprintf(n<10? "%d": fmt, n); + return mmt_sprintf(n<10? "%d": fmt, n); } static int num_len(const char *fmt, int n) { @@ -835,7 +835,7 @@ void avr_mem_display(FILE *f, const AVRPART *p, const char *prefix) { // Create mem desc string including alias if present AVRMEM_ALIAS *a = avr_find_memalias(p, m); - char *m_desc_str = str_sprintf("%s%s%s", m->desc, a? "/": "", a? a->desc: ""); + char *m_desc_str = mmt_sprintf("%s%s%s", m->desc, a? "/": "", a? a->desc: ""); // Print memory table content if(p->prog_modes & (PM_PDI | PM_UPDI)) { diff --git a/src/main.c b/src/main.c index 68e7689e..ae945bbb 100644 --- a/src/main.c +++ b/src/main.c @@ -218,8 +218,8 @@ static void usage(void) char *home = getenv("HOME"); size_t l = home? strlen(home): 0; char *cfg = home && str_casestarts(usr_config, home)? - str_sprintf("~/%s", usr_config+l+(usr_config[l]=='/')): - str_sprintf("%s", usr_config); + mmt_sprintf("~/%s", usr_config+l+(usr_config[l]=='/')): + mmt_sprintf("%s", usr_config); msg_error( "Usage: %s [options]\n" diff --git a/src/serialadapter.c b/src/serialadapter.c index 1243cfc3..4e8b5859 100644 --- a/src/serialadapter.c +++ b/src/serialadapter.c @@ -217,7 +217,7 @@ static char **sa_list_specs(const SERPORT *sp, int n, int i) { if(sa_unique_by_sea(sea, "", sp, n, i)) Plist[Pi++] = mmt_strdup(id); else if(*sn && sa_unique_by_sea(sea, sn, sp, n, i)) - Plist[Pi++] = str_sprintf("%s:%s", id, sn); + Plist[Pi++] = mmt_sprintf("%s:%s", id, sn); else if(!via && sa_num_matches_by_sea(sea, "", sp+i, 1)) via = id; @@ -232,11 +232,11 @@ static char **sa_list_specs(const SERPORT *sp, int n, int i) { if(Pi == 0 && sp[i].vid) { // No unique serial adapter, so maybe vid:pid[:sn] works? if(sa_unique_by_ids(sp[i].vid, sp[i].pid, "", sp, n, i)) - Plist[Pi++] = str_sprintf("usb:%04x:%04x", sp[i].vid, sp[i].pid); + Plist[Pi++] = mmt_sprintf("usb:%04x:%04x", sp[i].vid, sp[i].pid); else if(*sn && sa_unique_by_ids(sp[i].vid, sp[i].pid, sn, sp, n, i)) - Plist[Pi++] = str_sprintf("usb:%04x:%04x:%s", sp[i].vid, sp[i].pid, sn); + Plist[Pi++] = mmt_sprintf("usb:%04x:%04x:%s", sp[i].vid, sp[i].pid, sn); else if(via && Pi == 0) - Plist[Pi++] = str_sprintf("(via %s serial adapter)", via); + Plist[Pi++] = mmt_sprintf("(via %s serial adapter)", via); } Plist[Pi] = NULL; diff --git a/src/strutil.c b/src/strutil.c index 26110862..f05f9461 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -570,7 +570,7 @@ unsigned long long int str_ull(const char *str, char **endptr, int base) { */ #define Return(...) do { \ - sd->errstr = str_sprintf(__VA_ARGS__); \ + sd->errstr = mmt_sprintf(__VA_ARGS__); \ sd->type = 0; \ mmt_free(str); \ return sd; \ @@ -579,7 +579,7 @@ unsigned long long int str_ull(const char *str, char **endptr, int base) { #define Warning(...) do { \ if(sd->warnstr) \ mmt_free(sd->warnstr); \ - sd->warnstr = str_sprintf(__VA_ARGS__); \ + sd->warnstr = mmt_sprintf(__VA_ARGS__); \ } while (0) #define sizeforsigned(ll) ( \ diff --git a/src/update.c b/src/update.c index 91554918..8a0e09f2 100644 --- a/src/update.c +++ b/src/update.c @@ -133,9 +133,9 @@ void free_update(UPDATE *u) { char *update_str(const UPDATE *upd) { if(upd->cmdline) - return str_sprintf("-%c %s", + return mmt_sprintf("-%c %s", str_eq("interactive terminal", upd->cmdline)? 't': 'T', upd->cmdline); - return str_sprintf("-U %s:%c:%s:%c", + return mmt_sprintf("-U %s:%c:%s:%c", upd->memstr, upd->op == DEVICE_READ? 'r': upd->op == DEVICE_WRITE? 'w': 'v', upd->filename, From befcc6cf3da9cd4d545e95f685d992e4070d8722 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 18:38:28 +0100 Subject: [PATCH 055/422] Provide and use str_ccprintf() for temporary strings in closed-circuit space --- src/avrftdi.c | 15 ++++++--------- src/libavrdude.h | 7 ++++++- src/strutil.c | 45 ++++++++++++++++++++++++++++++++++----------- src/term.c | 13 ++++--------- 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index 8adede7d..271c933c 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -176,22 +176,19 @@ static int set_frequency(avrftdi_t* ftdi, uint32_t freq) } if (divisor < 0) { - char *f = str_frq(freq, 6), *h = str_frq(clock/2.0, 6); - pmsg_warning("frequency %s too high, resetting to %s\n", f, h); - mmt_free(f); mmt_free(h); + pmsg_warning("frequency %s too high, resetting to %s\n", + str_ccfrq(freq, 6), str_ccfrq(clock/2.0, 6)); divisor = 0; } if (divisor > 65535) { - char *f = str_frq(freq, 6), *l = str_frq(clock/2.0 / 65536, 6); - pmsg_warning("frequency %s too low, resetting to %s\n", f, l); - mmt_free(f); mmt_free(l); + pmsg_warning("frequency %s too low, resetting to %s\n", + str_ccfrq(freq, 6), str_ccfrq(clock/2.0 / 65536, 6)); divisor = 65535; } - char *f = str_frq(clock/2.0 / (divisor + 1), 6); - imsg_notice(" - frequency %s (clock divisor %d = 0x%04x)\n", f, divisor, divisor); - mmt_free(f); + imsg_notice(" - frequency %s (clock divisor %d = 0x%04x)\n", + str_ccfrq(clock/2.0 / (divisor + 1), 6), divisor, divisor); *ptr++ = TCK_DIVISOR; *ptr++ = (uint8_t)(divisor & 0xff); diff --git a/src/libavrdude.h b/src/libavrdude.h index 9f49fc7d..5705e049 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1478,6 +1478,11 @@ char *str_sprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) #endif ; +const char *str_ccprintf(const char *fmt, ...) +#if defined(__GNUC__) + __attribute__ ((format (printf, 1, 2))) +#endif +; char *str_fgets(FILE *fp, const char **errpp); char *str_lc(char *s); char *str_uc(char *s); @@ -1498,7 +1503,7 @@ void str_freedata(Str2data *sd); unsigned long long int str_int(const char *str, int type, const char **errpp); int str_membuf(const char *str, int type, unsigned char *buf, int size, const char **errpp); char *str_nexttok(char *buf, const char *delim, char **next); -char *str_frq(double f, int n); +const char *str_ccfrq(double f, int n); int str_levenshtein(const char *str1, const char *str2, int swap, int subst, int add, int del); size_t str_weighted_damerau_levenshtein(const char *str1, const char *str2); diff --git a/src/strutil.c b/src/strutil.c index f05f9461..58bf49e0 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -255,6 +255,33 @@ char *str_sprintf(const char *fmt, ...) { return p; } +// Return a string in closed-circuit space with the sprintf() result +const char *str_ccprintf(const char *fmt, ...) { + int size = 0, avail = sizeof cx->avr_space - AVR_SAFETY_MARGIN; + va_list ap; + + // Compute size + va_start(ap, fmt); + size = vsnprintf(NULL, size, fmt, ap); + va_end(ap); + + if(size < 0) + return ""; + + size++; // For terminating '\0' + if(size > avail) + size = avail; + char *p = avr_cc_buffer(size); + + va_start(ap, fmt); + size = vsnprintf(p, size, fmt, ap); + va_end(ap); + + if(size < 0) + *p = 0; + + return p; +} // Reads a potentially long line and returns it in a mmt_malloc'd buffer char *str_fgets(FILE *fp, const char **errpp) { @@ -877,7 +904,6 @@ void str_freedata(Str2data *sd) { */ unsigned long long int str_int(const char *str, int type, const char **errpp) { - char *tofree; const char *err = NULL; Str2data *sd = NULL; unsigned long long int ret = 0ULL; @@ -919,20 +945,17 @@ unsigned long long int str_int(const char *str, int type, const char **errpp) { if(signd == STR_SIGNED) { // Strictly signed if(sd->ll < smin[lds] || sd->ll > smax[lds]) { - err = cache_string(tofree=str_sprintf("out of int%d range", 1<<(3+lds))); - mmt_free(tofree); + err = cache_string(str_ccprintf("out of int%d range", 1<<(3+lds))); goto finished; } } else if(signd == STR_UNSIGNED) { // Strictly unsigned are out of range if u and -u are if(sd->ull > umax[lds] && ~sd->ull+1 > umax[lds]) { - err = cache_string(tofree=str_sprintf("out of uint%d range", 1<<(3+lds))); - mmt_free(tofree); + err = cache_string(str_ccprintf("out of uint%d range", 1<<(3+lds))); goto finished; } } else { // Neither strictly signed or unsigned if((sd->ll < smin[lds] || sd->ll > smax[lds]) && sd->ull > umax[lds] && ~sd->ull+1 > umax[lds]) { - err = cache_string(tofree=str_sprintf("out of int%d and uint%d range", 1<<(3+lds), 1<<(3+lds))); - mmt_free(tofree); + err = cache_string(str_ccprintf("out of int%d and uint%d range", 1<<(3+lds), 1<<(3+lds))); goto finished; } } @@ -1028,14 +1051,14 @@ char *str_nexttok(char *buf, const char *delim, char **next) { return (char *) q; } -// Return mmt_malloc'd string for frequency with n significant digits and xHz unit -char *str_frq(double f, int n) { +// Return string for frequency with n significant digits and xHz unit in closed-circuit space +const char *str_ccfrq(double f, int n) { struct { double fq; const char *pre; } prefix[] = {{1e9, "G"}, {1e6, "M"}, {1e3, "k"},}; for(size_t i = 0; i < sizeof prefix/sizeof*prefix; i++) if(f >= prefix[i].fq) - return str_sprintf("%.*g %sHz", n, f/prefix[i].fq, prefix[i].pre); - return str_sprintf("%.*g Hz", n, f); + return str_ccprintf("%.*g %sHz", n, f/prefix[i].fq, prefix[i].pre); + return str_ccprintf("%.*g Hz", n, f); } /* diff --git a/src/term.c b/src/term.c index d39d7850..54852be0 100644 --- a/src/term.c +++ b/src/term.c @@ -965,15 +965,13 @@ typedef struct { // Context parameters to be passed to functions // Cache the contents of the fuse and lock bits memories that a particular Configitem is involved in static int getfusel(const PROGRAMMER *pgm, const AVRPART *p, Fusel_t *fl, const Cfg_t *cci, const char **errpp) { const char *err = NULL; - char *tofree; int islock; islock = str_starts(cci->memstr, "lock"); if((islock && cci->t->memoffset != 0) || (!islock && (cci->t->memoffset < 0 || cci->t->memoffset >= (int) (sizeof fl->fuses/sizeof*fl->fuses)))) { - err = cache_string(tofree = str_sprintf("%s's %s has invalid memoffset %d", p->desc, cci->memstr, cci->t->memoffset)); - mmt_free(tofree); + err = cache_string(str_ccprintf("%s's %s has invalid memoffset %d", p->desc, cci->memstr, cci->t->memoffset)); goto back; } @@ -991,22 +989,19 @@ static int getfusel(const PROGRAMMER *pgm, const AVRPART *p, Fusel_t *fl, const const AVRMEM *mem = avr_locate_mem(p, cci->memstr); if(!mem) { - err = cache_string(tofree = str_sprintf("memory %s not defined for part %s", cci->memstr, p->desc)); - mmt_free(tofree); + err = cache_string(str_ccprintf("memory %s not defined for part %s", cci->memstr, p->desc)); goto back; } if((islock && mem->size != 4 && mem->size != 1) || (!islock && mem->size != 2 && mem->size != 1)) { - err = cache_string(tofree = str_sprintf("%s's %s memory has unexpected size %d", p->desc, mem->desc, mem->size)); - mmt_free(tofree); + err = cache_string(str_ccprintf("%s's %s memory has unexpected size %d", p->desc, mem->desc, mem->size)); goto back; } fl_t m = {.i = 0}; for(int i=0; isize; i++) if(led_read_byte(pgm, p, mem, i, m.b+i) < 0) { - err = cache_string(tofree = str_sprintf("cannot read %s's %s memory", p->desc, mem->desc)); - mmt_free(tofree); + err = cache_string(str_ccprintf("cannot read %s's %s memory", p->desc, mem->desc)); goto back; } From 3dcc51f5c1fe845d03db62cfce087c6ad7ba6972 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 19:13:38 +0100 Subject: [PATCH 056/422] Provide str_ccstrdup() to create a temporary string in closed-circuit space --- src/libavrdude.h | 1 + src/strutil.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index 5705e049..4694f01a 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1483,6 +1483,7 @@ const char *str_ccprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) #endif ; +const char *str_ccstrdup(const char *str); char *str_fgets(FILE *fp, const char **errpp); char *str_lc(char *s); char *str_uc(char *s); diff --git a/src/strutil.c b/src/strutil.c index 58bf49e0..85369026 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -283,6 +283,19 @@ const char *str_ccprintf(const char *fmt, ...) { return p; } +// Returns a temporary, possibly abbreviated copy of str in closed-circuit space +const char *str_ccstrdup(const char *str) { + size_t size = strlen(str) + 1, avail = sizeof cx->avr_space - AVR_SAFETY_MARGIN; + if(size > avail) + size = avail; + char *ret = avr_cc_buffer(size); + strncpy(ret, str, size); + ret[size-1] = 0; + + return ret; +} + + // Reads a potentially long line and returns it in a mmt_malloc'd buffer char *str_fgets(FILE *fp, const char **errpp) { int bs = 1023; // Must be 2^n - 1 From a22f2d8d415ca693a6334b0f71ff93b15f1ff059 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 19:28:13 +0100 Subject: [PATCH 057/422] Revert to pin_to_str() and pinmask_to_str() --- src/avrftdi.c | 29 +++++++++++------------------ src/developer_opts.c | 7 ++----- src/libavrdude.h | 8 ++++---- src/pgm.c | 3 +-- src/pindefs.c | 32 +++++++++++--------------------- 5 files changed, 29 insertions(+), 50 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index 271c933c..b4f21e2b 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -219,11 +219,9 @@ static int set_pin(const PROGRAMMER *pgm, int pinfunc, int value) { return 0; } - char *pmsk = pinmask_to_strdup(pin.mask); - pmsg_debug("setting pin %s (%s) as %s: %s (%s active)\n", pmsk, - ftdi_pin_name(pdata, pin), avr_pin_name(pinfunc), + pmsg_debug("setting pin %s (%s) as %s: %s (%s active)\n", + pinmask_to_str(pin.mask), ftdi_pin_name(pdata, pin), avr_pin_name(pinfunc), (value) ? "high" : "low", (pin.inverse[0]) ? "low" : "high"); - mmt_free(pmsk); pdata->pin_value = SET_BITS_0(pdata->pin_value, pgm, pinfunc, value); @@ -599,26 +597,21 @@ static int avrftdi_pin_setup(const PROGRAMMER *pgm) { avrftdi_check_pins_bb(pgm, true); imsg_error("pin configuration for FTDI MPSSE must be:\n"); if (pgm->flag == PGM_FL_IS_JTAG) { - char *ptck = pins_to_strdup(&pgm->pin[PIN_JTAG_TCK]), - *ptdi = pins_to_strdup(&pgm->pin[PIN_JTAG_TDI]), - *ptdo = pins_to_strdup(&pgm->pin[PIN_JTAG_TDO]), - *ptms = pins_to_strdup(&pgm->pin[PIN_JTAG_TMS]); imsg_error("%s: 0; %s: 1; %s: 2; %s: 3 (is: %s; %s; %s; %s)\n", avr_pin_name(PIN_JTAG_TCK), avr_pin_name(PIN_JTAG_TDI), avr_pin_name(PIN_JTAG_TDO), avr_pin_name(PIN_JTAG_TMS), - *ptck? ptck: "?", *ptdi? ptdi: "?", - *ptdo? ptdo: "?", *ptms? ptms: "?"); - mmt_free(ptck); mmt_free(ptdi); mmt_free(ptdo); mmt_free(ptms); + pins_to_str(&pgm->pin[PIN_JTAG_TCK]), + pins_to_str(&pgm->pin[PIN_JTAG_TDI]), + pins_to_str(&pgm->pin[PIN_JTAG_TDO]), + pins_to_str(&pgm->pin[PIN_JTAG_TMS])); } else { - char *psck = pins_to_strdup(&pgm->pin[PIN_AVR_SCK]), - *psdo = pins_to_strdup(&pgm->pin[PIN_AVR_SDO]), - *psdi = pins_to_strdup(&pgm->pin[PIN_AVR_SDI]); imsg_error("%s: 0; %s: 1; %s: 2 (is: %s; %s; %s)\n", - avr_pin_name(PIN_AVR_SCK), avr_pin_name(PIN_AVR_SDO), + avr_pin_name(PIN_AVR_SCK), + avr_pin_name(PIN_AVR_SDO), avr_pin_name(PIN_AVR_SDI), - *psck? psck: "?", *psdo? psdo: "?", - *psdi? psdi: "?"); - mmt_free(psck); mmt_free(psdo); mmt_free(psdi); + pins_to_str(&pgm->pin[PIN_AVR_SCK]), + pins_to_str(&pgm->pin[PIN_AVR_SDO]), + pins_to_str(&pgm->pin[PIN_AVR_SDI])); } imsg_error("if other pin configuration is used, fallback to slower bitbanging mode is used\n"); diff --git a/src/developer_opts.c b/src/developer_opts.c index 94d810d8..6faf58e3 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -1304,13 +1304,10 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas _if_pgmout_str(strcmp, cfg_escape(pgm->usbproduct), usbproduct); for(int i=0; ipin+i); - char *bstr = base? pins_to_strdup(base->pin+i): NULL; + const char *str = pins_to_str(pgm->pin+i); + const char *bstr = base? pins_to_str(base->pin+i): NULL; if(!base || !str_eq(bstr, str)) _pgmout_fmt(avr_pin_lcname(i), "%s", str); - - mmt_free(str); - mmt_free(bstr); } pgmstr = dev_hvupdi_support_liststr(pgm); diff --git a/src/libavrdude.h b/src/libavrdude.h index 4694f01a..5a8859f1 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -751,18 +751,18 @@ const char * avr_pin_lcname(int pinname); * 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 - * @returns a string that was created by mmt_strdup() + * @returns a temporary string that lives in closed-circuit space */ -char *pins_to_strdup(const struct pindef_t * const pindef); +const char *pins_to_str(const struct pindef_t * const pindef); /** * This function returns a string representation of pins in the mask, eg, 1, 3, 5-7, 9, 12 * Consecutive pin numbers are represented as start-end. * * @param[in] pinmask the pin mask for which we want the string representation - * @returns a string that was created by mmt_strdup() + * @returns a temporary string that lives in closed-circuit space */ -char *pinmask_to_strdup(const pinmask_t * const pinmask); +const char *pinmask_to_str(const pinmask_t * const pinmask); /* formerly serial.h */ diff --git a/src/pgm.c b/src/pgm.c index fae3f2b5..5456c3d8 100644 --- a/src/pgm.c +++ b/src/pgm.c @@ -289,9 +289,8 @@ void programmer_display(PROGRAMMER *pgm, const char * p) { void pgm_display_generic_mask(const PROGRAMMER *pgm, const char *p, unsigned int show) { for(int pbit = 1; pbit < N_PINS; pbit++) if(show & (1<pin + pbit); + const char *pinstr = pins_to_str(pgm->pin + pbit); msg_info("%s %-6s = %s\n", p, avr_pin_name(pbit), *pinstr? pinstr: "(not used)"); - mmt_free(pinstr); } } diff --git a/src/pindefs.c b/src/pindefs.c index 5548a7b0..f0384749 100644 --- a/src/pindefs.c +++ b/src/pindefs.c @@ -156,9 +156,9 @@ int pgm_fill_old_pins(PROGRAMMER * const pgm) { * Consecutive pin numbers are represented as start-end. * * @param[in] pinmask the pin mask for which we want the string representation - * @returns a string that was created by mmt_strdup() + * @returns a temporary string that lives in closed-circuit space */ -char *pinmask_to_strdup(const pinmask_t * const pinmask) { +const char *pinmask_to_str(const pinmask_t * const pinmask) { char buf[6 * (PIN_MAX + 1)]; char *p = buf; int n; @@ -196,7 +196,7 @@ char *pinmask_to_strdup(const pinmask_t * const pinmask) { p += n; } - return mmt_strdup(*buf? buf: "(no pins)"); + return str_ccstrdup(*buf? buf: "(no pins)"); } @@ -269,36 +269,26 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const } if(invalid) { if(output) { - char *mskinvalid = pinmask_to_strdup(invalid_used); pmsg_error("%s: these pins are not valid pins for this function: %s\n", - avr_pin_name(pinname), mskinvalid); - mmt_free(mskinvalid); - char *mskvalid = pinmask_to_strdup(valid_pins->mask); + avr_pin_name(pinname), pinmask_to_str(invalid_used)); pmsg_notice("%s: valid pins for this function are: %s\n", - avr_pin_name(pinname), mskvalid); - mmt_free(mskvalid); + avr_pin_name(pinname), pinmask_to_str(valid_pins->mask)); } is_ok = false; } if(inverse) { if(output) { - char *mskinvalidinv = pinmask_to_strdup(inverse_used); pmsg_error("%s: these pins are not usable as inverse pins for this function: %s\n", - avr_pin_name(pinname), mskinvalidinv); - mmt_free(mskinvalidinv); - char *mskvalidinv = pinmask_to_strdup(valid_pins->inverse); + avr_pin_name(pinname), pinmask_to_str(inverse_used)); pmsg_notice("%s: valid inverse pins for this function are: %s\n", - avr_pin_name(pinname), mskvalidinv); - mmt_free(mskvalidinv); + avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse)); } is_ok = false; } if(used) { if(output) { - char *pmsk = pinmask_to_strdup(already_used); pmsg_error("%s: these pins are set for other functions too: %s\n", - avr_pin_name(pinname), pmsk); - mmt_free(pmsk); + avr_pin_name(pinname), pinmask_to_str(already_used)); is_ok = false; } } @@ -322,9 +312,9 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const * 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 - * @returns a string that was created by mmt_strdup() + * @returns a temporary string that lives in closed-circuit space */ -char *pins_to_strdup(const struct pindef_t * const pindef) { +const char *pins_to_str(const struct pindef_t * const pindef) { char buf[6*(PIN_MAX+1)], *p = buf; *buf = 0; @@ -337,7 +327,7 @@ char *pins_to_strdup(const struct pindef_t * const pindef) { } } - return mmt_strdup(buf); + return str_ccstrdup(buf); } /** From 7936f0049fcf805dc39de3dd8a28b64253c7de8c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 19:34:07 +0100 Subject: [PATCH 058/422] Change static buffer to closed-circuit buffer in term.c --- src/term.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/term.c b/src/term.c index 54852be0..dbecf215 100644 --- a/src/term.c +++ b/src/term.c @@ -1100,8 +1100,8 @@ static int gatherval(const PROGRAMMER *pgm, const AVRPART *p, Cfg_t *cc, int i, } // Comment printed next to symbolic value -static char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, int value, Cfg_opts_t o) { - static char buf[512], bin[129]; +static const char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, int value, Cfg_opts_t o) { + char buf[512], bin[129]; unsigned u = value, m = cti->mask >> cti->lsh; int lsh = cti->lsh; @@ -1135,7 +1135,7 @@ static char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, int va strcat(buf+strlen(buf), "factory"); strcat(buf+strlen(buf), ")"); } - return buf; + return str_ccstrdup(buf); } // How a single property is printed From 531b00dd91e29d08a1184a8a2d96ad30b1e89d24 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 21:01:08 +0100 Subject: [PATCH 059/422] Rename last and done variables --- src/term.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/term.c b/src/term.c index dbecf215..b54f4d72 100644 --- a/src/term.c +++ b/src/term.c @@ -2686,14 +2686,15 @@ static int cmd_include(const PROGRAMMER *pgm, const AVRPART *p, int argc, const */ static void update_progress_tty(int percent, double etime, const char *hdr, int finish) { static char *header; - static int last, done = 1; + static int term_tty_last, term_tty_todo; int i; - setvbuf(stderr, (char *) NULL, _IONBF, 0); // Set stderr to be ubuffered + setvbuf(stderr, (char *) NULL, _IONBF, 0); // Set stderr to be ubuffered if(hdr) { lmsg_info(""); // Print new line unless already done before - last = done = 0; // OK, we have a header, start reporting + term_tty_last = 0; + term_tty_todo = 1; // OK, we have a header, start reporting if(header) mmt_free(header); header = mmt_strdup(hdr); @@ -2701,11 +2702,11 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int percent = percent > 100? 100: percent < 0? 0: percent; - if(!done) { + if(term_tty_todo) { if(!header) header = mmt_strdup("report"); - int showperc = finish >= 0? percent: last; + int showperc = finish >= 0? percent: term_tty_last; char hashes[51]; memset(hashes, finish >= 0? ' ': '-', 50); @@ -2718,16 +2719,16 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int if(percent == 100) { if(finish) lmsg_info(""); - done = 1; // Stop future reporting + term_tty_todo = 0; // Stop future reporting } } - last = percent; + term_tty_last = percent; setvbuf(stderr, (char *) NULL, _IOLBF, 0); // Set stderr to be line buffered } static void update_progress_no_tty(int percent, double etime, const char *hdr, int finish) { - static int last, done = 1; + static int term_notty_last, term_notty_todo; setvbuf(stderr, (char *) NULL, _IONBF, 0); @@ -2735,21 +2736,22 @@ static void update_progress_no_tty(int percent, double etime, const char *hdr, i if(hdr) { lmsg_info("%s | ", hdr); - last = done = 0; + term_notty_last = 0; + term_notty_todo = 1; } - if(!done) { - for(int cnt = percent/2; cnt > last/2; cnt--) + if(term_notty_todo) { + for(int cnt = percent/2; cnt > term_notty_last/2; cnt--) msg_info(finish >= 0? "#": "-"); if(percent == 100) { - msg_info(" | %d%% %0.2fs", finish >= 0? 100: last, etime); + msg_info(" | %d%% %0.2fs", finish >= 0? 100: term_notty_last, etime); if(finish) lmsg_info(""); - done = 1; + term_notty_todo = 0; } } - last = percent; + term_notty_last = percent; setvbuf(stderr, (char *) NULL, _IOLBF, 0); } From fff80ea3193b19d39384340e08972b311f882638 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 21:09:56 +0100 Subject: [PATCH 060/422] Rename static int i and static char *header --- src/term.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/term.c b/src/term.c index b54f4d72..ad563d24 100644 --- a/src/term.c +++ b/src/term.c @@ -211,7 +211,8 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha int len; const AVRMEM *mem; } read_mem[32]; - static int i; + static int term_mi; + int i = term_mi; const char *cmd = tolower(**argv) == 'd'? "dump": "read"; if ((argc < 2 && read_mem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { @@ -266,6 +267,7 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha pmsg_error("(%s) read_mem[] under-dimensioned; increase and recompile\n", cmd); return -1; } + term_mi = i; // Get start address if present const char *errptr; @@ -2685,7 +2687,7 @@ static int cmd_include(const PROGRAMMER *pgm, const AVRPART *p, int argc, const * 1 terminate progress bar with \n when finishing at 100 percent */ static void update_progress_tty(int percent, double etime, const char *hdr, int finish) { - static char *header; + static char *term_header; static int term_tty_last, term_tty_todo; int i; @@ -2695,16 +2697,16 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int lmsg_info(""); // Print new line unless already done before term_tty_last = 0; term_tty_todo = 1; // OK, we have a header, start reporting - if(header) - mmt_free(header); - header = mmt_strdup(hdr); + if(term_header) + mmt_free(term_header); + term_header = mmt_strdup(hdr); } percent = percent > 100? 100: percent < 0? 0: percent; if(term_tty_todo) { - if(!header) - header = mmt_strdup("report"); + if(!term_header) + term_header = mmt_strdup("report"); int showperc = finish >= 0? percent: term_tty_last; @@ -2715,7 +2717,7 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int hashes[50] = 0; // Overwrite line using \r - msg_info("\r%s | %s | %d%% %0.2f s ", header, hashes, showperc, etime); + msg_info("\r%s | %s | %d%% %0.2f s ", term_header, hashes, showperc, etime); if(percent == 100) { if(finish) lmsg_info(""); From a97f0f8eb4b399d93425670e3c88d3d4d4b145e1 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 21:18:13 +0100 Subject: [PATCH 061/422] Rename static read_mem --- src/term.c | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/term.c b/src/term.c index ad563d24..de5a0ace 100644 --- a/src/term.c +++ b/src/term.c @@ -210,12 +210,12 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha int addr; int len; const AVRMEM *mem; - } read_mem[32]; + } term_rmem[32]; static int term_mi; int i = term_mi; const char *cmd = tolower(**argv) == 'd'? "dump": "read"; - if ((argc < 2 && read_mem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { + if ((argc < 2 && term_rmem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { msg_error( "Syntax: %s # display entire region\n" " %s # start at \n" @@ -239,7 +239,7 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha if(argc > 1) memstr = argv[1]; else - memstr = read_mem[i].mem->desc; + memstr = term_rmem[i].mem->desc; const AVRMEM *mem = avr_locate_mem(p, memstr); if (mem == NULL) { pmsg_error("(%s) memory %s not defined for part %s\n", cmd, memstr, p->desc); @@ -252,19 +252,19 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha return -1; } - // Iterate through the read_mem structs to find relevant address and length info + // Iterate through the term_rmem structs to find relevant address and length info for(i = 0; i < 32; i++) { - if(read_mem[i].mem == NULL) - read_mem[i].mem = mem; - if(read_mem[i].mem == mem) { - if(read_mem[i].len == 0) - read_mem[i].len = maxsize > read_size? read_size: maxsize; + if(term_rmem[i].mem == NULL) + term_rmem[i].mem = mem; + if(term_rmem[i].mem == mem) { + if(term_rmem[i].len == 0) + term_rmem[i].len = maxsize > read_size? read_size: maxsize; break; } } if(i >= 32) { // Catch highly unlikely case - pmsg_error("(%s) read_mem[] under-dimensioned; increase and recompile\n", cmd); + pmsg_error("(%s) term_rmem[] under-dimensioned; increase and recompile\n", cmd); return -1; } term_mi = i; @@ -288,15 +288,15 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha cmd, mem->desc, argv[2], digits, maxsize, digits, maxsize-1); return -1; } - read_mem[i].addr = addr; + term_rmem[i].addr = addr; } // Get number of bytes to read if present if (argc >= 3) { if(str_eq(argv[argc - 1], "...")) { if (argc == 3) - read_mem[i].addr = 0; - read_mem[i].len = maxsize - read_mem[i].addr; + term_rmem[i].addr = 0; + term_rmem[i].len = maxsize - term_rmem[i].addr; } else if (argc == 4) { int len = str_int(argv[3], STR_INT32, &errptr); if(errptr) { @@ -306,7 +306,7 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha // Turn negative len value (number of bytes from top of memory) into an actual length if (len < 0) - len = maxsize + len + 1 - read_mem[i].addr; + len = maxsize + len + 1 - term_rmem[i].addr; if (len == 0) return 0; @@ -314,43 +314,43 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha pmsg_error("(%s) invalid effective length %d\n", cmd, len); return -1; } - read_mem[i].len = len; + term_rmem[i].len = len; } } // Wrap around if the memory address is greater than the maximum size - if(read_mem[i].addr >= maxsize) - read_mem[i].addr = 0; // Wrap around + if(term_rmem[i].addr >= maxsize) + term_rmem[i].addr = 0; // Wrap around // Trim len if nessary to prevent reading from the same memory address twice - if (read_mem[i].len > maxsize) - read_mem[i].len = maxsize; + if (term_rmem[i].len > maxsize) + term_rmem[i].len = maxsize; - uint8_t *buf = mmt_malloc(read_mem[i].len); + uint8_t *buf = mmt_malloc(term_rmem[i].len); if(argc < 4 && verbose) - term_out(">>> %s %s 0x%x 0x%x\n", cmd, read_mem[i].mem->desc, read_mem[i].addr, read_mem[i].len); + term_out(">>> %s %s 0x%x 0x%x\n", cmd, term_rmem[i].mem->desc, term_rmem[i].addr, term_rmem[i].len); report_progress(0, 1, "Reading"); - for (int j = 0; j < read_mem[i].len; j++) { - int addr = (read_mem[i].addr + j) % mem->size; - int rc = pgm->read_byte_cached(pgm, p, read_mem[i].mem, addr, &buf[j]); + for (int j = 0; j < term_rmem[i].len; j++) { + int addr = (term_rmem[i].addr + j) % mem->size; + int rc = pgm->read_byte_cached(pgm, p, term_rmem[i].mem, addr, &buf[j]); if (rc != 0) { report_progress(1, -1, NULL); - pmsg_error("(%s) error reading %s address 0x%05lx of part %s\n", cmd, mem->desc, (long) read_mem[i].addr + j, p->desc); + pmsg_error("(%s) error reading %s address 0x%05lx of part %s\n", cmd, mem->desc, (long) term_rmem[i].addr + j, p->desc); if (rc == -1) imsg_error("%*sread operation not supported on memory %s\n", 7, "", mem->desc); mmt_free(buf); return -1; } - report_progress(j, read_mem[i].len, NULL); + report_progress(j, term_rmem[i].len, NULL); } report_progress(1, 1, NULL); - hexdump_buf(stdout, mem, read_mem[i].addr, buf, read_mem[i].len); + hexdump_buf(stdout, mem, term_rmem[i].addr, buf, term_rmem[i].len); lterm_out(""); mmt_free(buf); - read_mem[i].addr = (read_mem[i].addr + read_mem[i].len) % maxsize; + term_rmem[i].addr = (term_rmem[i].addr + term_rmem[i].len) % maxsize; return 0; } From adb4feff866a8ae0733b8440aae7dc7c0ea5dd8b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 21:38:26 +0100 Subject: [PATCH 062/422] Put static variables of term.c in context structure --- src/libavrdude.h | 14 +++++ src/term.c | 146 ++++++++++++++++++++++------------------------- 2 files changed, 81 insertions(+), 79 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 5a8859f1..e6a8970b 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1598,6 +1598,20 @@ typedef struct { struct termios ser_original_termios; int ser_saved_original_termios; #endif + + // Static variables from term.c + int term_spi_mode; + struct mem_addr_len { + const AVRMEM *mem; + int addr, len; + } term_rmem[32]; + int term_mi; + const PROGRAMMER *term_pgm; + const AVRPART *term_p; + int term_running; + char *term_header; + int term_tty_last, term_tty_todo; + int term_notty_last, term_notty_todo; } cx_t; extern cx_t *cx; diff --git a/src/term.c b/src/term.c index de5a0ace..9e731063 100644 --- a/src/term.c +++ b/src/term.c @@ -126,7 +126,7 @@ struct command cmd[] = { #define NCMDS ((int)(sizeof(cmd)/sizeof(struct command))) -static int spi_mode = 0; +#define spi_mode (cx->term_spi_mode) static int hexdump_line(char *buffer, unsigned char *p, int n, int pad) { char *hexdata = "0123456789abcdef"; @@ -206,16 +206,10 @@ static int hexdump_buf(const FILE *f, const AVRMEM *m, int startaddr, const unsi static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { - static struct mem_addr_len { - int addr; - int len; - const AVRMEM *mem; - } term_rmem[32]; - static int term_mi; - int i = term_mi; + int i = cx->term_mi; const char *cmd = tolower(**argv) == 'd'? "dump": "read"; - if ((argc < 2 && term_rmem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { + if ((argc < 2 && cx->term_rmem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { msg_error( "Syntax: %s # display entire region\n" " %s # start at \n" @@ -239,7 +233,7 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha if(argc > 1) memstr = argv[1]; else - memstr = term_rmem[i].mem->desc; + memstr = cx->term_rmem[i].mem->desc; const AVRMEM *mem = avr_locate_mem(p, memstr); if (mem == NULL) { pmsg_error("(%s) memory %s not defined for part %s\n", cmd, memstr, p->desc); @@ -252,22 +246,22 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha return -1; } - // Iterate through the term_rmem structs to find relevant address and length info + // Iterate through the cx->term_rmem structs to find relevant address and length info for(i = 0; i < 32; i++) { - if(term_rmem[i].mem == NULL) - term_rmem[i].mem = mem; - if(term_rmem[i].mem == mem) { - if(term_rmem[i].len == 0) - term_rmem[i].len = maxsize > read_size? read_size: maxsize; + if(cx->term_rmem[i].mem == NULL) + cx->term_rmem[i].mem = mem; + if(cx->term_rmem[i].mem == mem) { + if(cx->term_rmem[i].len == 0) + cx->term_rmem[i].len = maxsize > read_size? read_size: maxsize; break; } } if(i >= 32) { // Catch highly unlikely case - pmsg_error("(%s) term_rmem[] under-dimensioned; increase and recompile\n", cmd); + pmsg_error("(%s) cx->term_rmem[] under-dimensioned; increase and recompile\n", cmd); return -1; } - term_mi = i; + cx->term_mi = i; // Get start address if present const char *errptr; @@ -288,15 +282,15 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha cmd, mem->desc, argv[2], digits, maxsize, digits, maxsize-1); return -1; } - term_rmem[i].addr = addr; + cx->term_rmem[i].addr = addr; } // Get number of bytes to read if present if (argc >= 3) { if(str_eq(argv[argc - 1], "...")) { if (argc == 3) - term_rmem[i].addr = 0; - term_rmem[i].len = maxsize - term_rmem[i].addr; + cx->term_rmem[i].addr = 0; + cx->term_rmem[i].len = maxsize - cx->term_rmem[i].addr; } else if (argc == 4) { int len = str_int(argv[3], STR_INT32, &errptr); if(errptr) { @@ -306,7 +300,7 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha // Turn negative len value (number of bytes from top of memory) into an actual length if (len < 0) - len = maxsize + len + 1 - term_rmem[i].addr; + len = maxsize + len + 1 - cx->term_rmem[i].addr; if (len == 0) return 0; @@ -314,43 +308,45 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha pmsg_error("(%s) invalid effective length %d\n", cmd, len); return -1; } - term_rmem[i].len = len; + cx->term_rmem[i].len = len; } } // Wrap around if the memory address is greater than the maximum size - if(term_rmem[i].addr >= maxsize) - term_rmem[i].addr = 0; // Wrap around + if(cx->term_rmem[i].addr >= maxsize) + cx->term_rmem[i].addr = 0; // Wrap around // Trim len if nessary to prevent reading from the same memory address twice - if (term_rmem[i].len > maxsize) - term_rmem[i].len = maxsize; + if (cx->term_rmem[i].len > maxsize) + cx->term_rmem[i].len = maxsize; - uint8_t *buf = mmt_malloc(term_rmem[i].len); + uint8_t *buf = mmt_malloc(cx->term_rmem[i].len); if(argc < 4 && verbose) - term_out(">>> %s %s 0x%x 0x%x\n", cmd, term_rmem[i].mem->desc, term_rmem[i].addr, term_rmem[i].len); + term_out(">>> %s %s 0x%x 0x%x\n", cmd, cx->term_rmem[i].mem->desc, + cx->term_rmem[i].addr, cx->term_rmem[i].len); report_progress(0, 1, "Reading"); - for (int j = 0; j < term_rmem[i].len; j++) { - int addr = (term_rmem[i].addr + j) % mem->size; - int rc = pgm->read_byte_cached(pgm, p, term_rmem[i].mem, addr, &buf[j]); + for (int j = 0; j < cx->term_rmem[i].len; j++) { + int addr = (cx->term_rmem[i].addr + j) % mem->size; + int rc = pgm->read_byte_cached(pgm, p, cx->term_rmem[i].mem, addr, &buf[j]); if (rc != 0) { report_progress(1, -1, NULL); - pmsg_error("(%s) error reading %s address 0x%05lx of part %s\n", cmd, mem->desc, (long) term_rmem[i].addr + j, p->desc); + pmsg_error("(%s) error reading %s address 0x%05lx of part %s\n", cmd, mem->desc, + (long) cx->term_rmem[i].addr + j, p->desc); if (rc == -1) imsg_error("%*sread operation not supported on memory %s\n", 7, "", mem->desc); mmt_free(buf); return -1; } - report_progress(j, term_rmem[i].len, NULL); + report_progress(j, cx->term_rmem[i].len, NULL); } report_progress(1, 1, NULL); - hexdump_buf(stdout, mem, term_rmem[i].addr, buf, term_rmem[i].len); + hexdump_buf(stdout, mem, cx->term_rmem[i].addr, buf, cx->term_rmem[i].len); lterm_out(""); mmt_free(buf); - term_rmem[i].addr = (term_rmem[i].addr + term_rmem[i].len) % maxsize; + cx->term_rmem[i].addr = (cx->term_rmem[i].addr + cx->term_rmem[i].len) % maxsize; return 0; } @@ -493,7 +489,7 @@ static int cmd_write(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch if (len == 0) return 0; if (len < 0 || len > maxsize - addr) { - pmsg_error("(write ...) effective %s start address 0x%0*x and effective length %d not compatible with memory size %d\n", + pmsg_error("(write ...) effective %s start address 0x%0*x and effective length %d incompatible with memory size %d\n", mem->desc, maxsize > 0x10000? 5: 4, addr, len, maxsize); return -1; } @@ -937,7 +933,7 @@ static int cmd_pgerase(const PROGRAMMER *pgm, const AVRPART *p, int argc, const // Config command -static const int MAX_PAD = 10; // Align value labels if difference between their lengths is less than this +static const int MAX_PAD = 10; // Align value labels if their length difference is less than this typedef union { // Lock memory can be 1 or 4 bytes uint8_t b[4]; @@ -1364,7 +1360,8 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c if(!nf || !str_eq(fc[nf-1].memstr, mt)) fc[nf++].memstr = mt; if(fc[nf-1].mask & ct[i].mask) { // This should not happen - pmsg_error("(config) overlapping bit values of %s mask 0x%02x in %s's %s\n", cc[i].t->name, ct[i].mask, p->desc, cc[i].memstr); + pmsg_error("(config) overlapping bit values of %s mask 0x%02x in %s's %s\n", cc[i].t->name, + ct[i].mask, p->desc, cc[i].memstr); ret = -1; goto finished; } @@ -1480,7 +1477,7 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c } if((toassign<>ct[ci].lsh); ret = -1; goto finished; @@ -2463,11 +2460,6 @@ int terminal_line(const PROGRAMMER *pgm, const AVRPART *p, const char *line) { #if defined(HAVE_LIBREADLINE) -static const PROGRAMMER *term_pgm; -static const AVRPART *term_p; - -static int term_running; - // Any character in standard input available (without sleeping)? static int readytoread() { #ifdef _MSC_VER @@ -2519,8 +2511,8 @@ static void term_gotline(char *cmdstr) { if(*cmdstr) { add_history(cmdstr); // Only quit returns a value > 0 - if(process_line(cmdstr, term_pgm, term_p) > 0) - term_running = 0; + if(process_line(cmdstr, cx->term_pgm, cx->term_p) > 0) + cx->term_running = 0; } mmt_free(cmdstr); /* @@ -2530,36 +2522,36 @@ static void term_gotline(char *cmdstr) { * * see https://github.com/avrdudes/avrdude/issues/1173 */ - if(term_running) { + if(cx->term_running) { rl_callback_handler_remove(); rl_callback_handler_install("avrdude> ", term_gotline); } } else { // End of file or terminal ^D lterm_out(""); - cmd_quit(term_pgm, term_p, 0, NULL); - term_running = 0; + cmd_quit(cx->term_pgm, cx->term_p, 0, NULL); + cx->term_running = 0; } - if(!term_running) + if(!cx->term_running) rl_callback_handler_remove(); } static int terminal_mode_interactive(const PROGRAMMER *pgm, const AVRPART *p) { - term_pgm = pgm; // For callback routine - term_p = p; + cx->term_pgm = pgm; // For callback routine + cx->term_p = p; rl_callback_handler_install("avrdude> ", term_gotline); - term_running = 1; - for(int n=1; term_running; n++) { + cx->term_running = 1; + for(int n=1; cx->term_running; n++) { if(n%16 == 0) { // Every 100 ms (16*6.25 us) reset bootloader watchdog timer if(pgm->term_keep_alive) pgm->term_keep_alive(pgm, NULL); led_set(pgm, LED_NOP); } usleep(6250); - if(readytoread() > 0 && term_running) + if(readytoread() > 0 && cx->term_running) rl_callback_read_char(); } @@ -2687,28 +2679,26 @@ static int cmd_include(const PROGRAMMER *pgm, const AVRPART *p, int argc, const * 1 terminate progress bar with \n when finishing at 100 percent */ static void update_progress_tty(int percent, double etime, const char *hdr, int finish) { - static char *term_header; - static int term_tty_last, term_tty_todo; int i; setvbuf(stderr, (char *) NULL, _IONBF, 0); // Set stderr to be ubuffered if(hdr) { lmsg_info(""); // Print new line unless already done before - term_tty_last = 0; - term_tty_todo = 1; // OK, we have a header, start reporting - if(term_header) - mmt_free(term_header); - term_header = mmt_strdup(hdr); + cx->term_tty_last = 0; + cx->term_tty_todo = 1; // OK, we have a header, start reporting + if(cx->term_header) + mmt_free(cx->term_header); + cx->term_header = mmt_strdup(hdr); } percent = percent > 100? 100: percent < 0? 0: percent; - if(term_tty_todo) { - if(!term_header) - term_header = mmt_strdup("report"); + if(cx->term_tty_todo) { + if(!cx->term_header) + cx->term_header = mmt_strdup("report"); - int showperc = finish >= 0? percent: term_tty_last; + int showperc = finish >= 0? percent: cx->term_tty_last; char hashes[51]; memset(hashes, finish >= 0? ' ': '-', 50); @@ -2717,43 +2707,41 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int hashes[50] = 0; // Overwrite line using \r - msg_info("\r%s | %s | %d%% %0.2f s ", term_header, hashes, showperc, etime); + msg_info("\r%s | %s | %d%% %0.2f s ", cx->term_header, hashes, showperc, etime); if(percent == 100) { if(finish) lmsg_info(""); - term_tty_todo = 0; // Stop future reporting + cx->term_tty_todo = 0; // Stop future reporting } } - term_tty_last = percent; + cx->term_tty_last = percent; setvbuf(stderr, (char *) NULL, _IOLBF, 0); // Set stderr to be line buffered } static void update_progress_no_tty(int percent, double etime, const char *hdr, int finish) { - static int term_notty_last, term_notty_todo; - setvbuf(stderr, (char *) NULL, _IONBF, 0); percent = percent > 100? 100: percent < 0? 0: percent; if(hdr) { lmsg_info("%s | ", hdr); - term_notty_last = 0; - term_notty_todo = 1; + cx->term_notty_last = 0; + cx->term_notty_todo = 1; } - if(term_notty_todo) { - for(int cnt = percent/2; cnt > term_notty_last/2; cnt--) + if(cx->term_notty_todo) { + for(int cnt = percent/2; cnt > cx->term_notty_last/2; cnt--) msg_info(finish >= 0? "#": "-"); if(percent == 100) { - msg_info(" | %d%% %0.2fs", finish >= 0? 100: term_notty_last, etime); + msg_info(" | %d%% %0.2fs", finish >= 0? 100: cx->term_notty_last, etime); if(finish) lmsg_info(""); - term_notty_todo = 0; + cx->term_notty_todo = 0; } } - term_notty_last = percent; + cx->term_notty_last = percent; setvbuf(stderr, (char *) NULL, _IOLBF, 0); } From 9af06c74765bc930ac5a16ca6e507e72d3047676 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 21:45:19 +0100 Subject: [PATCH 063/422] Rename static update.c variables --- src/update.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/update.c b/src/update.c index 8a0e09f2..8cd7e272 100644 --- a/src/update.c +++ b/src/update.c @@ -267,14 +267,14 @@ static void ioerror(const char *iotype, const UPDATE *upd) { // Basic checks to reveal serious failure before programming (and on autodetect set format) int update_dryrun(const AVRPART *p, UPDATE *upd) { - static const char **wrote, **termcmds; - static int nfwritten, nterms; + static const char **upd_wrote, **upd_termcmds; + static int upd_nfwritten, upd_nterms; int known, format_detect, ret = LIBAVRDUDE_SUCCESS; if(upd->cmdline) { // Todo: parse terminal command line? - termcmds = mmt_realloc(termcmds, sizeof(*termcmds) * (nterms+1)); - termcmds[nterms++] = upd->cmdline; + upd_termcmds = mmt_realloc(upd_termcmds, sizeof(*upd_termcmds) * (upd_nterms+1)); + upd_termcmds[upd_nterms++] = upd->cmdline; return 0; } @@ -293,16 +293,16 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { if(upd->op == DEVICE_VERIFY || upd->op == DEVICE_WRITE || upd->format == FMT_AUTO) { if(upd->format != FMT_IMM) { // Need to read the file: was it written before, so will be known? - for(int i = 0; i < nfwritten; i++) - if(!wrote || (upd->filename && str_eq(wrote[i], upd->filename))) + for(int i = 0; i < upd_nfwritten; i++) + if(!upd_wrote || (upd->filename && str_eq(upd_wrote[i], upd->filename))) known = 1; // Could a -T terminal command have created the file? - for(int i = 0; i < nterms; i++) - if(!termcmds || (upd->filename && str_contains(termcmds[i], upd->filename))) + for(int i = 0; i < upd_nterms; i++) + if(!upd_termcmds || (upd->filename && str_contains(upd_termcmds[i], upd->filename))) known = 1; // Any -t interactive terminal could have created it - for(int i = 0; i < nterms; i++) - if(!termcmds || str_eq(termcmds[i], "interactive terminal")) + for(int i = 0; i < upd_nterms; i++) + if(!upd_termcmds || str_eq(upd_termcmds[i], "interactive terminal")) known = 1; errno = 0; @@ -342,8 +342,9 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { ioerror("writeable", upd); ret = LIBAVRDUDE_SOFTFAIL; } else if(upd->filename) { // Record filename (other than stdout) is available for future reads - if(!str_eq(upd->filename, "-") && (wrote = mmt_realloc(wrote, sizeof(*wrote) * (nfwritten+1)))) - wrote[nfwritten++] = upd->filename; + if(!str_eq(upd->filename, "-") && + (upd_wrote = mmt_realloc(upd_wrote, sizeof(*upd_wrote) * (upd_nfwritten+1)))) + upd_wrote[upd_nfwritten++] = upd->filename; } } break; From 3a45e1fbec54146c0681d9254bb3c856487d4c7e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 21:48:33 +0100 Subject: [PATCH 064/422] Put static variables of update.c into context structure --- src/libavrdude.h | 4 ++++ src/update.c | 23 ++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index e6a8970b..8e6a1c4c 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1612,6 +1612,10 @@ typedef struct { char *term_header; int term_tty_last, term_tty_todo; int term_notty_last, term_notty_todo; + + // Static variables from update.c + const char **upd_wrote, **upd_termcmds; + int upd_nfwritten, upd_nterms; } cx_t; extern cx_t *cx; diff --git a/src/update.c b/src/update.c index 8cd7e272..4982f825 100644 --- a/src/update.c +++ b/src/update.c @@ -267,14 +267,11 @@ static void ioerror(const char *iotype, const UPDATE *upd) { // Basic checks to reveal serious failure before programming (and on autodetect set format) int update_dryrun(const AVRPART *p, UPDATE *upd) { - static const char **upd_wrote, **upd_termcmds; - static int upd_nfwritten, upd_nterms; - int known, format_detect, ret = LIBAVRDUDE_SUCCESS; if(upd->cmdline) { // Todo: parse terminal command line? - upd_termcmds = mmt_realloc(upd_termcmds, sizeof(*upd_termcmds) * (upd_nterms+1)); - upd_termcmds[upd_nterms++] = upd->cmdline; + cx->upd_termcmds = mmt_realloc(cx->upd_termcmds, sizeof(*cx->upd_termcmds) * (cx->upd_nterms+1)); + cx->upd_termcmds[cx->upd_nterms++] = upd->cmdline; return 0; } @@ -293,16 +290,16 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { if(upd->op == DEVICE_VERIFY || upd->op == DEVICE_WRITE || upd->format == FMT_AUTO) { if(upd->format != FMT_IMM) { // Need to read the file: was it written before, so will be known? - for(int i = 0; i < upd_nfwritten; i++) - if(!upd_wrote || (upd->filename && str_eq(upd_wrote[i], upd->filename))) + for(int i = 0; i < cx->upd_nfwritten; i++) + if(!cx->upd_wrote || (upd->filename && str_eq(cx->upd_wrote[i], upd->filename))) known = 1; // Could a -T terminal command have created the file? - for(int i = 0; i < upd_nterms; i++) - if(!upd_termcmds || (upd->filename && str_contains(upd_termcmds[i], upd->filename))) + for(int i = 0; i < cx->upd_nterms; i++) + if(!cx->upd_termcmds || (upd->filename && str_contains(cx->upd_termcmds[i], upd->filename))) known = 1; // Any -t interactive terminal could have created it - for(int i = 0; i < upd_nterms; i++) - if(!upd_termcmds || str_eq(upd_termcmds[i], "interactive terminal")) + for(int i = 0; i < cx->upd_nterms; i++) + if(!cx->upd_termcmds || str_eq(cx->upd_termcmds[i], "interactive terminal")) known = 1; errno = 0; @@ -343,8 +340,8 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { ret = LIBAVRDUDE_SOFTFAIL; } else if(upd->filename) { // Record filename (other than stdout) is available for future reads if(!str_eq(upd->filename, "-") && - (upd_wrote = mmt_realloc(upd_wrote, sizeof(*upd_wrote) * (upd_nfwritten+1)))) - upd_wrote[upd_nfwritten++] = upd->filename; + (cx->upd_wrote = mmt_realloc(cx->upd_wrote, sizeof(*cx->upd_wrote) * (cx->upd_nfwritten+1)))) + cx->upd_wrote[cx->upd_nfwritten++] = upd->filename; } } break; From 8e625510d8ffdb6b302a95e808ac13c3662bb46b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 21:50:52 +0100 Subject: [PATCH 065/422] Make static function greppable in usb_libusb.c --- src/usb_libusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/usb_libusb.c b/src/usb_libusb.c index 94acb398..8d7a9500 100644 --- a/src/usb_libusb.c +++ b/src/usb_libusb.c @@ -372,8 +372,7 @@ static int usbdev_send(const union filedescriptor *fd, const unsigned char *bp, * and transparently issue another USB read request if the buffer is * empty and more data are requested. */ -static int -usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_interrupt_xfer) +static int usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_interrupt_xfer) { int rv; From b4f5851e7f9ace38ab40019b0f864f0ee00a0b56 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 22:08:33 +0100 Subject: [PATCH 066/422] Rename usb_libusb.c variables --- src/usb_libusb.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/usb_libusb.c b/src/usb_libusb.c index 8d7a9500..8cf9d2b4 100644 --- a/src/usb_libusb.c +++ b/src/usb_libusb.c @@ -53,9 +53,8 @@ # undef interface #endif -static char usbbuf[USBDEV_MAX_XFER_3]; -static int buflen = -1, bufptr; - +static char usb_buf[USBDEV_MAX_XFER_3]; +static int usb_buflen = -1, usb_bufptr; static int usb_interface; /* @@ -377,9 +376,9 @@ static int usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_inter int rv; if (use_interrupt_xfer) - rv = usb_interrupt_read(udev, ep, usbbuf, maxsize, 10000); + rv = usb_interrupt_read(udev, ep, usb_buf, maxsize, 10000); else - rv = usb_bulk_read(udev, ep, usbbuf, maxsize, 10000); + rv = usb_bulk_read(udev, ep, usb_buf, maxsize, 10000); if (rv < 0) { pmsg_notice2("usb_fill_buf(): usb_%s_read() error: %s\n", @@ -387,8 +386,8 @@ static int usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_inter return -1; } - buflen = rv; - bufptr = 0; + usb_buflen = rv; + usb_bufptr = 0; return 0; } @@ -404,14 +403,14 @@ static int usbdev_recv(const union filedescriptor *fd, unsigned char *buf, size_ for (i = 0; nbytes > 0;) { - if (buflen <= bufptr) + if (usb_buflen <= usb_bufptr) { if (usb_fill_buf(udev, fd->usb.max_xfer, fd->usb.rep, fd->usb.use_interrupt_xfer) < 0) return -1; } - amnt = buflen - bufptr > (int) nbytes? (int) nbytes: buflen - bufptr; - memcpy(buf + i, usbbuf + bufptr, amnt); - bufptr += amnt; + amnt = usb_buflen - usb_bufptr > (int) nbytes? (int) nbytes: usb_buflen - usb_bufptr; + memcpy(buf + i, usb_buf + usb_bufptr, amnt); + usb_bufptr += amnt; nbytes -= amnt; i += amnt; } @@ -443,11 +442,11 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf, /* If there's an event EP, and it has data pending, return it first. */ if (fd->usb.eep != 0) { - rv = usb_bulk_read(udev, fd->usb.eep, usbbuf, + rv = usb_bulk_read(udev, fd->usb.eep, usb_buf, fd->usb.max_xfer, 1); if (rv > 4) { - memcpy(buf, usbbuf, rv); + memcpy(buf, usb_buf, rv); n = rv; n |= USB_RECV_FLAG_EVENT; goto printout; @@ -463,10 +462,10 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf, do { if (fd->usb.use_interrupt_xfer) - rv = usb_interrupt_read(udev, fd->usb.rep, usbbuf, + rv = usb_interrupt_read(udev, fd->usb.rep, usb_buf, fd->usb.max_xfer, 10000); else - rv = usb_bulk_read(udev, fd->usb.rep, usbbuf, + rv = usb_bulk_read(udev, fd->usb.rep, usb_buf, fd->usb.max_xfer, 10000); if (rv < 0) { @@ -477,7 +476,7 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf, if (rv <= (int) nbytes) { - memcpy (buf, usbbuf, rv); + memcpy (buf, usb_buf, rv); buf += rv; } else From 512c3b6fc215123bc8434adaf6e37ce077fde7f9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 22:12:59 +0100 Subject: [PATCH 067/422] Put static variables of usb_libusb.c into context structure --- src/libavrdude.h | 6 ++++++ src/usb_libusb.c | 40 ++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 8e6a1c4c..dc2da5ee 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1616,6 +1616,12 @@ typedef struct { // Static variables from update.c const char **upd_wrote, **upd_termcmds; int upd_nfwritten, upd_nterms; + + // Static variables from usb_libusb.c +#include "usbdevs.h" + char usb_buf[USBDEV_MAX_XFER_3]; + int usb_buflen, usb_bufptr; // @@@ Check whether usb_buflen needs initialising with -1 + int usb_interface; } cx_t; extern cx_t *cx; diff --git a/src/usb_libusb.c b/src/usb_libusb.c index 8cf9d2b4..995437fb 100644 --- a/src/usb_libusb.c +++ b/src/usb_libusb.c @@ -53,10 +53,6 @@ # undef interface #endif -static char usb_buf[USBDEV_MAX_XFER_3]; -static int usb_buflen = -1, usb_bufptr; -static int usb_interface; - /* * The "baud" parameter is meaningless for USB devices, so we reuse it * to pass the desired USB device ID. @@ -212,7 +208,7 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor for (iface = 0; iface < dev->config[0].bNumInterfaces; iface++) { - usb_interface = dev->config[0].interface[iface].altsetting[0].bInterfaceNumber; + cx->usb_interface = dev->config[0].interface[iface].altsetting[0].bInterfaceNumber; #ifdef LIBUSB_HAS_GET_DRIVER_NP /* * Many Linux systems attach the usbhid driver @@ -220,12 +216,12 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor * those, the driver needs to be detached before * we can claim the interface. */ - (void)usb_detach_kernel_driver_np(udev, usb_interface); + (void) usb_detach_kernel_driver_np(udev, cx->usb_interface); #endif - if (usb_claim_interface(udev, usb_interface)) + if (usb_claim_interface(udev, cx->usb_interface)) { pmsg_error("unable to claim interface %d: %s\n", - usb_interface, usb_strerror()); + cx->usb_interface, usb_strerror()); } else { @@ -310,7 +306,7 @@ static void usbdev_close(union filedescriptor *fd) if (udev == NULL) return; - (void)usb_release_interface(udev, usb_interface); + (void) usb_release_interface(udev, cx->usb_interface); #if defined(__linux__) /* @@ -376,9 +372,9 @@ static int usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_inter int rv; if (use_interrupt_xfer) - rv = usb_interrupt_read(udev, ep, usb_buf, maxsize, 10000); + rv = usb_interrupt_read(udev, ep, cx->usb_buf, maxsize, 10000); else - rv = usb_bulk_read(udev, ep, usb_buf, maxsize, 10000); + rv = usb_bulk_read(udev, ep, cx->usb_buf, maxsize, 10000); if (rv < 0) { pmsg_notice2("usb_fill_buf(): usb_%s_read() error: %s\n", @@ -386,8 +382,8 @@ static int usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_inter return -1; } - usb_buflen = rv; - usb_bufptr = 0; + cx->usb_buflen = rv; + cx->usb_bufptr = 0; return 0; } @@ -403,14 +399,14 @@ static int usbdev_recv(const union filedescriptor *fd, unsigned char *buf, size_ for (i = 0; nbytes > 0;) { - if (usb_buflen <= usb_bufptr) + if (cx->usb_buflen <= cx->usb_bufptr) { if (usb_fill_buf(udev, fd->usb.max_xfer, fd->usb.rep, fd->usb.use_interrupt_xfer) < 0) return -1; } - amnt = usb_buflen - usb_bufptr > (int) nbytes? (int) nbytes: usb_buflen - usb_bufptr; - memcpy(buf + i, usb_buf + usb_bufptr, amnt); - usb_bufptr += amnt; + amnt = cx->usb_buflen - cx->usb_bufptr > (int) nbytes? (int) nbytes: cx->usb_buflen - cx->usb_bufptr; + memcpy(buf + i, cx->usb_buf + cx->usb_bufptr, amnt); + cx->usb_bufptr += amnt; nbytes -= amnt; i += amnt; } @@ -442,11 +438,11 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf, /* If there's an event EP, and it has data pending, return it first. */ if (fd->usb.eep != 0) { - rv = usb_bulk_read(udev, fd->usb.eep, usb_buf, + rv = usb_bulk_read(udev, fd->usb.eep, cx->usb_buf, fd->usb.max_xfer, 1); if (rv > 4) { - memcpy(buf, usb_buf, rv); + memcpy(buf, cx->usb_buf, rv); n = rv; n |= USB_RECV_FLAG_EVENT; goto printout; @@ -462,10 +458,10 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf, do { if (fd->usb.use_interrupt_xfer) - rv = usb_interrupt_read(udev, fd->usb.rep, usb_buf, + rv = usb_interrupt_read(udev, fd->usb.rep, cx->usb_buf, fd->usb.max_xfer, 10000); else - rv = usb_bulk_read(udev, fd->usb.rep, usb_buf, + rv = usb_bulk_read(udev, fd->usb.rep, cx->usb_buf, fd->usb.max_xfer, 10000); if (rv < 0) { @@ -476,7 +472,7 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf, if (rv <= (int) nbytes) { - memcpy (buf, usb_buf, rv); + memcpy (buf, cx->usb_buf, rv); buf += rv; } else From cca61bf20efee6f363a7cc67c5485d9487fe0be8 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 22:20:09 +0100 Subject: [PATCH 068/422] Make static array const in serbb_posix.c --- src/serbb_posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serbb_posix.c b/src/serbb_posix.c index 877fc1a5..b9d2f180 100644 --- a/src/serbb_posix.c +++ b/src/serbb_posix.c @@ -72,7 +72,7 @@ static const int serregbits[DB9PINS + 1] = { 0, TIOCM_CD, 0, 0, TIOCM_DTR, 0, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS, TIOCM_RI }; #ifdef DEBUG -static const char *serpins[DB9PINS + 1] = +static const char * const serpins[DB9PINS + 1] = { "NONE", "CD", "RXD", "TXD", "DTR", "GND", "DSR", "RTS", "CTS", "RI" }; #endif From 627f320efbdc2b09b7b134e5c0f8533604928489 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 10 May 2024 22:21:06 +0100 Subject: [PATCH 069/422] Make static array const in flip1.c --- src/flip1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flip1.c b/src/flip1.c index 1ad390c3..f486ed07 100644 --- a/src/flip1.c +++ b/src/flip1.c @@ -764,7 +764,7 @@ static int flip1_set_mem_page(struct dfu_dev *dfu, unsigned short page_addr) { } static const char *flip1_status_str(const struct dfu_status *status) { - static const char *msg[] = { + static const char * const msg[] = { "No error condition is present", "File is not targeted for use by this device", "File is for this device but fails some vendor-specific verification test", From 5ae58ff728fc7bec35b6879799aff1b14c4330ea Mon Sep 17 00:00:00 2001 From: Funkeleinhorn Date: Tue, 14 May 2024 01:18:39 +0200 Subject: [PATCH 070/422] Address code review and add set/get_sck_period() --- src/avrdude.1 | 4 +- src/avrdude.conf.in | 2 +- src/doc/avrdude.texi | 4 +- src/serprog.c | 107 ++++++++++++++++++++++++------------------- src/serprog.h | 3 +- 5 files changed, 63 insertions(+), 57 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index 28de8edb..3a859781 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -1993,9 +1993,7 @@ Show help menu and exit. .It Ar cs Sets the chip select (CS) to use on supported programmers. Programmers supporting the 0x16 serprog command can have more than the default CS (0). -This option allows to choose this additional CS's (1,2,3,...) for programming the AVR. -Here you can find the addition to the serprog spec enabling that: -https://review.coreboot.org/c/flashrom/+/80498 +This option allows to choose these additional CSes (1, 2, ...) for programming the AVR. .It Ar help Show help menu and exit. .El diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 314b7ab7..516fed49 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -1491,7 +1491,7 @@ programmer # serialupdi programmer # serprog id = "serprog"; - desc = "Serprog"; + desc = "Program via the Serprog protocol from Flashrom"; type = "serprog"; prog_modes = PM_ISP; connection_type = serial; diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 83213daa..b9b9dacf 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -1653,9 +1653,7 @@ The serprog programmer type accepts the following extended parameter: @item @samp{cs} Sets the chip select (CS) to use on supported programmers. Programmers supporting the 0x16 serprog command can have more than the default CS (0). -This option allows to choose this additional CS's (1,2,3,...) for programming the AVR. -Here you can find the addition to the serprog spec enabling that: -https://review.coreboot.org/c/flashrom/+/80498 +This option allows to choose these additional CSes (1, 2, ...) for programming the AVR. @item @samp{help} Show help menu and exit. @end table diff --git a/src/serprog.c b/src/serprog.c index e40321d6..90fec7df 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -5,9 +5,6 @@ * https://flashrom.org/supported_hw/supported_prog/serprog/index.html * * Copyright (C) 2024 Sydney Louisa Wilke - * used linuxspi.c as a template: - * Copyright (C) 2013 Kevin Cuzner - * Copyright (C) 2018 Ralf Ramsauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * known limitations: + * Known limitations: * - performance is suboptimal * - connecting over TCP/IP to programmers is not implemented yet */ @@ -43,7 +40,7 @@ #include #include -const char serprog_desc[] = "Programmer using the serprog protocol"; +const char serprog_desc[] = "Program via the Serprog protocol from Flashrom"; /* * Private data for this programmer. @@ -51,6 +48,7 @@ const char serprog_desc[] = "Programmer using the serprog protocol"; struct pdata { unsigned char cmd_bitmap[32]; unsigned int cs; + uint32_t actual_frequency; }; #define my (*(struct pdata *)(pgm->cookie)) @@ -130,11 +128,14 @@ static int perform_serprog_cmd_full(const PROGRAMMER *pgm, uint8_t cmd, unsigned char *recv_buf, int recv_len) { unsigned char resp_status_code = 0; - serial_send(&pgm->fd, &cmd, 1); + if(serial_send(&pgm->fd, &cmd, 1) < 0) + return -1; if (params_len > 0) - serial_send(&pgm->fd, params, params_len); + if(serial_send(&pgm->fd, params, params_len) < 0) + return -1; if (send_len > 0) - serial_send(&pgm->fd, send_buf, send_len); + if(serial_send(&pgm->fd, send_buf, send_len) < 0) + return -1; if (serial_recv(&pgm->fd, &resp_status_code, 1) < 0 || serial_recv(&pgm->fd, recv_buf, recv_len) < 0) return -1; @@ -169,24 +170,7 @@ static bool is_serprog_cmd_supported(const unsigned char *cmd_bitmap, unsigned c // programmer lifecycle handlers -static int serprog_open(PROGRAMMER *pgm, const char *pt) { - const char *port_error = - "unknown port specification, " - "please use the format /dev/ttyACM0\n"; - char port_default[] = "/dev/ttyACM0"; - char *serialdev; - char *port = mmt_strdup(pt); - - if (str_eq(port, "unknown")) { - port = port_default; - } - - serialdev = strtok(port, ","); - if (!serialdev) { - pmsg_error("%s", port_error); - return -1; - } - +static int serprog_open(PROGRAMMER *pgm, const char *port) { union pinfo pinfo; pgm->port = port; pinfo.serialinfo.baud = pgm->baudrate? pgm->baudrate: 115200; @@ -256,20 +240,6 @@ static int serprog_open(PROGRAMMER *pgm, const char *pt) { return -1; } - // set SPI clock frequency - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { - memset(buf, 0, sizeof(buf)); - write_le32(buf, 115200); - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { - pmsg_error("cannot set SPI frequency\n"); - return -1; - } - if (read_le32(buf) != 115200) { - pmsg_error("set SPI frequency differs from the requested one\n"); - return -1; - } - } - return 0; } @@ -312,8 +282,8 @@ static int serprog_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned return serprog_spi_duplex(pgm, cmd, res, 4); } -static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *p) { - if (p->prog_modes & PM_TPI) { +static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *part) { + if (part->prog_modes & PM_TPI) { /* We do not support TPI. This is a dedicated SPI thing */ pmsg_error("the %s programmer does not support TPI\n", pgmid); return -1; @@ -321,6 +291,25 @@ static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *p) { unsigned char buf[32]; + // set SPI clock frequency + if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { + memset(buf, 0, sizeof(buf)); + uint32_t frequency; + if (pgm->bitclock > 0) { + frequency = pgm->bitclock; + } else if (part->factory_fcpu > 0) { + frequency = (part->factory_fcpu / 4); + } else { + frequency = 250000; + } + write_le32(buf, frequency); + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { + pmsg_error("cannot set SPI frequency\n"); + return -1; + } + my.actual_frequency = read_le32(buf); + } + // set active chip select if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { memset(buf, 0, sizeof(buf)); @@ -361,7 +350,7 @@ static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *p) { //enable programming on the part tries = 0; do { - ret = pgm->program_enable(pgm, p); + ret = pgm->program_enable(pgm, part); if (ret == 0 || ret == -1) break; } while(tries++ < 65); @@ -372,6 +361,10 @@ static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *p) { return ret; } +/* used linuxspi.c as a template: + * Copyright (C) 2013 Kevin Cuzner + * Copyright (C) 2018 Ralf Ramsauer + */ static int serprog_program_enable(const PROGRAMMER *pgm, const AVRPART *p) { unsigned char cmd[4], res[4]; @@ -450,6 +443,26 @@ static void serprog_teardown(PROGRAMMER *pgm) { pgm->cookie = NULL; } +static int serprog_set_sck_period(const PROGRAMMER *pgm, double v) { + if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { + return -1; + } + unsigned char buf[8]; + memset(buf, 0, sizeof(buf)); + write_le32(buf, v); + if (perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { + pmsg_error("cannot set SPI frequency\n"); + return -1; + } + my.actual_frequency = read_le32(buf); + return 0; +} + +static int serprog_get_sck_period(const PROGRAMMER *pgm, double *v) { + *v = my.actual_frequency; + return 0; +} + static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { LNODEID ln; const char *extended_param; @@ -470,11 +483,7 @@ static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xcs=cs_num Sets the chip select (CS) to use on supported programmers.\n"); - msg_error(" Programmers supporting the 0x16 serprog command can have more than the default CS (0).\n"); - msg_error(" This option allows to choose this additional CS's (1,2,3,...) for programming the AVR.\n"); - msg_error(" Here you can find the addition to the serprog spec enabling that:\n"); - msg_error(" https://review.coreboot.org/c/flashrom/+/80498\n"); + msg_error(" -xcs=cs_num Sets the chip select (CS) to use on supported programmers\n"); msg_error(" -xhelp Show this help menu and exit\n"); return LIBAVRDUDE_EXIT; } @@ -506,5 +515,7 @@ void serprog_initpgm(PROGRAMMER *pgm) { pgm->setup = serprog_setup; pgm->teardown = serprog_teardown; pgm->parseextparams = serprog_parseextparams; + pgm->get_sck_period = serprog_get_sck_period; + pgm->set_sck_period = serprog_set_sck_period; } diff --git a/src/serprog.h b/src/serprog.h index 5de51452..99ec9401 100644 --- a/src/serprog.h +++ b/src/serprog.h @@ -1,8 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers + * * Copyright (C) 2024 Sydney Louisa Wilke - * used linuxspi.h as a template: - * Copyright (C) 2013 Kevin Cuzner * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 393364224fec2f141477291e235a15f30d26539a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 14 May 2024 18:57:37 +0100 Subject: [PATCH 071/422] Rename cx_t to libavrdude_context --- src/libavrdude.h | 10 +++++----- src/main.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index dc2da5ee..cb361b23 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1539,9 +1539,9 @@ char *avr_cc_buffer(size_t n); * * Global and static variables should go here; the only remaining static * variables ought to be read-only tables. Access should be via a global - * pointer cx_t *cx; applications using libavrdude ought to allocate cx = - * mmt_malloc(sizeof *cx) for each instantiation (and set initial values - * if needed) and deallocate with mmt_free(cx). + * pointer libavrdude_context *cx; applications using libavrdude ought to + * allocate cx = mmt_malloc(sizeof *cx) for each instantiation (and set + * initial values if needed) and deallocate with mmt_free(cx). */ typedef struct { @@ -1622,9 +1622,9 @@ typedef struct { char usb_buf[USBDEV_MAX_XFER_3]; int usb_buflen, usb_bufptr; // @@@ Check whether usb_buflen needs initialising with -1 int usb_interface; -} cx_t; +} libavrdude_context; -extern cx_t *cx; +extern libavrdude_context *cx; /* formerly confwin.h */ diff --git a/src/main.c b/src/main.c index ae945bbb..3aca35a4 100644 --- a/src/main.c +++ b/src/main.c @@ -189,7 +189,7 @@ struct list_walk_cookie }; -cx_t *cx; // Context pointer, eventually the only global variable +libavrdude_context *cx; // Context pointer, eventually the only global variable static LISTID updates = NULL; From cdf3dea7494e375931ff2559957f3166c38dfefe Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 17 May 2024 11:57:57 +0100 Subject: [PATCH 072/422] Assert vecsz variable as const --- src/urclock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index fc0fbe53..d22d613d 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -544,7 +544,7 @@ static int urclock_flash_readhook(const PROGRAMMER *pgm, const AVRPART *p, const const char *fname, int size) { // size is max memory address + 1 int nmdata, maxsize, firstbeg, firstlen; - int vecsz = ur.uP.flashsize <= 8192? 2: 4; // Small parts use rjmp, large parts need 4-byte jmp + const int vecsz = ur.uP.flashsize <= 8192? 2: 4; // Small parts use rjmp, large a 4-byte jmp set_date_filename(pgm, fname); @@ -1489,7 +1489,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { ur.bloptiversion>>8, ur.bloptiversion & 255); Return("unknown bootloader ... please specify -xbootsize=\n"); } - } else if(!ur.boothigh) { // Fixme: guess bootloader size from low flash + } else if(!ur.boothigh) { // @@@ Fixme: guess bootloader size from low flash } vblvecfound: From 2dc946f2631d67981a3040dd1d13040b4bf65bdf Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 17 May 2024 13:01:57 +0100 Subject: [PATCH 073/422] Reserve high bit of vector number and number of pages --- src/urclock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index d22d613d..69570fbf 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -1349,9 +1349,9 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { if((rc = ur_readEF(pgm, p, spc, flm->size-6, 6, 'F'))) return rc; - // In a urboot bootloader (v7.2 onwards) these six are as follows - uint8_t numpags = spc[0]; // Actually, these two only exist from v7.5 onwards - uint8_t vectnum = spc[1]; + // In a urboot bootloader these six (v7.5 onwards) are as follows + uint8_t numpags = spc[0] & 0x7f; // Number of bootloader pages (undefined before v7.5) + uint8_t vectnum = spc[1] & 0x7f; // Vector number for application start (undefined before v7.5) rjmpwp = buf2uint16(spc+2); // rjmp to bootloader pgm_write_page() or ret opcode uint8_t cap = spc[4]; // Capability byte uint8_t urver = spc[5]; // Urboot version (low three bits are minor version: 076 is v7.6) From 3b2bbb393fe0269acc85926d384d3d5cd2ecc088 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 17 May 2024 14:25:38 +0100 Subject: [PATCH 074/422] Harden checks for urboot presence --- src/urclock.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index 69570fbf..8cea51f6 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -1359,12 +1359,12 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { // Extensively check this is an urboot bootloader v7.2 .. v12.7 == 0147 and extract properties if(urver >= 072 && urver <= 0147 && (isRjmp(rjmpwp) || rjmpwp == ret_opcode)) { // Prob urboot - ur.blurversion = urver; - ur.bleepromrw = iseeprom_cap(cap); - // Vector bootloader: 0 = none, 1 = external patching, 2 = bl patches, 3 = patches + verifies - if(!ur.vbllevel) // Unless manually overwritten - ur.vbllevel = vectorbl_level_cap(cap); - if(urver >= 075) { // Urboot v7.5+ encodes # of bootloader pages and vbl vector number + if(urver < 075) { // Early urboot versions don't offer many sanity checks + ur.blurversion = urver; + ur.bleepromrw = iseeprom_cap(cap); + if(!ur.vbllevel) // Unless manually overwritten + ur.vbllevel = vectorbl_level_cap(cap); + } else { // Urboot v7.5+ encodes bootloader size and vector number int blsize = numpags*flm->page_size; // Size of urboot bootloader should be in [64, 2048] (in v7.6 these are 224-512 bytes) if(blsize >= 64 && blsize <= 2048 && vectnum <= ur.uP.ninterrupts) { // Within range @@ -1375,7 +1375,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { if(flm->size - blsize != ur.blstart) { pmsg_warning("urboot bootloader size %d explicitly overwritten by -xbootsize=%d\n", blsize, ur.xbootsize); - if(!ovsigck && ur.vbllevel) { + if(!ovsigck && vectnum) { imsg_warning("this can lead to bricking the vector bootloader\n"); return -1; } @@ -1394,6 +1394,11 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { } } else ur.vblvectornum = vectnum; + + ur.blurversion = urver; + ur.bleepromrw = iseeprom_cap(cap); + if(!ur.vbllevel) // Unless manually overwritten + ur.vbllevel = vectorbl_level_cap(cap); } } } @@ -1684,7 +1689,7 @@ static int urclock_paged_rdwr(const PROGRAMMER *pgm, const AVRPART *part, char r if(len != ur.uP.pagesize) Return("len %d must be page size %d for paged flash writes", len, ur.uP.pagesize); - if(badd < 4U && ur.boothigh && ur.blstart && ur.vbllevel==1) { + if(badd < 4U && ur.boothigh && ur.blstart && ur.vbllevel == 1) { int vecsz = ur.uP.flashsize <= 8192? 2: 4; unsigned char jmptoboot[4]; int resetsize = set_reset(pgm, jmptoboot, vecsz); @@ -2151,7 +2156,7 @@ static int urclock_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { ur.done_ce = 1; if(!emulated) { // Write jump to boot section to reset vector - if(ur.boothigh && ur.blstart && ur.vbllevel==1) { + if(ur.boothigh && ur.blstart && ur.vbllevel == 1) { AVRMEM *flm = avr_locate_flash(p); int vecsz = ur.uP.flashsize <= 8192? 2: 4; if(flm && flm->page_size >= vecsz) { From 0f9032e6c3925f182b8f5ecd34f2c57a0dda5628 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 17 May 2024 14:40:26 +0100 Subject: [PATCH 075/422] Set vbl level from vector number for urboot v8.0+ --- src/urclock.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index 8cea51f6..2d53c8e5 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -1392,13 +1392,18 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { vectnum, ur.xvectornum); imsg_warning("the application might not start correctly\n"); } - } else + } else { ur.vblvectornum = vectnum; + /* + * Urboot v8.0 (urver == 0100) onwards no longer supports self-patching + * bootloaders. The vbllevel is either 0 (vectnum == 0) or 1 (vectnum > 0). + * No longer refer to the capability byte from v8.0 thus freeing 2 bits. + */ + ur.vbllevel = urver <= 077? vectorbl_level_cap(cap): vectnum > 0; + } ur.blurversion = urver; ur.bleepromrw = iseeprom_cap(cap); - if(!ur.vbllevel) // Unless manually overwritten - ur.vbllevel = vectorbl_level_cap(cap); } } } From 8075b90172fb0fcd5bf0c5f9292c12a9605cd836 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 17 May 2024 14:49:31 +0100 Subject: [PATCH 076/422] Update capability bit definitions --- src/urclock.c | 4 +-- src/urclock_private.h | 84 ++++++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index 2d53c8e5..853b3a03 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -1363,7 +1363,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { ur.blurversion = urver; ur.bleepromrw = iseeprom_cap(cap); if(!ur.vbllevel) // Unless manually overwritten - ur.vbllevel = vectorbl_level_cap(cap); + ur.vbllevel = vectorbl_level077_cap(cap); } else { // Urboot v7.5+ encodes bootloader size and vector number int blsize = numpags*flm->page_size; // Size of urboot bootloader should be in [64, 2048] (in v7.6 these are 224-512 bytes) @@ -1399,7 +1399,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { * bootloaders. The vbllevel is either 0 (vectnum == 0) or 1 (vectnum > 0). * No longer refer to the capability byte from v8.0 thus freeing 2 bits. */ - ur.vbllevel = urver <= 077? vectorbl_level_cap(cap): vectnum > 0; + ur.vbllevel = urver <= 077? vectorbl_level077_cap(cap): vectnum > 0; } ur.blurversion = urver; diff --git a/src/urclock_private.h b/src/urclock_private.h index 6b70a48b..941a7c38 100644 --- a/src/urclock_private.h +++ b/src/urclock_private.h @@ -18,8 +18,8 @@ /* $Id$ */ -#ifndef urclock_private_h__ -#define urclock_private_h__ +#ifndef urclock_private_h +#define urclock_private_h // EEPROM or flash cache for bytewise access typedef struct { @@ -92,14 +92,15 @@ typedef struct { #define UR_PGMWRITEPAGE 128 // pgm_write_page() can be called from application at FLASHEND+1-4 #define UR_AUTOBAUD 128 // Bootloader has autobaud detection (from v7.7) #define UR_EEPROM 64 // EEPROM read/write support -#define UR_URPROTOCOL 32 // Bootloader uses urprotocol that requires avrdude -c urclock +#define UR_URPROTOCOL 32 // Using urprotocol (v7.6 and v7.7 only) #define UR_DUAL 16 // Dual boot -#define UR_VBLMASK 12 // Vector bootloader bits +#define UR_VBLMASK 12 // Vector bootloader bits (up to v7.7 only) #define UR_VBLPATCHVERIFY 12 // Patch reset/interrupt vectors and show original ones on verify #define UR_VBLPATCH 8 // Patch reset/interrupt vectors only (expect an error on verify) #define UR_VBL 4 // Merely start application via interrupt vector instead of reset #define UR_NO_VBL 0 // Not a vector bootloader, must set fuses to HW bootloader support #define UR_PROTECTME 2 // Bootloader safeguards against overwriting itself +#define UR_PROTECTRESET 2 // Bootloader safeguards against overwriting itself and reset #define UR_RESETFLAGS 1 // Load reset flags into register R2 before starting application #define UR_HAS_CE 1 // Bootloader has Chip Erase (from v7.7) @@ -116,39 +117,56 @@ typedef struct { (uint8_t) (_vh >= 072 && _vh != 0xff? _vh: 0); }) #define vercapis(capver, mask) ({ uint16_t _vi = capver; !!(capabilities_cv(_vi) & (mask)); }) -#define ispgmwritepage_cv(capver) vercapis(capver, UR_PGMWRITEPAGE) // up to v7.6 -#define isautobaud_cv(capver) vercapis(capver, UR_AUTOBAUD) // from v7.7 -#define iseeprom_cv(capver) vercapis(capver, UR_EEPROM) -#define isurprotocol_cv(capver) vercapis(capver, UR_URPROTOCOL) -#define isdual_cv(capver) vercapis(capver, UR_DUAL) -#define isvectorbl_cv(capver) vercapis(capver, UR_VBLMASK) -#define isprotectme_cv(capver) vercapis(capver, UR_PROTECTME) -#define isresetflags_cv(capver) vercapis(capver, UR_RESETFLAGS) // up to v7.6 -#define ishas_ce_cv(capver) vercapis(capver, UR_HAS_CE) // from v7.7 +#define isautobaud_cv(capver) vercapis(capver, UR_AUTOBAUD) // from v7.7 +#define iseeprom_cv(capver) vercapis(capver, UR_EEPROM) +#define isdual_cv(capver) vercapis(capver, UR_DUAL) +#define isprotectreset_cv(capver) vercapis(capver, UR_PROTECTRESET) // from 7.7 +#define ishas_ce_cv(capver) vercapis(capver, UR_HAS_CE) // from v7.7 + +// Up to v7.7 +#define isurprotocol077_cv(capver) vercapis(capver, UR_URPROTOCOL) +#define isvectorbl077_cv(capver) vercapis(capver, UR_VBLMASK) + +// Up to v7.6 +#define ispgmwritepage076_cv(capver) vercapis(capver, UR_PGMWRITEPAGE) +#define isprotectme076_cv(capver) vercapis(capver, UR_PROTECTME) +#define isresetflags076_cv(capver) vercapis(capver, UR_RESETFLAGS) + // Capability bits incl position -#define pgmwritepage_bit_cap(cap) ((cap) & UR_PGMWRITEPAGE) // up to v7.6 -#define autibaud_bit_cap(cap) ((cap) & UR_AUTOBAUD) // from v7.7 -#define eeprom_bit_cap(cap) ((cap) & UR_EEPROM) -#define dual_bit_cap(cap) ((cap) & UR_DUAL) -#define vector_bits_cap(cap) ((cap) & UR_VBLMASK)) -#define protectme_bit_cap(cap) ((cap) & UR_PROTECTME) -#define urprotocol_bit_cap(cap) ((cap) & UR_URPROTOCOL) -#define resetflags_bit_cap(cap) ((cap) & UR_RESETFLAGS) // up to v7.6 -#define has_ce_bit_cap(cap) ((cap) & UR_HAS_CE) // from v7.7 +#define autobaud_bit_cap(cap) ((cap) & UR_AUTOBAUD) // from v7.7 +#define eeprom_bit_cap(cap) ((cap) & UR_EEPROM) +#define dual_bit_cap(cap) ((cap) & UR_DUAL) +#define protectreset_bit_cap(cap) ((cap) & UR_PROTECTRESET) // from v7.7 +#define has_ce_bit_cap(cap) ((cap) & UR_HAS_CE) // from v7.7 + +// Up to v7.7 +#define urprotocol077_bit_cap(cap) ((cap) & UR_URPROTOCOL) +#define vector077_bits_cap(cap) ((cap) & UR_VBLMASK)) + +// Up to v7.6 +#define pgmwritepage076_bit_cap(cap) ((cap) & UR_PGMWRITEPAGE) +#define protectme076_bit_cap(cap) ((cap) & UR_PROTECTME) +#define resetflags076_bit_cap(cap) ((cap) & UR_RESETFLAGS) + // Boolean capabilities -#define ispgmwritepage_cap(cap) (!!((cap) & UR_PGMWRITEPAGE)) // up to v7.6 -#define isautobaud_cap(cap) (!!((cap) & UR_AUTOBAUD)) // from v7.7 -#define iseeprom_cap(cap) (!!((cap) & UR_EEPROM)) -#define isdual_cap(cap) (!!((cap) & UR_DUAL)) -#define isvectorbl_cap(cap) (!!((cap) & UR_VBLMASK))) -#define isprotectme_cap(cap) (!!((cap) & UR_PROTECTME)) -#define isurprotocol_cap(cap) (!!((cap) & UR_URPROTOCOL)) -#define isresetflags_cap(cap) (!!((cap) & UR_RESETFLAGS)) // up to v7.6 -#define ishas_ce_cap(cap) (!!((cap) & UR_HAS_CE)) // from v7.7 +#define isautobaud_cap(cap) (!!((cap) & UR_AUTOBAUD)) // from v7.7 +#define iseeprom_cap(cap) (!!((cap) & UR_EEPROM)) +#define isdual_cap(cap) (!!((cap) & UR_DUAL)) +#define isprotectreset_cap(cap) (!!((cap) & UR_PROTECTRESET)) // from v7.7 +#define ishas_ce_cap(cap) (!!((cap) & UR_HAS_CE)) // from v7.7 -// Capability levels 0, 1, 2 or 3 -#define vectorbl_level_cap(cap) (((cap) & UR_VBLMASK)/UR_VBL) +// Up to v7.7 +#define isurprotocol077_cap(cap) (!!((cap) & UR_URPROTOCOL)) +#define isvectorbl077_cap(cap) (!!((cap) & UR_VBLMASK))) + +// Up to v7.6 +#define ispgmwritepage076_cap(cap) (!!((cap) & UR_PGMWRITEPAGE)) +#define isprotectme076_cap(cap) (!!((cap) & UR_PROTECTME)) +#define isresetflags076_cap(cap) (!!((cap) & UR_RESETFLAGS)) + +// Capability levels 0, 1, 2 or 3 (only for bootloaders up to v7.7) +#define vectorbl_level077_cap(cap) (((cap) & UR_VBLMASK)/(UR_VBLMASK & -UR_VBLMASK)) #endif From 6962d79dc93480a4a4f1346e923a5bc4c0794509 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 17 May 2024 15:55:48 +0100 Subject: [PATCH 077/422] Update u8.0+ capability printing --- src/urclock.c | 9 ++++++--- src/urclock_private.h | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index 853b3a03..b6797b64 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -922,8 +922,11 @@ static void urbootPutVersion(const PROGRAMMER *pgm, char *buf, uint16_t ver, uin buf += strlen(buf); *buf++ = (hi < 077 && (type & UR_PGMWRITEPAGE)) || (hi >= 077 && rjmpwp != ret_opcode)? 'w': '-'; *buf++ = type & UR_EEPROM? 'e': '-'; - if(hi >= 076) { // From urboot version 7.6 URPROTOCOL has its own bit - *buf++ = type & UR_URPROTOCOL? 'u': 's'; + if(hi >= 076) { + if(hi > 077) // From version 8.0 it's always urprotocol + *buf++ = type & UR_EXPEDITE? 'U': 'u'; + else + *buf++ = type & UR_URPROTOCOL? 'u': 's'; *buf++ = type & UR_DUAL? 'd': '-'; } else { *buf++ = '-'; // Dummy bit @@ -931,7 +934,7 @@ static void urbootPutVersion(const PROGRAMMER *pgm, char *buf, uint16_t ver, uin // D = Dual boot with SE & SPI restoration, d = dual boot with SE, f = dual boot only *buf++ = flags==3? 'D': flags==2? 'd': flags? 'f': '-'; } - flags = (type/UR_VBL) & 3; + flags = (type/(UR_VBLMASK & -UR_VBLMASK)) & (hi > 077? 1: 3); // Only use 1 bit for v8.0+ // V = VBL, patch & verify, v = VBL, patch only, j = VBL, jump only *buf++ = flags==3? 'V': flags==2? 'v': flags? 'j': 'h'; *buf++ = hi < 077? (type & UR_PROTECTME? 'p': '-'): (type & UR_PROTECTME? 'P': 'p'); diff --git a/src/urclock_private.h b/src/urclock_private.h index 941a7c38..65f18179 100644 --- a/src/urclock_private.h +++ b/src/urclock_private.h @@ -90,9 +90,10 @@ typedef struct { // Capability byte of bootloader from version 7.2 onwards #define UR_PGMWRITEPAGE 128 // pgm_write_page() can be called from application at FLASHEND+1-4 -#define UR_AUTOBAUD 128 // Bootloader has autobaud detection (from v7.7) +#define UR_AUTOBAUD 128 // Bootloader has autobaud detection (from v7.7) #define UR_EEPROM 64 // EEPROM read/write support #define UR_URPROTOCOL 32 // Using urprotocol (v7.6 and v7.7 only) +#define UR_EXPEDITE 32 // Check need to write flash first (from v8.0) #define UR_DUAL 16 // Dual boot #define UR_VBLMASK 12 // Vector bootloader bits (up to v7.7 only) #define UR_VBLPATCHVERIFY 12 // Patch reset/interrupt vectors and show original ones on verify From 514a09ad83f43477ad57ea028907dc97371e2982 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 00:32:39 +0100 Subject: [PATCH 078/422] Update NEWS --- NEWS | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/NEWS b/NEWS index 75d71733..69c394c8 100644 --- a/NEWS +++ b/NEWS @@ -11,9 +11,13 @@ Changes since version 7.3: * New devices supported: + - AVR16DU14, AVR16DU20, AVR16DU28, AVR16DU32 + - AVR32DU14, AVR32DU20, AVR32DU28, AVR32DU32 + * New programmers supported: * Issues fixed: + - Avrintel.h missing from installation #1683 - Use of undeclared identifier 'AVRDUDE_FULL_VERSION' #1706 - Wrong message level in jtag3_prmsg() #1726 @@ -27,8 +31,13 @@ Changes since version 7.3: - Remove calls to exit() from libavrdude library #774 - cmake enabling LINUXGPIO on ubuntu 20.04 fails #1782 - macOS github action failed. #1793 + - Format mismatch warnings #1799 + - 0xff optimization when reading #1732 + - Add support for more AVR-DU parts #1742 + - Misleading error message: cannot find programmer id #1805 * Pull requests: + - Remove 32bit MSYS2 mingw32 and clang32 build #1687 - Make avrintel.h an internal header file for libavrdude #1686 - Fix -Wcalloc-transposed-args warning #1680 @@ -65,9 +74,19 @@ Changes since version 7.3: - Use magic memory tree interface throughout #1795 - Silence MacOS compiler warning #1794 - Add macOS autotools to github action #1798 + - Silence compiler warnings #1800 + - Fix 7 typos in 4 files #1802 + - Put static variables into context structure #1803 + - Add new AVRnnDUnn parts #1804 + - Differentiate cause when programmer isn't found #1806 + - Prepare for next urboot version #1808 * Internals: + - Created a context structure pointed to by cx, which harbours global + and static variables + - Made programmers libavrdude ready: remove exit() calls and moved + static variables into local struct pdata Changes in version 7.3: From df1ecd34b5a94400230b601d685e3d2f561edd39 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:33:27 +0100 Subject: [PATCH 079/422] s/\bavrftdi_t\b/Avrftdi_data/g --- src/avrftdi.c | 70 ++++++++++++++++++++----------------------- src/avrftdi_private.h | 4 +-- src/avrftdi_tpi.c | 4 +-- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index 16501c84..e90f2879 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -84,13 +84,13 @@ enum { FTDI_TMS_CS, }; -static int write_flush(avrftdi_t *); +static int write_flush(Avrftdi_data *); /* * returns a human-readable name for a pin number. The name should match with * the pin names used in FTDI datasheets. */ -static char *ftdi_pin_name(avrftdi_t *pdata, struct pindef_t pin) { +static char *ftdi_pin_name(Avrftdi_data *pdata, struct pindef_t pin) { char *str = pdata->name_str; size_t strsiz = sizeof pdata->name_str; @@ -145,8 +145,7 @@ static void buf_dump(const unsigned char *buf, int len, char *desc, * calculates the so-called 'divisor'-value from a given frequency. * the divisor is sent to the chip. */ -static int set_frequency(avrftdi_t* ftdi, uint32_t freq) -{ +static int set_frequency(Avrftdi_data *ftdi, uint32_t freq) { int32_t clock, divisor; float hs_error, ls_error; uint8_t buf[4], *ptr = buf; @@ -211,7 +210,7 @@ static int set_pin(const PROGRAMMER *pgm, int pinfunc, int value) { if(pinfunc < 0 || pinfunc >= N_PINS) return -1; - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); struct pindef_t pin = pgm->pin[pinfunc]; if (pin.mask[0] == 0) { @@ -271,7 +270,7 @@ static inline int set_data(const PROGRAMMER *pgm, unsigned char *buf, unsigned c int j; int buf_pos = 0; unsigned char bit = 0x80; - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); for (j=0; j<8; j++) { pdata->pin_value = SET_BITS_0(pdata->pin_value,pgm,PIN_AVR_SDO,data & bit); @@ -324,7 +323,7 @@ static int avrftdi_transmit_bb(const PROGRAMMER *pgm, unsigned char mode, const { size_t remaining = buf_size; size_t written = 0; - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); size_t blocksize = pdata->rx_buffer_size/2; // we are reading 2 bytes per data byte // determine a maximum size of data block @@ -387,7 +386,7 @@ static int avrftdi_transmit_bb(const PROGRAMMER *pgm, unsigned char mode, const * Write is only performed when mode contains MPSSE_DO_WRITE. * Read is only performed when mode contains MPSSE_DO_WRITE and MPSSE_DO_READ. */ -static int avrftdi_transmit_mpsse(avrftdi_t* pdata, unsigned char mode, const unsigned char *buf, +static int avrftdi_transmit_mpsse(Avrftdi_data *pdata, unsigned char mode, const unsigned char *buf, unsigned char *data, int buf_size) { size_t blocksize; @@ -440,14 +439,14 @@ static int avrftdi_transmit_mpsse(avrftdi_t* pdata, unsigned char mode, const un static inline int avrftdi_transmit(const PROGRAMMER *pgm, unsigned char mode, const unsigned char *buf, unsigned char *data, int buf_size) { - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); if (pdata->use_bitbanging) return avrftdi_transmit_bb(pgm, mode, buf, data, buf_size); else return avrftdi_transmit_mpsse(pdata, mode, buf, data, buf_size); } -static int write_flush(avrftdi_t* pdata) +static int write_flush(Avrftdi_data *pdata) { unsigned char buf[6]; @@ -502,7 +501,7 @@ static int avrftdi_check_pins_bb(const PROGRAMMER *pgm, bool output) { /* pin checklist. */ struct pin_checklist_t pin_checklist[N_PINS]; - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); /* value for 8/12/16 bit wide interface */ int valid_mask = ((1 << pdata->pin_limit) - 1); @@ -529,7 +528,7 @@ static int avrftdi_check_pins_mpsse(const PROGRAMMER *pgm, bool output) { /* pin checklist. */ struct pin_checklist_t pin_checklist[N_PINS]; - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); struct pindef_t *valid_pins = pdata->mpsse_pins; @@ -585,7 +584,7 @@ static int avrftdi_pin_setup(const PROGRAMMER *pgm) { * pin setup * *************/ - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); bool pin_check_mpsse = (0 == avrftdi_check_pins_mpsse(pgm, verbose>3)); @@ -663,7 +662,7 @@ static int avrftdi_pin_setup(const PROGRAMMER *pgm) { static int avrftdi_open(PROGRAMMER *pgm, const char *port) { int vid, pid, interface, err; - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); /************************ * parameter validation * @@ -784,9 +783,8 @@ static int avrftdi_open(PROGRAMMER *pgm, const char *port) { return avrftdi_pin_setup(pgm)? -1: 0; } -static void avrftdi_close(PROGRAMMER * pgm) -{ - avrftdi_t* pdata = to_pdata(pgm); +static void avrftdi_close(PROGRAMMER *pgm) { + Avrftdi_data *pdata = to_pdata(pgm); if(pdata->ftdic->usb_dev) { set_pin(pgm, PIN_AVR_RESET, ON); @@ -909,7 +907,7 @@ static int avrftdi_lext(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m if(m->op[AVR_OP_LOAD_EXT_ADDR] == NULL) return 0; - avrftdi_t *pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); unsigned char buf[] = { 0x00, 0x00, 0x00, 0x00 }; /* only send load extended address command if high byte changed */ @@ -1091,7 +1089,7 @@ static int avrftdi_flash_write(const PROGRAMMER *pgm, const AVRPART *p, const AV static int avrftdi_flash_read(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int page_size, unsigned int addr, unsigned int len) { - OPCODE * readop; + OPCODE *readop; unsigned int buf_size = 4 * len + 4; unsigned char* o_buf = alloca(buf_size); @@ -1186,10 +1184,10 @@ static int avrftdi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR return -2; } -static void avrftdi_setup(PROGRAMMER * pgm) { - avrftdi_t* pdata; +static void avrftdi_setup(PROGRAMMER *pgm) { + Avrftdi_data *pdata; - pgm->cookie = mmt_malloc(sizeof(avrftdi_t)); + pgm->cookie = mmt_malloc(sizeof(Avrftdi_data)); pdata = to_pdata(pgm); /* SCK/SDO/SDI are fixed and not invertible? */ @@ -1216,9 +1214,9 @@ static void avrftdi_setup(PROGRAMMER * pgm) { pdata->lext_byte = 0xff; } -static void avrftdi_teardown(PROGRAMMER * pgm) { +static void avrftdi_teardown(PROGRAMMER *pgm) { if(pgm->cookie) { - avrftdi_t *pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); ftdi_deinit(pdata->ftdic); ftdi_free(pdata->ftdic); mmt_free(pdata); @@ -1230,9 +1228,8 @@ static void avrftdi_teardown(PROGRAMMER * pgm) { /* JTAG functions */ /******************/ -static int avrftdi_jtag_reset(const PROGRAMMER *pgm) -{ - avrftdi_t *pdata = to_pdata(pgm); +static int avrftdi_jtag_reset(const PROGRAMMER *pgm) { + Avrftdi_data *pdata = to_pdata(pgm); unsigned char buf[3], *ptr = buf; /* Unknown -> Reset -> Run-Test/Idle */ @@ -1245,9 +1242,8 @@ static int avrftdi_jtag_reset(const PROGRAMMER *pgm) return 0; } -static int avrftdi_jtag_ir_out(const PROGRAMMER *pgm, unsigned char ir) -{ - avrftdi_t *pdata = to_pdata(pgm); +static int avrftdi_jtag_ir_out(const PROGRAMMER *pgm, unsigned char ir) { + Avrftdi_data *pdata = to_pdata(pgm); unsigned char buf[9], *ptr = buf; /* Idle -> Select-DR -> Select-IR -> Capture-IR -> Shift-IR */ @@ -1270,9 +1266,8 @@ static int avrftdi_jtag_ir_out(const PROGRAMMER *pgm, unsigned char ir) return 0; } -static int avrftdi_jtag_dr_out(const PROGRAMMER *pgm, unsigned int dr, int bits) -{ - avrftdi_t *pdata = to_pdata(pgm); +static int avrftdi_jtag_dr_out(const PROGRAMMER *pgm, unsigned int dr, int bits) { + Avrftdi_data *pdata = to_pdata(pgm); unsigned char buf[18], *ptr = buf; if (bits <= 0 || bits > 31) { @@ -1314,7 +1309,7 @@ static int avrftdi_jtag_dr_out(const PROGRAMMER *pgm, unsigned int dr, int bits) static int avrftdi_jtag_dr_inout(const PROGRAMMER *pgm, unsigned int dr, int bits) { - avrftdi_t *pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); unsigned char buf[19], *ptr = buf; unsigned char bytes = 1, pos; unsigned int dr_in; @@ -1419,9 +1414,8 @@ static int avrftdi_jtag_initialize(const PROGRAMMER *pgm, const AVRPART *p) return 0; } -static void avrftdi_jtag_disable(const PROGRAMMER *pgm) -{ - avrftdi_t *pdata = to_pdata(pgm); +static void avrftdi_jtag_disable(const PROGRAMMER *pgm) { + Avrftdi_data *pdata = to_pdata(pgm); /* NOP command */ avrftdi_jtag_ir_out(pgm, JTAG_IR_PROG_COMMANDS); @@ -1682,7 +1676,7 @@ static int avrftdi_jtag_paged_read(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int page_size, unsigned int addr, unsigned int n_bytes) { - avrftdi_t *pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); unsigned int maxaddr = addr + n_bytes; unsigned char *buf, *ptr; unsigned int bytes; diff --git a/src/avrftdi_private.h b/src/avrftdi_private.h index 2d453099..72b9ce30 100644 --- a/src/avrftdi_private.h +++ b/src/avrftdi_private.h @@ -72,7 +72,7 @@ enum jtag_cmd { }; #define to_pdata(pgm) \ - ((avrftdi_t *)((pgm)->cookie)) + ((Avrftdi_data *)((pgm)->cookie)) typedef struct avrftdi_s { /* pointer to struct maintained by libftdi to identify the device */ @@ -98,7 +98,7 @@ typedef struct avrftdi_s { struct pindef_t valid_pins; // Used in avrftdi_check_pins_bb() struct pindef_t mpsse_pins[4]; // Used in avrftdi_check_pins_mpsse() struct pindef_t other_pins; // Used in avrftdi_check_pins_mpsse() -} avrftdi_t; +} Avrftdi_data; #endif /* DO_NOT_BUILD_AVRFDTI */ diff --git a/src/avrftdi_tpi.c b/src/avrftdi_tpi.c index 934d9936..3a45e5f1 100644 --- a/src/avrftdi_tpi.c +++ b/src/avrftdi_tpi.c @@ -64,7 +64,7 @@ int avrftdi_tpi_initialize(const PROGRAMMER *pgm, const AVRPART *p) { int ret; - avrftdi_t* pdata = to_pdata(pgm); + Avrftdi_data *pdata = to_pdata(pgm); unsigned char buf[] = { MPSSE_DO_WRITE | MPSSE_WRITE_NEG | MPSSE_LSB, 0x01, 0x00, 0xff, 0xff }; pmsg_info("Setting /Reset pin low\n"); @@ -132,7 +132,7 @@ static uint16_t tpi_byte2frame(uint8_t byte) { return frame; } -static int tpi_frame2byte(uint16_t frame, uint8_t * byte) { +static int tpi_frame2byte(uint16_t frame, uint8_t *byte) { /* drop idle and start bit(s) */ *byte = (frame >> 5) & 0xff; From 79ac24b8a4eff9fa913017de5f78136c361f0bc4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:33:58 +0100 Subject: [PATCH 080/422] s/\bBlhash_t\b/Bl_hash/g --- src/urclock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index dbfdff29..88065aeb 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -1092,10 +1092,10 @@ static uint32_t jenkins_hash(const uint8_t* key, size_t length) { typedef struct { uint16_t sz, ee; uint32_t h256, hash; -} Blhash_t; +} Bl_hash; static int cmpblhash(const void *va, const void *vb) { - const Blhash_t *a = va, *b = vb; + const Bl_hash *a = va, *b = vb; return a->sz > b->sz? 1: a->sz < b->sz? -1: a->hash > b->hash? 1: a->hash < b->hash? -1: 0; } @@ -1103,7 +1103,7 @@ static void guessblstart(const PROGRAMMER *pgm, const AVRPART *p) { if(ur.urprotocol && !(ur.urfeatures & UB_READ_FLASH)) // Cannot read flash return; - Blhash_t blist[] = { + Bl_hash blist[] = { // From https://github.com/arduino/ArduinoCore-avr/tree/master/bootloaders { 1024, 0, 0x35445c45, 0x9ef77953 }, // ATmegaBOOT-prod-firmware-2009-11-07.hex { 1024, 0, 0x32b1376c, 0xceba80bb }, // ATmegaBOOT.hex From 96218db0a916d47fff7dcc9612b387eb66e08a14 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:34:12 +0100 Subject: [PATCH 081/422] s/\bCacheDesc_t\b/Cache_desc/g --- src/avrcache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/avrcache.c b/src/avrcache.c index 38aa4f8c..fe0ff9a2 100644 --- a/src/avrcache.c +++ b/src/avrcache.c @@ -363,12 +363,12 @@ typedef struct { AVRMEM *mem; AVR_Cache *cp; int isflash, iseeprom, zopaddr, pgerase; -} CacheDesc_t; +} Cache_desc; // Write flash, EEPROM, bootrow and usersig caches to device and free them int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) { - CacheDesc_t mems[] = { + Cache_desc mems[] = { { avr_locate_flash(p), pgm->cp_flash, 1, 0, -1, 0 }, { avr_locate_eeprom(p), pgm->cp_eeprom, 0, 1, -1, 0 }, { avr_locate_bootrow(p), pgm->cp_bootrow, 0, 0, -1, 0 }, @@ -689,7 +689,7 @@ int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM // Erase the chip and set the cache accordingly int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p) { - CacheDesc_t mems[3] = { + Cache_desc mems[3] = { { avr_locate_flash(p), pgm->cp_flash, 1, 0, -1, 0 }, { avr_locate_eeprom(p), pgm->cp_eeprom, 0, 1, -1, 0 }, // bootrow/usersig is unaffected by CE From efa4aba1b8f3bad2cb0b2275550c51c7c8deea08 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:34:27 +0100 Subject: [PATCH 082/422] s/\bCfg_opts_t\b/Cfg_opts/g --- src/term.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/term.c b/src/term.c index c6a24ed1..e151bece 100644 --- a/src/term.c +++ b/src/term.c @@ -958,7 +958,7 @@ typedef struct { typedef struct { // Context parameters to be passed to functions int verb, allscript, flheaders, allv, vmax, printfactory; -} Cfg_opts_t; +} Cfg_opts; // Cache the contents of the fuse and lock bits memories that a particular Configitem is involved in static int getfusel(const PROGRAMMER *pgm, const AVRPART *p, Fusel_t *fl, const Cfg_t *cci, const char **errpp) { @@ -1098,7 +1098,7 @@ static int gatherval(const PROGRAMMER *pgm, const AVRPART *p, Cfg_t *cc, int i, } // Comment printed next to symbolic value -static const char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, int value, Cfg_opts_t o) { +static const char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, int value, Cfg_opts o) { char buf[512], bin[129]; unsigned u = value, m = cti->mask >> cti->lsh; int lsh = cti->lsh; @@ -1137,14 +1137,14 @@ static const char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, } // How a single property is printed -static void printoneproperty(Cfg_t *cc, int ii, const Valueitem_t *vp, int llen, const char *vstr, Cfg_opts_t o) { +static void printoneproperty(Cfg_t *cc, int ii, const Valueitem_t *vp, int llen, const char *vstr, Cfg_opts o) { int value = vp? vp->value: cc[ii].val; term_out("%s %s=%-*s # %s\n", vp && cc[ii].val != vp->value? "# conf": "config", cc[ii].t->name, llen, vstr, valuecomment(cc[ii].t, vp, value, o)); } // Prints a list of all possible values (o.allv) or just the one proporty cc[ii] -static void printproperty(Cfg_t *cc, int ii, Cfg_opts_t o) { +static void printproperty(Cfg_t *cc, int ii, Cfg_opts o) { const Valueitem_t *vt = cc[ii].t->vlist, *vp; int nv = cc[ii].t->nvalues; const char *ccom = cc->t[ii].ccomment, *col = strchr(ccom, ':'); @@ -1209,7 +1209,7 @@ static void printproperty(Cfg_t *cc, int ii, Cfg_opts_t o) { } // Print the fuse/lock bits header (-f, o.flheaders) -static void printfuse(Cfg_t *cc, int ii, Flock_t *fc, int nf, int printed, Cfg_opts_t o) { +static void printfuse(Cfg_t *cc, int ii, Flock_t *fc, int nf, int printed, Cfg_opts o) { char buf[512]; int fj; for(fj=0; fj 0; ) { // Simple option parsing From e33ad3a20c3052695f3855aa135acbbbde860e18 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:35:00 +0100 Subject: [PATCH 083/422] s/\bCfg_t\b/Cnfg/g --- src/term.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/term.c b/src/term.c index e151bece..cdff7e03 100644 --- a/src/term.c +++ b/src/term.c @@ -954,14 +954,14 @@ typedef struct { const char *alt; // Set when memstr is an alias int match; // Matched by user request int ok, val, initval; // Has value val been read OK? Initval == -1 if not known -} Cfg_t; +} Cnfg; typedef struct { // Context parameters to be passed to functions int verb, allscript, flheaders, allv, vmax, printfactory; } Cfg_opts; // Cache the contents of the fuse and lock bits memories that a particular Configitem is involved in -static int getfusel(const PROGRAMMER *pgm, const AVRPART *p, Fusel_t *fl, const Cfg_t *cci, const char **errpp) { +static int getfusel(const PROGRAMMER *pgm, const AVRPART *p, Fusel_t *fl, const Cnfg *cci, const char **errpp) { const char *err = NULL; int islock; @@ -1022,7 +1022,7 @@ back: return err? -1: 0; } -static int setmatches(const char *str, int n, Cfg_t *cc) { +static int setmatches(const char *str, int n, Cnfg *cc) { int matches = 0; if(!*str) @@ -1075,7 +1075,7 @@ typedef struct { // Fuse/lock properties of the part // Fill in cc record with the actual value of the relevant fuse -static int gatherval(const PROGRAMMER *pgm, const AVRPART *p, Cfg_t *cc, int i, +static int gatherval(const PROGRAMMER *pgm, const AVRPART *p, Cnfg *cc, int i, Fusel_t *fuselp, Flock_t *fc, int nf) { // Load current value of this config item @@ -1137,14 +1137,14 @@ static const char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, } // How a single property is printed -static void printoneproperty(Cfg_t *cc, int ii, const Valueitem_t *vp, int llen, const char *vstr, Cfg_opts o) { +static void printoneproperty(Cnfg *cc, int ii, const Valueitem_t *vp, int llen, const char *vstr, Cfg_opts o) { int value = vp? vp->value: cc[ii].val; term_out("%s %s=%-*s # %s\n", vp && cc[ii].val != vp->value? "# conf": "config", cc[ii].t->name, llen, vstr, valuecomment(cc[ii].t, vp, value, o)); } // Prints a list of all possible values (o.allv) or just the one proporty cc[ii] -static void printproperty(Cfg_t *cc, int ii, Cfg_opts o) { +static void printproperty(Cnfg *cc, int ii, Cfg_opts o) { const Valueitem_t *vt = cc[ii].t->vlist, *vp; int nv = cc[ii].t->nvalues; const char *ccom = cc->t[ii].ccomment, *col = strchr(ccom, ':'); @@ -1209,7 +1209,7 @@ static void printproperty(Cfg_t *cc, int ii, Cfg_opts o) { } // Print the fuse/lock bits header (-f, o.flheaders) -static void printfuse(Cfg_t *cc, int ii, Flock_t *fc, int nf, int printed, Cfg_opts o) { +static void printfuse(Cnfg *cc, int ii, Flock_t *fc, int nf, int printed, Cfg_opts o) { char buf[512]; int fj; for(fj=0; fj Date: Sat, 18 May 2024 01:35:35 +0100 Subject: [PATCH 084/422] s/\bdry_prog_t\b/Dry_prog/g --- src/dryrun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index 04da53d0..c6c8eb7b 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -47,11 +47,11 @@ typedef enum { DRY_NOBOOTLOADER, // No bootloader, taking to an ordinary programmer DRY_TOP, // Bootloader and it sits at top of flash DRY_BOTTOM, // Bootloader sits at bottom of flash (UPDI parts) -} dry_prog_t; +} Dry_prog; typedef struct { AVRPART *dp; - dry_prog_t bl; // Bootloader and, if so, at top/bottom of flash? + Dry_prog bl; // Bootloader and, if so, at top/bottom of flash? int blsize; // Bootloader size min(flash size/4, 512) } dryrun_t; From 73aa17fd4b518f5138e47bd434ac077a98c788be Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:35:49 +0100 Subject: [PATCH 085/422] s/\bdryrun_t\b/Dryrun_data/g --- src/dryrun.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index c6c8eb7b..c6714eb8 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -53,10 +53,10 @@ typedef struct { AVRPART *dp; Dry_prog bl; // Bootloader and, if so, at top/bottom of flash? int blsize; // Bootloader size min(flash size/4, 512) -} dryrun_t; +} Dryrun_data; // Use private programmer data as if they were a global structure dry -#define dry (*(dryrun_t *)(pgm->cookie)) +#define dry (*(Dryrun_data *)(pgm->cookie)) #define Return(...) do { pmsg_error(__VA_ARGS__); msg_error("\n"); return -1; } while (0) @@ -535,7 +535,7 @@ static int dryrun_readonly(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM static void dryrun_setup(PROGRAMMER *pgm) { pmsg_debug("%s()\n", __func__); // Allocate dry - pgm->cookie = mmt_malloc(sizeof(dryrun_t)); + pgm->cookie = mmt_malloc(sizeof(Dryrun_data)); } From 8b78b7d63b3bd68fb463e5ca6b828c0ff1a20c38 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:36:05 +0100 Subject: [PATCH 086/422] s/\bFlock_t\b/FL_item/g --- src/term.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/term.c b/src/term.c index cdff7e03..5af47eb8 100644 --- a/src/term.c +++ b/src/term.c @@ -1071,12 +1071,12 @@ typedef struct { // Fuse/lock properties of the part const char *memstr; int mask; int value; -} Flock_t; +} FL_item; // Fill in cc record with the actual value of the relevant fuse static int gatherval(const PROGRAMMER *pgm, const AVRPART *p, Cnfg *cc, int i, - Fusel_t *fuselp, Flock_t *fc, int nf) { + Fusel_t *fuselp, FL_item *fc, int nf) { // Load current value of this config item const char *errstr = NULL; @@ -1209,7 +1209,7 @@ static void printproperty(Cnfg *cc, int ii, Cfg_opts o) { } // Print the fuse/lock bits header (-f, o.flheaders) -static void printfuse(Cnfg *cc, int ii, Flock_t *fc, int nf, int printed, Cfg_opts o) { +static void printfuse(Cnfg *cc, int ii, FL_item *fc, int nf, int printed, Cfg_opts o) { char buf[512]; int fj; for(fj=0; fj Date: Sat, 18 May 2024 01:36:19 +0100 Subject: [PATCH 087/422] s/\bfl_t\b/Intbytes/g --- src/term.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/term.c b/src/term.c index 5af47eb8..ebecd8d1 100644 --- a/src/term.c +++ b/src/term.c @@ -938,7 +938,7 @@ static const int MAX_PAD = 10; // Align value labels if their length difference typedef union { // Lock memory can be 1 or 4 bytes uint8_t b[4]; uint32_t i; -} fl_t; +} Intbytes; typedef struct { // Fuses and lock bits uint16_t fuses[16]; // pdicfg fuse has two bytes @@ -996,7 +996,7 @@ static int getfusel(const PROGRAMMER *pgm, const AVRPART *p, Fusel_t *fl, const goto back; } - fl_t m = {.i = 0}; + Intbytes m = {.i = 0}; for(int i=0; isize; i++) if(led_read_byte(pgm, p, mem, i, m.b+i) < 0) { err = cache_string(str_ccprintf("cannot read %s's %s memory", p->desc, mem->desc)); @@ -1510,7 +1510,7 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c goto finished; } - fl_t towrite; + Intbytes towrite; towrite.i = (fusel.current & ~ct[ci].mask) | (toassign< Date: Sat, 18 May 2024 01:36:37 +0100 Subject: [PATCH 088/422] s/\bFusel_t\b/Part_FL/g --- src/term.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/term.c b/src/term.c index ebecd8d1..1e894f03 100644 --- a/src/term.c +++ b/src/term.c @@ -946,7 +946,7 @@ typedef struct { // Fuses and lock bits int fread[16], lread; int islock; uint32_t current; -} Fusel_t; +} Part_FL; typedef struct { const Configitem_t *t; // Configuration bitfield table @@ -961,7 +961,7 @@ typedef struct { // Context parameters to be passed to functions } Cfg_opts; // Cache the contents of the fuse and lock bits memories that a particular Configitem is involved in -static int getfusel(const PROGRAMMER *pgm, const AVRPART *p, Fusel_t *fl, const Cnfg *cci, const char **errpp) { +static int getfusel(const PROGRAMMER *pgm, const AVRPART *p, Part_FL *fl, const Cnfg *cci, const char **errpp) { const char *err = NULL; int islock; @@ -1076,7 +1076,7 @@ typedef struct { // Fuse/lock properties of the part // Fill in cc record with the actual value of the relevant fuse static int gatherval(const PROGRAMMER *pgm, const AVRPART *p, Cnfg *cc, int i, - Fusel_t *fuselp, FL_item *fc, int nf) { + Part_FL *fuselp, FL_item *fc, int nf) { // Load current value of this config item const char *errstr = NULL; @@ -1314,7 +1314,7 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c int idx = -1; // Index in uP_table[] const Configitem_t *ct; // Configuration bitfield table int nc; // Number of config properties, some may not be available - Fusel_t fusel; // Copy of fuses and lock bits + Part_FL fusel; // Copy of fuses and lock bits const Valueitem_t *vt; // Pointer to symbolic labels and associated values int nv; // Number of symbolic labels Cnfg *cc; // Current configuration; cc[] and ct[] are parallel arrays From 55f6ee67c0d115522870d2b56944735f5489a68d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:36:51 +0100 Subject: [PATCH 089/422] s/\bis_outside_int64_t\b/is_outside_int64/g --- src/strutil.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/strutil.c b/src/strutil.c index 85369026..7a8e0085 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -642,7 +642,7 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m // Try integers and assign data size if(type & STR_INTEGER) { - bool is_big_endian, is_signed = 0, is_outside_int64_t = 0, is_out_of_range = 0; + bool is_big_endian, is_signed = 0, is_outside_int64 = 0, is_out_of_range = 0; char *stri = str; while(isspace(*stri & 0xff)) @@ -684,9 +684,9 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m if(is_signed) { // Is input in range for int64_t? if(*stri == '-' && (sd->ull == ~(~0ULL>>1) || sd->ll > 0)) - is_outside_int64_t = 1; + is_outside_int64 = 1; if(*stri != '-' && sd->ll < 0) - is_outside_int64_t = 1; + is_outside_int64 = 1; } // Set size @@ -699,7 +699,7 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m } else if(is_signed) { // Smallest size that fits signed or unsigned (asymmetric to meet user expectation) sd->size = - is_outside_int64_t? 8: + is_outside_int64? 8: sd->ll < INT32_MIN || sd->ll > (long long) UINT32_MAX? 8: sd->ll < INT16_MIN || sd->ll > (long long) UINT16_MAX? 4: sd->ll < INT8_MIN || sd->ll > (long long) UINT8_MAX? 2: 1; @@ -760,7 +760,7 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m else if(is_out_of_range) Warning("%s out of uint%d range, interpreted as %d-byte %llu", stri, sd->size*8, sd->size, (long long unsigned int) sd->ull); - else if(is_outside_int64_t) + else if(is_outside_int64) Warning("%s out of int64 range (consider U suffix)", stri); sd->type = STR_INTEGER; From 2bfc2968a642fab0effead1eb42e446dd6af6307 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:40:31 +0100 Subject: [PATCH 090/422] s/\bpdata_t\b/struct pdata/g --- src/micronucleus.c | 67 ++++++++++++++++++---------------------------- src/teensy.c | 39 ++++++++++++--------------- 2 files changed, 43 insertions(+), 63 deletions(-) diff --git a/src/micronucleus.c b/src/micronucleus.c index beba31a3..c5459772 100644 --- a/src/micronucleus.c +++ b/src/micronucleus.c @@ -75,12 +75,11 @@ #define MICRONUCLEUS_DEFAULT_TIMEOUT 500 #define MICRONUCLEUS_MAX_MAJOR_VERSION 2 -#define PDATA(pgm) ((pdata_t*)(pgm->cookie)) +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) //----------------------------------------------------------------------------- -typedef struct pdata -{ +struct pdata { usb_dev_handle* usb_handle; // Extended parameters bool wait_until_device_present; @@ -102,7 +101,7 @@ typedef struct pdata uint16_t user_reset_vector; // reset vector of user program bool write_last_page; // last page already programmed bool start_program; // require start after flash -} pdata_t; +}; //----------------------------------------------------------------------------- @@ -111,8 +110,7 @@ static void delay_ms(uint32_t duration) usleep(duration * 1000); } -static int micronucleus_check_connection(pdata_t* pdata) -{ +static int micronucleus_check_connection(struct pdata *pdata) { if (pdata->major_version >= 2) { uint8_t buffer[6] = { 0 }; @@ -139,8 +137,7 @@ static int micronucleus_check_connection(pdata_t* pdata) } } -static bool micronucleus_is_device_responsive(pdata_t* pdata, struct usb_device* device) -{ +static bool micronucleus_is_device_responsive(struct pdata *pdata, struct usb_device *device) { pdata->usb_handle = usb_open(device); if (pdata->usb_handle == NULL) { @@ -155,8 +152,7 @@ static bool micronucleus_is_device_responsive(pdata_t* pdata, struct usb_device* return result >= 0; } -static int micronucleus_reconnect(pdata_t* pdata) -{ +static int micronucleus_reconnect(struct pdata *pdata) { struct usb_device* device = usb_device(pdata->usb_handle); usb_close(pdata->usb_handle); @@ -176,8 +172,7 @@ static int micronucleus_reconnect(pdata_t* pdata) return -1; } -static int micronucleus_get_bootloader_info_v1(pdata_t* pdata) -{ +static int micronucleus_get_bootloader_info_v1(struct pdata *pdata) { uint8_t buffer[4] = { 0 }; int result = usb_control_msg( pdata->usb_handle, @@ -243,8 +238,7 @@ static int micronucleus_get_bootloader_info_v1(pdata_t* pdata) return 0; } -static int micronucleus_get_bootloader_info_v2(pdata_t* pdata) -{ +static int micronucleus_get_bootloader_info_v2(struct pdata *pdata) { uint8_t buffer[6] = { 0 }; int result = usb_control_msg( pdata->usb_handle, @@ -284,8 +278,7 @@ static int micronucleus_get_bootloader_info_v2(pdata_t* pdata) return 0; } -static int micronucleus_get_bootloader_info(pdata_t* pdata) -{ +static int micronucleus_get_bootloader_info(struct pdata *pdata) { if (pdata->major_version >= 2) { return micronucleus_get_bootloader_info_v2(pdata); @@ -296,8 +289,7 @@ static int micronucleus_get_bootloader_info(pdata_t* pdata) } } -static void micronucleus_dump_device_info(pdata_t* pdata) -{ +static void micronucleus_dump_device_info(struct pdata *pdata) { pmsg_notice("Bootloader version: %d.%d\n", pdata->major_version, pdata->minor_version); imsg_notice("Available flash size: %u\n", pdata->flash_size); imsg_notice("Page size: %u\n", pdata->page_size); @@ -308,8 +300,7 @@ static void micronucleus_dump_device_info(pdata_t* pdata) imsg_notice("Signature2: 0x%02X\n", pdata->signature2); } -static int micronucleus_erase_device(pdata_t* pdata) -{ +static int micronucleus_erase_device(struct pdata *pdata) { pmsg_debug("micronucleus_erase_device()\n"); int result = usb_control_msg( @@ -351,8 +342,7 @@ static int micronucleus_erase_device(pdata_t* pdata) return 0; } -static int micronucleus_patch_reset_vector(pdata_t* pdata, uint8_t* buffer) -{ +static int micronucleus_patch_reset_vector(struct pdata *pdata, uint8_t *buffer) { // Save user reset vector. uint16_t word0 = (buffer[1] << 8) | buffer[0]; uint16_t word1 = (buffer[3] << 8) | buffer[2]; @@ -394,8 +384,7 @@ static int micronucleus_patch_reset_vector(pdata_t* pdata, uint8_t* buffer) return 0; } -static void micronucleus_patch_user_vector(pdata_t* pdata, uint8_t* buffer) -{ +static void micronucleus_patch_user_vector(struct pdata *pdata, uint8_t *buffer) { uint16_t user_reset_addr = pdata->bootloader_start - 4; uint16_t address = pdata->bootloader_start - pdata->page_size; if (user_reset_addr > 0x2000) @@ -416,8 +405,7 @@ static void micronucleus_patch_user_vector(pdata_t* pdata, uint8_t* buffer) } } -static int micronucleus_write_page_v1(pdata_t* pdata, uint32_t address, uint8_t* buffer, uint32_t size) -{ +static int micronucleus_write_page_v1(struct pdata *pdata, uint32_t address, uint8_t *buffer, uint32_t size) { int result = usb_control_msg( pdata->usb_handle, USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, @@ -434,8 +422,7 @@ static int micronucleus_write_page_v1(pdata_t* pdata, uint32_t address, uint8_t* return 0; } -static int micronucleus_write_page_v2(pdata_t* pdata, uint32_t address, uint8_t* buffer, uint32_t size) -{ +static int micronucleus_write_page_v2(struct pdata *pdata, uint32_t address, uint8_t *buffer, uint32_t size) { int result = usb_control_msg( pdata->usb_handle, USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, @@ -470,8 +457,7 @@ static int micronucleus_write_page_v2(pdata_t* pdata, uint32_t address, uint8_t* return 0; } -static int micronucleus_write_page(pdata_t* pdata, uint32_t address, uint8_t* buffer, uint32_t size) -{ +static int micronucleus_write_page(struct pdata *pdata, uint32_t address, uint8_t *buffer, uint32_t size) { pmsg_debug("micronucleus_write_page(address=0x%04X, size=%d)\n", address, size); if (address == 0) @@ -522,8 +508,7 @@ static int micronucleus_write_page(pdata_t* pdata, uint32_t address, uint8_t* bu return 0; } -static int micronucleus_start(pdata_t* pdata) -{ +static int micronucleus_start(struct pdata *pdata) { pmsg_debug("micronucleus_start()\n"); int result = usb_control_msg( @@ -546,7 +531,7 @@ static int micronucleus_start(pdata_t* pdata) static void micronucleus_setup(PROGRAMMER *pgm) { pmsg_debug("micronucleus_setup()\n"); - pgm->cookie = mmt_malloc(sizeof(pdata_t)); + pgm->cookie = mmt_malloc(sizeof(struct pdata)); } static void micronucleus_teardown(PROGRAMMER* pgm) { @@ -558,7 +543,7 @@ static void micronucleus_teardown(PROGRAMMER* pgm) { static int micronucleus_initialize(const PROGRAMMER *pgm, const AVRPART *p) { pmsg_debug("micronucleus_initialize()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); int result = micronucleus_get_bootloader_info(pdata); if (result < 0) @@ -580,7 +565,7 @@ static void micronucleus_powerup(const PROGRAMMER *pgm) { static void micronucleus_powerdown(const PROGRAMMER *pgm) { pmsg_debug("micronucleus_powerdown()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); if (pdata->write_last_page) { pdata->write_last_page = false; @@ -621,7 +606,7 @@ static int micronucleus_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, return -1; } - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); mem->buf[0] = 0x1E; mem->buf[1] = pdata->signature1; mem->buf[2] = pdata->signature2; @@ -631,14 +616,14 @@ static int micronucleus_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, static int micronucleus_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { pmsg_debug("micronucleus_chip_erase()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); return micronucleus_erase_device(pdata); } static int micronucleus_open(PROGRAMMER* pgm, const char *port) { pmsg_debug("micronucleus_open(\"%s\")\n", port); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); const char *bus_name = NULL; char* dev_name = NULL; @@ -790,7 +775,7 @@ static void micronucleus_close(PROGRAMMER* pgm) { pmsg_debug("micronucleus_close()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); if (pdata->usb_handle != NULL) { usb_close(pdata->usb_handle); @@ -838,7 +823,7 @@ static int micronucleus_paged_write(const PROGRAMMER *pgm, const AVRPART *p, con if (mem_is_flash(mem)) { - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); if (n_bytes > page_size) { @@ -886,7 +871,7 @@ static int micronucleus_paged_write(const PROGRAMMER *pgm, const AVRPART *p, con static int micronucleus_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) { pmsg_debug("micronucleus_parseextparams()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); for (LNODEID node = lfirst(xparams); node != NULL; node = lnext(node)) { const char* param = ldata(node); diff --git a/src/teensy.c b/src/teensy.c index 11a2b9f1..dd5c58d3 100644 --- a/src/teensy.c +++ b/src/teensy.c @@ -59,12 +59,11 @@ #define TEENSY_CONNECT_WAIT 100 -#define PDATA(pgm) ((pdata_t*)(pgm->cookie)) +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) //----------------------------------------------------------------------------- -typedef struct pdata -{ +struct pdata { hid_device* hid_handle; uint16_t hid_usage; // Extended parameters @@ -78,7 +77,7 @@ typedef struct pdata // State bool erase_flash; bool reboot; -} pdata_t; +}; //----------------------------------------------------------------------------- @@ -87,7 +86,7 @@ static void delay_ms(uint32_t duration) usleep(duration * 1000); } -static int teensy_get_bootloader_info(pdata_t* pdata, const AVRPART* p) { +static int teensy_get_bootloader_info(struct pdata *pdata, const AVRPART *p) { switch (pdata->hid_usage) { case 0x19: @@ -156,8 +155,7 @@ static int teensy_get_bootloader_info(pdata_t* pdata, const AVRPART* p) { return 0; } -static void teensy_dump_device_info(pdata_t* pdata) -{ +static void teensy_dump_device_info(struct pdata *pdata) { pmsg_notice("HID usage: 0x%02X\n", pdata->hid_usage); pmsg_notice("Board: %s\n", pdata->board); pmsg_notice("Available flash size: %u\n", pdata->flash_size); @@ -166,8 +164,7 @@ static void teensy_dump_device_info(pdata_t* pdata) pdata->sig_bytes[0], pdata->sig_bytes[1], pdata->sig_bytes[2]); } -static int teensy_write_page(pdata_t* pdata, uint32_t address, const uint8_t* buffer, uint32_t size, bool suppress_warning) -{ +static int teensy_write_page(struct pdata *pdata, uint32_t address, const uint8_t *buffer, uint32_t size, bool suppress_warning) { pmsg_debug("teensy_write_page(address=0x%06X, size=%d)\n", address, size); if (size > pdata->page_size) @@ -211,16 +208,14 @@ static int teensy_write_page(pdata_t* pdata, uint32_t address, const uint8_t* bu return 0; } -static int teensy_erase_flash(pdata_t* pdata) -{ +static int teensy_erase_flash(struct pdata *pdata) { pmsg_debug("teensy_erase_flash()\n"); // Write a dummy page at address 0 to explicitly erase the flash. return teensy_write_page(pdata, 0, NULL, 0, false); } -static int teensy_reboot(pdata_t* pdata) -{ +static int teensy_reboot(struct pdata *pdata) { pmsg_debug("teensy_reboot()\n"); // Write a dummy page at address -1 to reboot the Teensy. @@ -231,7 +226,7 @@ static int teensy_reboot(pdata_t* pdata) static void teensy_setup(PROGRAMMER *pgm) { pmsg_debug("teensy_setup()\n"); - pgm->cookie = mmt_malloc(sizeof(pdata_t)); + pgm->cookie = mmt_malloc(sizeof(struct pdata)); } static void teensy_teardown(PROGRAMMER *pgm) { @@ -243,7 +238,7 @@ static void teensy_teardown(PROGRAMMER *pgm) { static int teensy_initialize(const PROGRAMMER *pgm, const AVRPART *p) { pmsg_debug("teensy_initialize()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); int result = teensy_get_bootloader_info(pdata, p); if (result < 0) @@ -265,7 +260,7 @@ static void teensy_powerup(const PROGRAMMER *pgm) { static void teensy_powerdown(const PROGRAMMER *pgm) { pmsg_debug("teensy_powerdown()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); if (pdata->erase_flash) { @@ -302,7 +297,7 @@ static int teensy_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const return -1; } - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); memcpy(mem->buf, pdata->sig_bytes, sizeof(pdata->sig_bytes)); return 0; @@ -311,7 +306,7 @@ static int teensy_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const static int teensy_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { pmsg_debug("teensy_chip_erase()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); // Schedule a chip erase, either at first write or on powerdown. pdata->erase_flash = true; @@ -322,7 +317,7 @@ static int teensy_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { static int teensy_open(PROGRAMMER *pgm, const char *port) { pmsg_debug("teensy_open(\"%s\")\n", port); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); const char *bus_name = NULL; char* dev_name = NULL; @@ -438,7 +433,7 @@ static void teensy_close(PROGRAMMER* pgm) { pmsg_debug("teensy_close()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); if (pdata->hid_handle != NULL) { hid_close(pdata->hid_handle); @@ -486,7 +481,7 @@ static int teensy_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR if (mem_is_flash(mem)) { - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); if (n_bytes > page_size) { @@ -537,7 +532,7 @@ static int teensy_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR static int teensy_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) { pmsg_debug("teensy_parseextparams()\n"); - pdata_t* pdata = PDATA(pgm); + struct pdata *pdata = PDATA(pgm); for (LNODEID node = lfirst(xparams); node != NULL; node = lnext(node)) { const char* param = ldata(node); From 74e28d752a6302e1c4dc3f753d4fff1b78090747 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:40:46 +0100 Subject: [PATCH 091/422] s/\bppipins_t\b/ppipins/g --- src/par.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/par.c b/src/par.c index 84630348..ce702f9f 100644 --- a/src/par.c +++ b/src/par.c @@ -44,14 +44,14 @@ #if HAVE_PARPORT -struct ppipins_t { +struct ppipins { int pin; int reg; int bit; int inverted; }; -static const struct ppipins_t ppipins[] = { +static const struct ppipins ppipins[] = { { 1, PPICTRL, 0x01, 1 }, { 2, PPIDATA, 0x01, 0 }, { 3, PPIDATA, 0x02, 0 }, @@ -71,7 +71,7 @@ static const struct ppipins_t ppipins[] = { { 17, PPICTRL, 0x08, 1 } }; -#define NPINS (sizeof(ppipins)/sizeof(struct ppipins_t)) +#define NPINS (sizeof(ppipins)/sizeof(struct ppipins)) static int par_setpin_internal(const PROGRAMMER *pgm, int pin, int value) { int inverted; From d26eac2433c872dd2ce6337a72c383f957e272d4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:41:00 +0100 Subject: [PATCH 092/422] s/\bsckoptions_t\b/sckoptions/g --- src/usbasp.c | 2 +- src/usbasp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usbasp.c b/src/usbasp.c index 22a54bf2..3de8ed77 100644 --- a/src/usbasp.c +++ b/src/usbasp.c @@ -934,7 +934,7 @@ static int usbasp_spi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const } /* The list of SCK frequencies in Hz supported by USBasp */ -static const struct sckoptions_t usbaspSCKoptions[] = { +static const struct sckoptions usbaspSCKoptions[] = { { USBASP_ISP_SCK_3000, 3000000 }, { USBASP_ISP_SCK_1500, 1500000 }, { USBASP_ISP_SCK_750, 750000 }, diff --git a/src/usbasp.h b/src/usbasp.h index b91aeaaf..eacf8005 100644 --- a/src/usbasp.h +++ b/src/usbasp.h @@ -115,7 +115,7 @@ #define NVMCMD_WORD_WRITE 0x1D -typedef struct sckoptions_t { +typedef struct sckoptions { int id; double frequency; } CLOCKOPTIONS; From fc3891a1add6dfc4f7ecba04f16fcdef7738dc5d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:41:14 +0100 Subject: [PATCH 093/422] s/\bSegorder_t\b/Segorder/g --- src/fileio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 3ca4dbf3..f7fb5d45 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -153,7 +153,7 @@ FILEFMT fileio_format(char c) { typedef enum { FIRST_SEG = 1, LAST_SEG = 2, -} Segorder_t; +} Segorder; static void print_ihex_extended_addr(int n_64k, FILE *outf) { @@ -176,7 +176,7 @@ static void print_ihex_extended_addr(int n_64k, FILE *outf) { * Return the maximum memory address within mem->buf that was read from * plus one. If an error occurs, return -1. */ -static int b2ihex(const unsigned char *buf, const Segment_t *segp, Segorder_t where, +static int b2ihex(const unsigned char *buf, const Segment_t *segp, Segorder where, int recsize, int startaddr, const char *outfile_unused, FILE *outf, FILEFMT ffmt) { @@ -458,7 +458,7 @@ static unsigned int cksum_srec(const unsigned char *buf, int n, unsigned addr, i // Binary to Motorola S-Record, see https://en.wikipedia.org/wiki/SREC_(file_format) -static int b2srec(const AVRMEM *mem, const Segment_t *segp, Segorder_t where, +static int b2srec(const AVRMEM *mem, const Segment_t *segp, Segorder where, int recsize, int startaddr, const char *outfile_unused, FILE *outf) { const unsigned char *buf; @@ -1079,7 +1079,7 @@ static int fileio_imm(struct fioparms *fio, const char *fname, FILE *f_unused, static int fileio_ihex(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const Segment_t *segp, FILEFMT ffmt, Segorder_t where) { + const AVRMEM *mem, const Segment_t *segp, FILEFMT ffmt, Segorder where) { int rc; @@ -1102,7 +1102,7 @@ static int fileio_ihex(struct fioparms *fio, const char *filename, FILE *f, static int fileio_srec(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const Segment_t *segp, Segorder_t where) { + const AVRMEM *mem, const Segment_t *segp, Segorder where) { int rc; @@ -1540,7 +1540,7 @@ static int fileio_segments_normalise(int oprwv, const char *filename, FILEFMT fo if(fio.op == FIO_READ) // Fill unspecified memory in segment memset(mem->buf+addr, 0xff, len); memset(mem->tags+addr, 0, len); - Segorder_t where = 0; + Segorder where = 0; if(i == 0) where |= FIRST_SEG; From e566919e6c059832b9d13f7cec195764563d9eed Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:44:00 +0100 Subject: [PATCH 094/422] s/\btoken_t\b/token/g --- src/config.c | 55 ++++++++++++++++++++++++---------------------------- src/config.h | 32 +++++++++++++++--------------- 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/src/config.c b/src/config.c index 80760df7..d0e7779a 100644 --- a/src/config.c +++ b/src/config.c @@ -46,20 +46,20 @@ double default_bitclock; char const *default_linuxgpio; int allow_subshells; -LISTID string_list; -LISTID number_list; -PROGRAMMER * current_prog; -AVRPART * current_part; -AVRMEM * current_mem; -int current_strct; -LISTID part_list; -LISTID programmers; -bool is_alias; +LISTID string_list; +LISTID number_list; +PROGRAMMER *current_prog; +AVRPART *current_part; +AVRMEM *current_mem; +int current_strct; +LISTID part_list; +LISTID programmers; +bool is_alias; -int cfg_lineno; -char * cfg_infile; +int cfg_lineno; +char *cfg_infile; -extern char * yytext; +extern char *yytext; #define pgm_comp_desc(x, type) { #x, COMP_PROGRAMMER, offsetof(PROGRAMMER, x), sizeof(((PROGRAMMER *) NULL)->x), type } #define part_comp_desc(x, type) { #x, COMP_AVRPART, offsetof(AVRPART, x), sizeof(((AVRPART *) NULL)->x), type } @@ -228,8 +228,7 @@ int yywrap() } -int yyerror(char * errmsg, ...) -{ +int yyerror(char *errmsg, ...) { va_list args; char message[512]; @@ -245,8 +244,7 @@ int yyerror(char * errmsg, ...) } -int yywarning(char * errmsg, ...) -{ +int yywarning(char *errmsg, ...) { va_list args; char message[512]; @@ -262,15 +260,14 @@ int yywarning(char * errmsg, ...) } -TOKEN * new_token(int primary) { - TOKEN * tkn = (TOKEN *) mmt_malloc(sizeof(TOKEN)); +TOKEN *new_token(int primary) { + TOKEN *tkn = (TOKEN *) mmt_malloc(sizeof(TOKEN)); tkn->primary = primary; return tkn; } -void free_token(TOKEN * tkn) -{ +void free_token(TOKEN *tkn) { if (tkn) { switch (tkn->value.type) { case V_STR: @@ -287,7 +284,7 @@ void free_token(TOKEN * tkn) void free_tokens(int n, ...) { - TOKEN * t; + TOKEN *t; va_list ap; va_start(ap, n); @@ -302,7 +299,7 @@ void free_tokens(int n, ...) TOKEN *new_number(const char *text) { const char *errstr; - struct token_t *tkn = new_token(TKN_NUMBER); + TOKEN *tkn = new_token(TKN_NUMBER); tkn->value.type = V_NUM; tkn->value.number = str_int(text, STR_INT32, &errstr); if(errstr) { @@ -320,7 +317,7 @@ TOKEN *new_number(const char *text) { TOKEN *new_number_real(const char *text) { char *endptr; - struct token_t * tkn = new_token(TKN_NUMBER); + TOKEN *tkn = new_token(TKN_NUMBER); tkn->value.type = V_NUM_REAL; tkn->value.number_real = strtod(text, &endptr); if(endptr == text || *endptr) { @@ -337,7 +334,7 @@ TOKEN *new_number_real(const char *text) { } TOKEN *new_constant(const char *con) { - struct token_t *tkn = new_token(TKN_NUMBER); + TOKEN *tkn = new_token(TKN_NUMBER); int assigned = 1; tkn->value.type = V_NUM; @@ -380,7 +377,7 @@ TOKEN *new_constant(const char *con) { } TOKEN *new_string(const char *text) { - struct token_t *tkn = new_token(TKN_STRING); + TOKEN *tkn = new_token(TKN_STRING); tkn->value.type = V_STR; tkn->value.string = mmt_strdup(text); @@ -397,8 +394,7 @@ TOKEN *new_keyword(int primary) { } -void print_token(TOKEN * tkn) -{ +void print_token(TOKEN *tkn) { if (!tkn) return; @@ -438,9 +434,8 @@ void pyytext(void) extern int yylex_destroy(void); #endif -int read_config(const char * file) -{ - FILE * f; +int read_config(const char *file) { + FILE *f; int r; if(!(cfg_infile = realpath(file, NULL))) { diff --git a/src/config.h b/src/config.h index 292585fc..1c01b1ef 100644 --- a/src/config.h +++ b/src/config.h @@ -74,33 +74,33 @@ enum { // Value types for VALUE struct }; typedef struct value_t { - int type; + int type; union { - int number; - double number_real; - char * string; + int number; + double number_real; + char *string; Component_t *comp; }; } VALUE; -typedef struct token_t { +typedef struct token { int primary; VALUE value; } TOKEN; -typedef struct token_t *token_p; +typedef struct token *token_p; -extern FILE * yyin; -extern PROGRAMMER * current_prog; -extern AVRPART * current_part; -extern AVRMEM * current_mem; -extern int current_strct; -extern int cfg_lineno; -extern char * cfg_infile; -extern LISTID string_list; -extern LISTID number_list; -extern bool is_alias; // current entry is alias +extern FILE *yyin; +extern PROGRAMMER *current_prog; +extern AVRPART *current_part; +extern AVRMEM *current_mem; +extern int current_strct; +extern int cfg_lineno; +extern char *cfg_infile; +extern LISTID string_list; +extern LISTID number_list; +extern bool is_alias; // current entry is alias #if !defined(HAS_YYSTYPE) From 4c05994f23bf8f24caf52cbc7c9f4779a297089e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:44:25 +0100 Subject: [PATCH 095/422] s/\bUrclock_t\b/Urclock_data/g --- src/urclock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index 88065aeb..97b70068 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -324,10 +324,10 @@ typedef struct { char title[254]; // Use instead of filename for metadata - same size as filename char iddesc[64]; // Location of Urclock ID, eg F.12324.6 or E.-4.4 (default E.257.6) -} Urclock_t; +} Urclock_data; // Use private programmer data as if they were a global structure ur -#define ur (*(Urclock_t *)(pgm->cookie)) +#define ur (*(Urclock_data *)(pgm->cookie)) #define Return(...) do { pmsg_error(__VA_ARGS__); msg_error("\n"); return -1; } while (0) @@ -2552,7 +2552,7 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) { static void urclock_setup(PROGRAMMER *pgm) { // Allocate ur - pgm->cookie = mmt_malloc(sizeof(Urclock_t)); + pgm->cookie = mmt_malloc(sizeof(Urclock_data)); ur.xvectornum = -1; // Initialise, to ascertain whether user had set to 0 ur.ext_addr_byte = 0xff; // So first memory address will load extended address From 4b53ebdeb52ce86a153961e3cc23c629b600eb1a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:45:03 +0100 Subject: [PATCH 096/422] s/\bWrite_mode_t\b/Write_mode/g --- src/term.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/term.c b/src/term.c index 1e894f03..93d8a5f3 100644 --- a/src/term.c +++ b/src/term.c @@ -365,7 +365,7 @@ static size_t maxstrlen(int argc, const char **argv) { typedef enum { WRITE_MODE_STANDARD = 0, WRITE_MODE_FILL = 1, -} Write_mode_t; +} Write_mode; static int cmd_write(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { if (argc < 3 || (argc > 1 && str_eq(argv[1], "-?"))) { @@ -418,7 +418,7 @@ static int cmd_write(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch } int i; - int write_mode; // Operation mode, standard or fill + Write_mode write_mode; // Operation mode, standard or fill int start_offset; // Which argc argument int len; // Number of bytes to write to memory const char *memstr = argv[1]; // Memory name string From 81d151398c2c2aca43270f2f8bd0767e1db4711e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 01:46:24 +0100 Subject: [PATCH 097/422] Remove value_t symbol --- src/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.h b/src/config.h index 1c01b1ef..b335cb6c 100644 --- a/src/config.h +++ b/src/config.h @@ -73,7 +73,7 @@ enum { // Value types for VALUE struct V_COMPONENT, }; -typedef struct value_t { +typedef struct { int type; union { int number; From 39ec94f0eb9f300660ea2778eece7dbc4573a4fb Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 May 2024 02:29:03 +0100 Subject: [PATCH 098/422] Warn whhen programmer failes to define prog_modes --- src/config_gram.y | 3 +++ src/lexer.l | 3 ++- src/libavrdude.h | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/config_gram.y b/src/config_gram.y index 99732fa5..831e72cb 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -275,6 +275,9 @@ prog_def : yyerror("programmer type not specified"); YYABORT; } + if(!current_prog->prog_modes && cx->lex_kw_is_programmer) + yywarning("programmer %s fails to specify prog_modes = PM_...;", + (char *) ldata(lfirst(current_prog->id))); for(LNODEID ln = lfirst(current_prog->id); ln; ln = lnext(ln)) { char *id = ldata(ln); if((existing_prog = locate_programmer(programmers, id))) { diff --git a/src/lexer.l b/src/lexer.l index b11928dd..bd474b64 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -226,7 +226,8 @@ part { yylval=NULL; ccap(); current_strct = COMP_AVRPART; return K_P pgm_enable { yylval=new_token(K_PGM_ENABLE); ccap(); return K_PGM_ENABLE; } pgmled { yylval=NULL; ccap(); return K_PGMLED; } pp_controlstack { yylval=NULL; ccap(); return K_PP_CONTROLSTACK; } -(programmer|serialadapter) { yylval=NULL; ccap(); current_strct = COMP_PROGRAMMER; return K_PROGRAMMER; } +(programmer|serialadapter) { yylval=NULL; ccap(); current_strct = COMP_PROGRAMMER; + cx->lex_kw_is_programmer = *yytext == 'p'; return K_PROGRAMMER; } rdyled { yylval=NULL; ccap(); return K_RDYLED; } read { yylval=new_token(K_READ); ccap(); return K_READ; } read_hi { yylval=new_token(K_READ_HI); ccap(); return K_READ_HI; } diff --git a/src/libavrdude.h b/src/libavrdude.h index cb361b23..6ed366ba 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1581,7 +1581,7 @@ typedef struct { uint16_t dfu_wIndex; // A running number for USB messages // Static variable from config_gram.y - int cfgy_pin_name; // Temporary variable for grammar parsing + int cfgy_pin_name; // Temporary variable for grammar parsing // Static variable from ppi.c unsigned char ppi_shadow[3]; @@ -1622,6 +1622,9 @@ typedef struct { char usb_buf[USBDEV_MAX_XFER_3]; int usb_buflen, usb_bufptr; // @@@ Check whether usb_buflen needs initialising with -1 int usb_interface; + + // Variable connecting lexer.l and config_gram.y + int lex_kw_is_programmer; // Was the K_PROGRAMMER keyword "programmer"? } libavrdude_context; extern libavrdude_context *cx; From 6d136a129c8c050bbcd06797c5e0445e97602a10 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 00:44:02 +0100 Subject: [PATCH 099/422] Rename struct programmer_t to PROGRAMMER --- src/ch341a.c | 6 +- src/libavrdude.h | 152 +++++++++++++++++++++-------------------------- src/pgm.c | 2 +- src/stk500v2.c | 8 +-- src/urclock.c | 4 +- src/urclock.h | 8 +++ 6 files changed, 84 insertions(+), 96 deletions(-) diff --git a/src/ch341a.c b/src/ch341a.c index 60bf9395..12f4ff0b 100644 --- a/src/ch341a.c +++ b/src/ch341a.c @@ -333,7 +333,7 @@ static int ch341a_spi_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsig } -static int ch341a_spi_chip_erase(const struct programmer_t *pgm, const AVRPART *p) { +static int ch341a_spi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { unsigned char cmd[4]; unsigned char res[4]; @@ -477,12 +477,12 @@ void ch341a_initpgm(PROGRAMMER *pgm) { // ---------------------------------------------------------------------- #else // !defined(HAVE_LIBUSB_1_0) -static int ch341a_nousb_open(struct programmer_t *pgm, const char *name) { +static int ch341a_nousb_open(PROGRAMMER *pgm, const char *name) { pmsg_error("no usb support, please compile again with libusb installed\n"); return -1; } -void ch341a_initpgm(PROGRAMMER * pgm) { +void ch341a_initpgm(PROGRAMMER *pgm) { strcpy(pgm->type, "ch341a"); pgm->open = ch341a_nousb_open; } diff --git a/src/libavrdude.h b/src/libavrdude.h index cb361b23..0519bade 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -702,14 +702,14 @@ void pin_set_value(struct pindef_t * const pindef, const int pin, const bool inv */ void pin_clear_all(struct pindef_t * const pindef); -struct programmer_t; /* forward declaration */ +typedef struct programmer_t PROGRAMMER; // Forward declaration /** * Convert for given programmer new pin definitions to old pin definitions. * * @param[inout] pgm programmer whose pins shall be converted. */ -int pgm_fill_old_pins(struct programmer_t * const pgm); +int pgm_fill_old_pins(PROGRAMMER * const pgm); /** * This function checks all pin of pgm against the constraints given in the checklist. @@ -729,7 +729,7 @@ int pgm_fill_old_pins(struct programmer_t * const pgm); * @param[in] output false suppresses error messages to the user * @returns 0 if all pin definitions are valid, -1 otherwise */ -int pins_check(const struct programmer_t * const pgm, const struct pin_checklist_t * const checklist, const int size, const bool output); +int pins_check(const PROGRAMMER * const pgm, const struct pin_checklist_t * const checklist, const int size, const bool output); /** * Returns the name of the pin as string. @@ -937,7 +937,7 @@ typedef struct { typedef struct programmer_t { LISTID id; const char *desc; - void (*initpgm)(struct programmer_t *pgm); // Sets up the AVRDUDE programmer + void (*initpgm)(PROGRAMMER *pgm); // Sets up the AVRDUDE programmer LISTID comments; // Used by developer options -c*/[ASsr...] const char *parent_id; // Used by developer options int prog_modes; // Programming interfaces, see #define PM_... @@ -969,76 +969,63 @@ typedef struct programmer_t { double bitclock; // JTAG ICE clock period in microseconds leds_t *leds; // State of LEDs as tracked by led_...() functions in leds.c - int (*rdy_led) (const struct programmer_t *pgm, int value); - int (*err_led) (const struct programmer_t *pgm, int value); - int (*pgm_led) (const struct programmer_t *pgm, int value); - int (*vfy_led) (const struct programmer_t *pgm, int value); - int (*initialize) (const struct programmer_t *pgm, const AVRPART *p); // Sets up the physical programmer - void (*display) (const struct programmer_t *pgm, const char *p); - void (*enable) (struct programmer_t *pgm, const AVRPART *p); - void (*disable) (const struct programmer_t *pgm); - void (*powerup) (const struct programmer_t *pgm); - void (*powerdown) (const struct programmer_t *pgm); - int (*program_enable) (const struct programmer_t *pgm, const AVRPART *p); - int (*chip_erase) (const struct programmer_t *pgm, const AVRPART *p); - int (*unlock) (const struct programmer_t *pgm, const AVRPART *p); - int (*cmd) (const struct programmer_t *pgm, const unsigned char *cmd, - unsigned char *res); - int (*cmd_tpi) (const struct programmer_t *pgm, const unsigned char *cmd, - int cmd_len, unsigned char res[], int res_len); - int (*spi) (const struct programmer_t *pgm, const unsigned char *cmd, - unsigned char *res, int count); - int (*open) (struct programmer_t *pgm, const char *port); - void (*close) (struct programmer_t *pgm); - int (*paged_write) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned int page_size, unsigned int baseaddr, - unsigned int n_bytes); - int (*paged_load) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned int page_size, unsigned int baseaddr, - unsigned int n_bytes); - int (*page_erase) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned int baseaddr); - void (*write_setup) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m); - int (*write_byte) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned long addr, unsigned char value); - int (*read_byte) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned long addr, unsigned char *value); - int (*read_sig_bytes) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m); - int (*read_sib) (const struct programmer_t *pgm, const AVRPART *p, char *sib); - int (*read_chip_rev) (const struct programmer_t *pgm, const AVRPART *p, unsigned char *chip_rev); - int (*term_keep_alive)(const struct programmer_t *pgm, const AVRPART *p); - int (*end_programming)(const struct programmer_t *pgm, const AVRPART *p); + int (*rdy_led) (const PROGRAMMER *pgm, int value); + int (*err_led) (const PROGRAMMER *pgm, int value); + int (*pgm_led) (const PROGRAMMER *pgm, int value); + int (*vfy_led) (const PROGRAMMER *pgm, int value); + int (*initialize) (const PROGRAMMER *pgm, const AVRPART *p); // Sets up the physical programmer + void (*display) (const PROGRAMMER *pgm, const char *p); + void (*enable) (PROGRAMMER *pgm, const AVRPART *p); + void (*disable) (const PROGRAMMER *pgm); + void (*powerup) (const PROGRAMMER *pgm); + void (*powerdown) (const PROGRAMMER *pgm); + int (*program_enable) (const PROGRAMMER *pgm, const AVRPART *p); + int (*chip_erase) (const PROGRAMMER *pgm, const AVRPART *p); + int (*unlock) (const PROGRAMMER *pgm, const AVRPART *p); + int (*cmd) (const PROGRAMMER *pgm, const unsigned char *cmd, unsigned char *res); + int (*cmd_tpi) (const PROGRAMMER *pgm, const unsigned char *cmd, int cmd_len, unsigned char *res, int res_len); + int (*spi) (const PROGRAMMER *pgm, const unsigned char *cmd, unsigned char *res, int count); + int (*open) (PROGRAMMER *pgm, const char *port); + void (*close) (PROGRAMMER *pgm); + int (*paged_write) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int pg_size, unsigned int addr, unsigned int n); + int (*paged_load) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int pg_size, unsigned int addr, unsigned int n); + int (*page_erase) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int addr); + void (*write_setup) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m); + int (*write_byte) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, unsigned char value); + int (*read_byte) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, unsigned char *value); + int (*read_sig_bytes) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m); + int (*read_sib) (const PROGRAMMER *pgm, const AVRPART *p, char *sib); + int (*read_chip_rev) (const PROGRAMMER *pgm, const AVRPART *p, unsigned char *chip_rev); + int (*term_keep_alive)(const PROGRAMMER *pgm, const AVRPART *p); + int (*end_programming)(const PROGRAMMER *pgm, const AVRPART *p); + + void (*print_parms) (const PROGRAMMER *pgm, FILE *fp); + int (*set_vtarget) (const PROGRAMMER *pgm, double v); + int (*get_vtarget) (const PROGRAMMER *pgm, double *v); + int (*set_varef) (const PROGRAMMER *pgm, unsigned int chan, double v); + int (*get_varef) (const PROGRAMMER *pgm, unsigned int chan, double *v); + int (*set_fosc) (const PROGRAMMER *pgm, double v); + int (*get_fosc) (const PROGRAMMER *pgm, double *v); + int (*set_sck_period) (const PROGRAMMER *pgm, double v); + int (*get_sck_period) (const PROGRAMMER *pgm, double *v); + int (*setpin) (const PROGRAMMER *pgm, int pinfunc, int value); + int (*getpin) (const PROGRAMMER *pgm, int pinfunc); + int (*highpulsepin) (const PROGRAMMER *pgm, int pinfunc); + int (*parseexitspecs) (PROGRAMMER *pgm, const char *s); + int (*perform_osccal) (const PROGRAMMER *pgm); + int (*parseextparams) (const PROGRAMMER *pgm, const LISTID xparams); + void (*setup) (PROGRAMMER *pgm); + void (*teardown) (PROGRAMMER *pgm); + int (*flash_readhook) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *flm, const char *fname, int size); - void (*print_parms) (const struct programmer_t *pgm, FILE *fp); - int (*set_vtarget) (const struct programmer_t *pgm, double v); - int (*get_vtarget) (const struct programmer_t *pgm, double *v); - int (*set_varef) (const struct programmer_t *pgm, unsigned int chan, double v); - int (*get_varef) (const struct programmer_t *pgm, unsigned int chan, double *v); - int (*set_fosc) (const struct programmer_t *pgm, double v); - int (*get_fosc) (const struct programmer_t *pgm, double *v); - int (*set_sck_period) (const struct programmer_t *pgm, double v); - int (*get_sck_period) (const struct programmer_t *pgm, double *v); - int (*setpin) (const struct programmer_t *pgm, int pinfunc, int value); - int (*getpin) (const struct programmer_t *pgm, int pinfunc); - int (*highpulsepin) (const struct programmer_t *pgm, int pinfunc); - int (*parseexitspecs) (struct programmer_t *pgm, const char *s); - int (*perform_osccal) (const struct programmer_t *pgm); - int (*parseextparams) (const struct programmer_t *pgm, const LISTID xparams); - void (*setup) (struct programmer_t *pgm); - void (*teardown) (struct programmer_t *pgm); - int (*flash_readhook) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *flm, const char *fname, int size); // Cached r/w API for terminal reads/writes - int (*write_byte_cached)(const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned long addr, unsigned char value); - int (*read_byte_cached)(const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned long addr, unsigned char *value); - int (*chip_erase_cached)(const struct programmer_t *pgm, const AVRPART *p); - int (*page_erase_cached)(const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned int baseaddr); - int (*readonly) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m, - unsigned int addr); - int (*flush_cache) (const struct programmer_t *pgm, const AVRPART *p); - int (*reset_cache) (const struct programmer_t *pgm, const AVRPART *p); + int (*write_byte_cached)(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, unsigned char value); + int (*read_byte_cached)(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, unsigned char *value); + int (*chip_erase_cached)(const PROGRAMMER *pgm, const AVRPART *p); + int (*page_erase_cached)(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int addr); + int (*readonly) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int addr); + int (*flush_cache) (const PROGRAMMER *pgm, const AVRPART *p); + int (*reset_cache) (const PROGRAMMER *pgm, const AVRPART *p); AVR_Cache *cp_flash, *cp_eeprom, *cp_bootrow, *cp_usersig; const char *config_file; // Config file where defined @@ -1184,7 +1171,7 @@ int avr_is_and(const unsigned char *s1, const unsigned char *s2, const unsigned int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char *value); int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char data); int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p); -int avr_page_erase_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned int baseaddr); +int avr_page_erase_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned int addr); int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p); int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p); @@ -1326,7 +1313,7 @@ int update_dryrun(const AVRPART *p, UPDATE *upd); typedef struct programmer_type_t { const char * const id; - void (*initpgm)(struct programmer_t *pgm); + void (*initpgm)(PROGRAMMER *pgm); const char * const desc; } PROGRAMMER_TYPE; @@ -1336,7 +1323,7 @@ extern "C" { const PROGRAMMER_TYPE *locate_programmer_type(const char *id); -const char *locate_programmer_type_id(void (*initpgm)(struct programmer_t *pgm)); +const char *locate_programmer_type_id(void (*initpgm)(PROGRAMMER *pgm)); typedef void (*walk_programmer_types_cb)(const char *id, const char *desc, void *cookie); @@ -1511,16 +1498,11 @@ size_t str_weighted_damerau_levenshtein(const char *str1, const char *str2); int led_set(const PROGRAMMER *pgm, int led); int led_clr(const PROGRAMMER *pgm, int led); int led_chip_erase(const PROGRAMMER *pgm, const AVRPART *p); -int led_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, - unsigned long addr, unsigned char value); -int led_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, - unsigned long addr, unsigned char *value); -int led_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, - unsigned int page_size, unsigned int baseaddr, unsigned int n_bytes); -int led_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, - unsigned int page_size, unsigned int baseaddr, unsigned int n_bytes); -int led_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, - unsigned int baseaddr); +int led_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, unsigned char value); +int led_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, unsigned char *value); +int led_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int page_size, unsigned int addr, unsigned int n); +int led_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int page_size, unsigned int addr, unsigned int n); +int led_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned int addr); int terminal_mode(const PROGRAMMER *pgm, const AVRPART *p); int terminal_mode_noninteractive(const PROGRAMMER *pgm, const AVRPART *p); diff --git a/src/pgm.c b/src/pgm.c index 5456c3d8..79550d9a 100644 --- a/src/pgm.c +++ b/src/pgm.c @@ -407,7 +407,7 @@ void sort_programmers(LISTID programmers) } -// Soft assignment: some struct programmer_t entries can be both programmers and serial adapters +// Soft assignment: some PROGRAMMER entries can be both programmers and serial adapters int is_programmer(const PROGRAMMER *p) { return p && p->id && lsize(p->id) && p->prog_modes && p->initpgm; } diff --git a/src/stk500v2.c b/src/stk500v2.c index 9014543f..6c89f18f 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -2081,22 +2081,22 @@ static void scratchmonkey_led_state(const PROGRAMMER *pgm, int flag, int value) stk500v2_setparm_real(pgm, PARAM_SCRATCHMONKEY_STATUS_LEDS, PDATA(pgm)->scratchmonkey_leds); } -static int scratchmonkey_rdy_led(const struct programmer_t *pgm, int value) { +static int scratchmonkey_rdy_led(const PROGRAMMER *pgm, int value) { scratchmonkey_led_state(pgm, SCRATCHMONKEY_RDY_LED, value); return 0; } -static int scratchmonkey_err_led(const struct programmer_t *pgm, int value) { +static int scratchmonkey_err_led(const PROGRAMMER *pgm, int value) { scratchmonkey_led_state(pgm, SCRATCHMONKEY_ERR_LED, value); return 0; } -static int scratchmonkey_pgm_led(const struct programmer_t *pgm, int value) { +static int scratchmonkey_pgm_led(const PROGRAMMER *pgm, int value) { scratchmonkey_led_state(pgm, SCRATCHMONKEY_PGM_LED, value); return 0; } -static int scratchmonkey_vfy_led(const struct programmer_t *pgm, int value) { +static int scratchmonkey_vfy_led(const PROGRAMMER *pgm, int value) { scratchmonkey_led_state(pgm, SCRATCHMONKEY_VFY_LED, value); return 0; } diff --git a/src/urclock.c b/src/urclock.c index 97b70068..12c34086 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -2419,9 +2419,7 @@ static void urclock_display(const PROGRAMMER *pgm, const char *p_unused) { // Return whether an address is write protected -static int urclock_readonly(const struct programmer_t *pgm, const AVRPART *p_unused, - const AVRMEM *mem, unsigned int addr) { - +static int urclock_readonly(const PROGRAMMER *pgm, const AVRPART *p_unused, const AVRMEM *mem, unsigned int addr) { if(mem_is_in_flash(mem)) { if(addr > (unsigned int) ur.pfend) return 1; diff --git a/src/urclock.h b/src/urclock.h index d92b765a..4315e0d8 100644 --- a/src/urclock.h +++ b/src/urclock.h @@ -21,9 +21,17 @@ #ifndef urclock_h__ #define urclock_h__ +#ifdef __cplusplus +extern "C" { +#endif + extern const char urclock_desc[]; void urclock_initpgm (PROGRAMMER *pgm); +#ifdef __cplusplus +} +#endif + #endif From a98c6f436dc83b28e964f3d3ea3281f09c558c9d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 00:47:26 +0100 Subject: [PATCH 100/422] s/\bprogrammer_t\b/programmer/g --- src/libavrdude.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 0519bade..6556cac0 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -702,7 +702,7 @@ void pin_set_value(struct pindef_t * const pindef, const int pin, const bool inv */ void pin_clear_all(struct pindef_t * const pindef); -typedef struct programmer_t PROGRAMMER; // Forward declaration +typedef struct programmer PROGRAMMER; // Forward declaration /** * Convert for given programmer new pin definitions to old pin definitions. @@ -934,7 +934,7 @@ typedef struct { * - pgm_new() in pgm.c for initialisation; note that all const char * must * be initialised with "" */ -typedef struct programmer_t { +typedef struct programmer { LISTID id; const char *desc; void (*initpgm)(PROGRAMMER *pgm); // Sets up the AVRDUDE programmer From d0875fc267f4357a5b9578c23c2d66d3fe43aef4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 00:49:32 +0100 Subject: [PATCH 101/422] Update avrintel files --- src/avrintel.c | 998 +++++++++++++++++++------------------- src/libavrdude-avrintel.h | 599 ++++++++++++----------- 2 files changed, 802 insertions(+), 795 deletions(-) diff --git a/src/avrintel.c b/src/avrintel.c index 01d6690e..81860442 100644 --- a/src/avrintel.c +++ b/src/avrintel.c @@ -9,7 +9,7 @@ * Meta-author Stefan Rueger * * v 1.3 - * 08.05.2024 + * 20.05.2024 * */ @@ -56,7 +56,7 @@ int upidxname(const char *name) { // Given sig bytes return number of matching indices in uP_table and create a list of names in p int upmatchingsig(uint8_t sigs[3], char *p, size_t n) { int matching = 0; - uPcore_t up = {0, }; + Avrintel up = {0, }; // Scan table for the given signature for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++) { @@ -98,7 +98,7 @@ int upmatchingsig(uint8_t sigs[3], char *p, size_t n) { } -const uPcore_t uP_table[] = { // Value of -1 typically means unknown +const Avrintel uP_table[] = { // Value of -1 typically means unknown //mcu_name // Sources //{mcu_name, mcuid, family, {sig, na, ture}, // ID //mcu_name flstart, flsize, pgsiz, nb, bootsz, eestart, eesize, ep, rambeg, ramsiz, // Mem @@ -2135,7 +2135,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR16DD14*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD14*/ 401, rgftab_avr32dd14}, // Register file - //AVR16DU14 atdf // Sources + //AVR16DU14 atdf, avrdude // Sources {"AVR16DU14", 386, F_AVR8X, {0x1E, 0x94, 0x3B}, // ID /*AVR16DU14*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DU14*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2153,7 +2153,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR16DD20*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD20*/ 401, rgftab_avr32dd14}, // Register file - //AVR16DU20 atdf // Sources + //AVR16DU20 atdf, avrdude // Sources {"AVR16DU20", 387, F_AVR8X, {0x1E, 0x94, 0x3A}, // ID /*AVR16DU20*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DU20*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2171,7 +2171,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR16DD28*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD28*/ 401, rgftab_avr32dd14}, // Register file - //AVR16DU28 atdf // Sources + //AVR16DU28 atdf, avrdude // Sources {"AVR16DU28", 388, F_AVR8X, {0x1E, 0x94, 0x39}, // ID /*AVR16DU28*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2195,7 +2195,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR16DD32*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD32*/ 401, rgftab_avr32dd14}, // Register file - //AVR16DU32 atdf // Sources + //AVR16DU32 atdf, avrdude // Sources {"AVR16DU32", 389, F_AVR8X, {0x1E, 0x94, 0x38}, // ID /*AVR16DU32*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2225,7 +2225,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR32DD14*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD14*/ 401, rgftab_avr32dd14}, // Register file - //AVR32DU14 atdf // Sources + //AVR32DU14 atdf, avrdude // Sources {"AVR32DU14", 390, F_AVR8X, {0x1E, 0x95, 0x4F}, // ID /*AVR32DU14*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DU14*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2237,7 +2237,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR32DD20*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD20*/ 401, rgftab_avr32dd14}, // Register file - //AVR32DU20 atdf // Sources + //AVR32DU20 atdf, avrdude // Sources {"AVR32DU20", 391, F_AVR8X, {0x1E, 0x95, 0x4E}, // ID /*AVR32DU20*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DU20*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2261,7 +2261,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR32DD28*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD28*/ 401, rgftab_avr32dd14}, // Register file - //AVR32DU28 atdf // Sources + //AVR32DU28 atdf, avrdude // Sources {"AVR32DU28", 392, F_AVR8X, {0x1E, 0x95, 0x40}, // ID /*AVR32DU28*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2291,7 +2291,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR32DD32*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD32*/ 401, rgftab_avr32dd14}, // Register file - //AVR32DU32 atdf // Sources + //AVR32DU32 atdf, avrdude // Sources {"AVR32DU32", 393, F_AVR8X, {0x1E, 0x95, 0x3F}, // ID /*AVR32DU32*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2351,7 +2351,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR64DD28*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR64DD28*/ 401, rgftab_avr32dd14}, // Register file - //AVR64DU28 atdf // Sources + //AVR64DU28 atdf, avrdude // Sources {"AVR64DU28", 384, F_AVR8X, {0x1E, 0x96, 0x22}, // ID /*AVR64DU28*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem /*AVR64DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -2381,7 +2381,7 @@ const uPcore_t uP_table[] = { // Value of -1 typically means unknown /*AVR64DD32*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR64DD32*/ 401, rgftab_avr32dd14}, // Register file - //AVR64DU32 atdf // Sources + //AVR64DU32 atdf, avrdude // Sources {"AVR64DU32", 385, F_AVR8X, {0x1E, 0x96, 0x21}, // ID /*AVR64DU32*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem /*AVR64DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config @@ -7843,7 +7843,7 @@ const char * const vtab_avr128db64[vts_avr128db64] = { * ATmega328 ATmega48 ATmega48A ATmega48P ATmega48PA ATmega88 ATmega88A ATmega88P ATmega88PA * ATmega168 ATmega168A ATmega168P ATmega168PA ATmega328P ATA6612C ATA6613C ATA6614Q */ -static const Valueitem_t _values_sut_cksel_atmega328[55] = { +static const Configvalue _values_sut_cksel_atmega328[55] = { {0x00, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x03, "intrcosc_128khz_6ck_14ck_0ms", "int RC osc 128 kHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -7902,7 +7902,7 @@ static const Valueitem_t _values_sut_cksel_atmega328[55] = { }; // ATmega16M1 ATmega32C1 ATmega32M1 ATmega64C1 ATmega64M1 AT90PWM2B AT90PWM3B AT90PWM316 -static const Valueitem_t _values_sut_cksel_atmega16m1[53] = { +static const Configvalue _values_sut_cksel_atmega16m1[53] = { {0x00, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x01, "pllclk_pllin_extclk_6kck_14ck_0ms", "PLL clock/4; PLL input: ext clock; startup time PWRDWN/RESET: 6K CK/14 CK + 0 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -7959,7 +7959,7 @@ static const Valueitem_t _values_sut_cksel_atmega16m1[53] = { }; // ATmega328PB ATmega48PB ATmega88PB ATmega168PB ATmega324PB -static const Valueitem_t _values_sut_cksel_atmega328pb[47] = { +static const Configvalue _values_sut_cksel_atmega328pb[47] = { {0x00, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x03, "intrcosc_128khz_6ck_14ck_0ms", "int RC osc 128 kHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -8013,7 +8013,7 @@ static const Valueitem_t _values_sut_cksel_atmega328pb[47] = { * ATmega8515 ATmega103comp AT90S8535comp ATmega8 ATmega8A ATmega16 ATmega16A ATmega32 ATmega32A * ATmega64 ATmega64A ATmega128 ATmega128A ATmega8535 AT90S8515comp */ -static const Valueitem_t _values_sut_cksel_atmega8515[58] = { +static const Configvalue _values_sut_cksel_atmega8515[58] = { {0x00, "extclk_6ck_0ms", "ext clock; startup time: 6 CK + 0 ms"}, {0x01, "intrcosc_1mhz_6ck_0ms", "int RC osc 1 MHz; startup time: 6 CK + 0 ms"}, {0x02, "intrcosc_2mhz_6ck_0ms", "int RC osc 2 MHz; startup time: 6 CK + 0 ms"}, @@ -8075,7 +8075,7 @@ static const Valueitem_t _values_sut_cksel_atmega8515[58] = { }; // ATtiny441 ATtiny841 -static const Valueitem_t _values_sut_cksel_attiny441[17] = { +static const Configvalue _values_sut_cksel_attiny441[17] = { {0x00, "extclk_6ck_16ck_16ms", "ext clock; startup time PWRDWN/RESET: 6 CK/16 CK + 16 ms"}, {0x02, "intrcosc_8mhz_6ck_16ck_16ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/16 CK + 16 ms"}, {0x04, "intulposc_32khz_6ck_16ck_16ms", "int ultra-low-power osc 32 kHz; startup time PWRDWN/RESET: 6 CK/16 CK + 16 ms"}, @@ -8096,7 +8096,7 @@ static const Valueitem_t _values_sut_cksel_attiny441[17] = { }; // AT90PWM2 AT90PWM1 AT90PWM3 AT90PWM216 -static const Valueitem_t _values_sut_cksel_at90pwm2[42] = { +static const Configvalue _values_sut_cksel_at90pwm2[42] = { {0x00, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x03, "pllclk_16mhz_1kck_14ck_0ms", "PLL clock 16 MHz; startup time PWRDWN/RESET: 1024 CK/14 CK + 0 ms"}, @@ -8142,7 +8142,7 @@ static const Valueitem_t _values_sut_cksel_at90pwm2[42] = { }; // AT90PWM81 AT90PWM161 -static const Valueitem_t _values_sut_cksel_at90pwm81[56] = { +static const Configvalue _values_sut_cksel_at90pwm81[56] = { {0x00, "extclk_pllin_rc_8mhz_6ck_14ck_0ms", "ext clock; PLL input: RC 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x01, "pllclk_div4_pllin_rc_8mhz_1kck_14ck_0ms", "PLL/4; PLL input: RC 8 MHz; startup time PWRDWN/RESET: 1024 CK/14 CK + 0 ms"}, {0x02, "rc_8mhz_pllin_rc_8mhz_6ck_14ck_0ms", "RC 8 MHz; PLL input: RC 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -8205,7 +8205,7 @@ static const Valueitem_t _values_sut_cksel_at90pwm81[56] = { * AT90CAN128 AT90USB162 ATmega161comp ATmega8U2 ATmega16U2 ATmega16U4 ATmega32U2 ATmega32U4 * ATmega32U6 ATmega162 AT90USB82 AT90USB646 AT90USB647 AT90USB1286 AT90USB1287 */ -static const Valueitem_t _values_sut_cksel_at90can128[50] = { +static const Configvalue _values_sut_cksel_at90can128[50] = { {0x00, "extclk_6ck_0ms", "ext clock; startup time: 6 CK + 0 ms"}, {0x02, "intrcosc_6ck_0ms", "int RC osc; startup time: 6 CK + 0 ms"}, {0x04, "extlofxtal_1kck_0ms", "ext low-freq crystal; startup time: 1024 CK + 0 ms"}, @@ -8259,14 +8259,14 @@ static const Valueitem_t _values_sut_cksel_at90can128[50] = { }; // ATA6285 ATA6286 ATA6289 -static const Valueitem_t _values_sut_cksel_ata6285[3] = { +static const Configvalue _values_sut_cksel_ata6285[3] = { {0, "sut_6ck_14ck_0ms", "startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {1, "sut_6ck_14ck_5ms7", "startup time PWRDWN/RESET: 6 CK/14 CK + 5.7 ms"}, {2, "sut_6ck_14ck_90ms", "startup time PWRDWN/RESET: 6 CK/14 CK + 90 ms"}, }; // AT90SCR100H AT90SCR100 -static const Valueitem_t _values_sut_cksel_at90scr100h[14] = { +static const Configvalue _values_sut_cksel_at90scr100h[14] = { {0x00, "extclk_bodenx00", "ext clock; brownout detection"}, {0x01, "extclk_bodenx01", "ext clock; brownout detection"}, {0x08, "cres_fastpwrx08", "ceramic res; fast rising power"}, @@ -8284,7 +8284,7 @@ static const Valueitem_t _values_sut_cksel_at90scr100h[14] = { }; // ATtiny13 ATtiny13A -static const Valueitem_t _values_sut_cksel_attiny13[12] = { +static const Configvalue _values_sut_cksel_attiny13[12] = { {0x00, "extclk_14ck_0ms", "ext clock; startup time: 14 CK + 0 ms"}, {0x01, "intrcosc_4mhz8_14ck_0ms", "int RC osc 4.8 MHz; startup time: 14 CK + 0 ms"}, {0x02, "intrcosc_9mhz6_14ck_0ms", "int RC osc 9.6 MHz; startup time: 14 CK + 0 ms"}, @@ -8300,7 +8300,7 @@ static const Valueitem_t _values_sut_cksel_attiny13[12] = { }; // ATtiny24 ATtiny24A ATtiny44 ATtiny44A ATtiny84 ATtiny84A -static const Valueitem_t _values_sut_cksel_attiny24[44] = { +static const Configvalue _values_sut_cksel_attiny24[44] = { {0x00, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x04, "wdosc_128khz_6ck_14ck_0ms", "WD osc 128 kHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -8348,7 +8348,7 @@ static const Valueitem_t _values_sut_cksel_attiny24[44] = { }; // ATtiny25 ATtiny45 ATtiny85 -static const Valueitem_t _values_sut_cksel_attiny25[51] = { +static const Configvalue _values_sut_cksel_attiny25[51] = { {0x00, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x01, "pllclk_1kck_14ck_4ms", "PLL clock; startup time PWRDWN/RESET: 1024 CK/14 CK + 4 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -8403,7 +8403,7 @@ static const Valueitem_t _values_sut_cksel_attiny25[51] = { }; // ATtiny26 -static const Valueitem_t _values_sut_cksel_attiny26[62] = { +static const Configvalue _values_sut_cksel_attiny26[62] = { {0x01, "pllclk_1kck_0ms", "PLL clock; startup time: 1024 CK + 0 ms"}, {0x11, "pllclk_1kck_4ms", "PLL clock; startup time: 1024 CK + 4 ms"}, {0x21, "pllclk_1kck_64ms", "PLL clock; startup time: 1024 CK + 64 ms"}, @@ -8469,7 +8469,7 @@ static const Valueitem_t _values_sut_cksel_attiny26[62] = { }; // ATtiny43U ATtiny261 ATtiny261A ATtiny461 ATtiny461A ATtiny861 ATtiny861A -static const Valueitem_t _values_sut_cksel_attiny43u[48] = { +static const Configvalue _values_sut_cksel_attiny43u[48] = { {0x00, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x01, "pllclk_1kck_14ck_8ms", "PLL clock; startup time PWRDWN/RESET: 1024 CK/14 CK + 8 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -8521,7 +8521,7 @@ static const Valueitem_t _values_sut_cksel_attiny43u[48] = { }; // ATtiny48 ATtiny88 -static const Valueitem_t _values_sut_cksel_attiny48[9] = { +static const Configvalue _values_sut_cksel_attiny48[9] = { {0x0c, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x0e, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x0f, "intrcosc_128khz_6ck_14ck_0ms", "int RC osc 128 kHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -8534,7 +8534,7 @@ static const Valueitem_t _values_sut_cksel_attiny48[9] = { }; // ATtiny87 ATtiny167 ATA5272 ATA5505 ATA6616C ATA6617C ATA664251 -static const Valueitem_t _values_sut_cksel_attiny87[44] = { +static const Configvalue _values_sut_cksel_attiny87[44] = { {0x00, "extclk_6ck_14ck_0ms", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x03, "wdosc_128khz_6ck_14ck_0ms", "WD osc 128 kHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -8582,7 +8582,7 @@ static const Valueitem_t _values_sut_cksel_attiny87[44] = { }; // ATtiny828 ATtiny828R -static const Valueitem_t _values_sut_cksel_attiny828[16] = { +static const Configvalue _values_sut_cksel_attiny828[16] = { {0x00, "extclk_6ck_14ck_0msx00", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x01, "extclk_6ck_14ck_0msx01", "ext clock; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, {0x02, "intrcosc_8mhz_6ck_14ck_0ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/14 CK + 0 ms"}, @@ -8602,7 +8602,7 @@ static const Valueitem_t _values_sut_cksel_attiny828[16] = { }; // ATtiny1634 ATtiny1634R -static const Valueitem_t _values_sut_cksel_attiny1634[15] = { +static const Configvalue _values_sut_cksel_attiny1634[15] = { {0x00, "extclk_6ck_16ck_16ms", "ext clock; startup time PWRDWN/RESET: 6 CK/16 CK + 16 ms"}, {0x02, "intrcosc_8mhz_6ck_16ck_16ms", "int RC osc 8 MHz; startup time PWRDWN/RESET: 6 CK/16 CK + 16 ms"}, {0x04, "intulposc_32khz_6ck_16ck_16ms", "int ultra-low-power osc 32 kHz; startup time PWRDWN/RESET: 6 CK/16 CK + 16 ms"}, @@ -8621,7 +8621,7 @@ static const Valueitem_t _values_sut_cksel_attiny1634[15] = { }; // ATtiny2313 ATtiny2313A ATtiny4313 -static const Valueitem_t _values_sut_cksel_attiny2313[44] = { +static const Configvalue _values_sut_cksel_attiny2313[44] = { {0x00, "extclk_14ck_0ms", "ext clock; startup time: 14 CK + 0 ms"}, {0x02, "intrcosc_4mhz_14ck_0ms", "int RC osc 4 MHz; startup time: 14 CK + 0 ms"}, {0x04, "intrcosc_8mhz_14ck_0ms", "int RC osc 8 MHz; startup time: 14 CK + 0 ms"}, @@ -8669,7 +8669,7 @@ static const Valueitem_t _values_sut_cksel_attiny2313[44] = { }; // ATmega64RFR2 ATmega128RFR2 ATmega256RFR2 ATmega644RFR2 ATmega1284RFR2 ATmega2564RFR2 -static const Valueitem_t _values_sut_cksel_atmega64rfr2[49] = { +static const Configvalue _values_sut_cksel_atmega64rfr2[49] = { {0x00, "extclk_6ck_0ms", "ext clock; startup time: 6 CK + 0 ms"}, {0x02, "intrcosc_6ck_0ms", "int RC osc; startup time: 6 CK + 0 ms"}, {0x03, "intrcosc_128khz_6ck_0ms", "int 128 kHz RC osc; startup time: 6 CK + 0 ms"}, @@ -8722,7 +8722,7 @@ static const Valueitem_t _values_sut_cksel_atmega64rfr2[49] = { }; // ATmega128RFA1 -static const Valueitem_t _values_sut_cksel_atmega128rfa1[17] = { +static const Configvalue _values_sut_cksel_atmega128rfa1[17] = { {0x00, "extclk_6ck_0ms", "ext clock; startup time: 6 CK + 0 ms"}, {0x02, "intrcosc_6ck_0ms", "int RC osc; startup time: 6 CK + 0 ms"}, {0x03, "intrcosc_128khz_6ck_0ms", "int 128 kHz RC osc; startup time: 6 CK + 0 ms"}, @@ -8747,7 +8747,7 @@ static const Valueitem_t _values_sut_cksel_atmega128rfa1[17] = { * ATmega644A ATmega644P ATmega644PA ATmega1280 ATmega1281 ATmega1284 ATmega1284P ATmega2560 * ATmega2561 */ -static const Valueitem_t _values_sut_cksel_atmega164a[55] = { +static const Configvalue _values_sut_cksel_atmega164a[55] = { {0x00, "extclk_6ck_0ms", "ext clock; startup time: 6 CK + 0 ms"}, {0x02, "intrcosc_6ck_0ms", "int RC osc; startup time: 6 CK + 0 ms"}, {0x03, "intrcosc_128khz_6ck_0ms", "int 128 kHz RC osc; startup time: 6 CK + 0 ms"}, @@ -8812,7 +8812,7 @@ static const Valueitem_t _values_sut_cksel_atmega164a[55] = { * ATmega3250P ATmega3250PA ATmega3290 ATmega3290A ATmega3290P ATmega3290PA ATmega6450 ATmega6450A * ATmega6450P ATmega6490 ATmega6490A ATmega6490P */ -static const Valueitem_t _values_sut_cksel_atmega165[44] = { +static const Configvalue _values_sut_cksel_atmega165[44] = { {0x00, "extclk_6ck_0ms", "ext clock; startup time: 6 CK + 0 ms"}, {0x02, "intrcosc_6ck_0ms", "int RC osc; startup time: 6 CK + 0 ms"}, {0x06, "extlofxtal_1kck_0ms", "ext low-freq crystal; startup time: 1024 CK + 0 ms"}, @@ -8860,7 +8860,7 @@ static const Valueitem_t _values_sut_cksel_atmega165[44] = { }; // ATmega406 -static const Valueitem_t _values_sut_cksel_atmega406[6] = { +static const Configvalue _values_sut_cksel_atmega406[6] = { {0, "sut_14ck_0msx00", "startup time: 14 CK + 0 ms"}, {1, "sut_14ck_0msx01", "startup time: 14 CK + 0 ms"}, {2, "sut_14ck_3ms9x02", "startup time: 14 CK + 3.9 ms"}, @@ -8870,7 +8870,7 @@ static const Valueitem_t _values_sut_cksel_atmega406[6] = { }; // AT90CAN32 AT90CAN64 -static const Valueitem_t _values_sut_cksel_at90can32[38] = { +static const Configvalue _values_sut_cksel_at90can32[38] = { {0x00, "extclk_6ck_0ms", "ext clock; startup time: 6 CK + 0 ms"}, {0x02, "intrcosc_6ck_0ms", "int RC osc; startup time: 6 CK + 0 ms"}, {0x04, "extlofxtal_1kck_0ms", "ext low-freq crystal; startup time: 1024 CK + 0 ms"}, @@ -8912,7 +8912,7 @@ static const Valueitem_t _values_sut_cksel_at90can32[38] = { }; // AT90S2333 AT90S4433 -static const Valueitem_t _values_sut_cksel_at90s2333[8] = { +static const Configvalue _values_sut_cksel_at90s2333[8] = { {0, "extclk_slowpwr", "ext clock; slowly rising power"}, {1, "extclk_boden_por", "ext clock; brownout detection or power-on reset"}, {2, "xosc", "crystal osc"}, @@ -8929,25 +8929,25 @@ static const Valueitem_t _values_sut_cksel_at90s2333[8] = { * ATmega162 ATmega168 ATmega168A ATmega168P ATmega168PA ATmega168PB ATmega328P AT90PWM1 AT90PWM2B * AT90PWM3 AT90PWM3B AT90PWM216 AT90PWM316 ATA6612C ATA6613C ATA6614Q */ -static const Valueitem_t _values_ckout_atmega328[2] = { +static const Configvalue _values_ckout_atmega328[2] = { {0, "gpio_pb0", "clock output on GPIO PB0"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; // ATmega16M1 AT90PWM81 ATmega32C1 ATmega32M1 ATmega64C1 ATmega64M1 AT90PWM161 -static const Valueitem_t _values_ckout_atmega16m1[2] = { +static const Configvalue _values_ckout_atmega16m1[2] = { {0, "gpio_pd1", "clock output on GPIO PD1"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; // ATtiny102 ATtiny4 ATtiny5 ATtiny9 ATtiny10 ATtiny20 ATtiny40 ATtiny104 -static const Valueitem_t _values_ckout_attiny102[2] = { +static const Configvalue _values_ckout_attiny102[2] = { {0, "gpio", "clock output on GPIO"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; // ATtiny441 ATtiny841 ATtiny1634 ATtiny1634R -static const Valueitem_t _values_ckout_attiny441[2] = { +static const Configvalue _values_ckout_attiny441[2] = { {0, "gpio_pc2", "clock output on GPIO PC2"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; @@ -8956,13 +8956,13 @@ static const Valueitem_t _values_ckout_attiny441[2] = { * AT90CAN128 AT90USB162 ATmega8U2 ATmega16U2 ATmega16U4 ATmega32U2 ATmega32U4 ATmega32U6 AT90CAN32 * AT90CAN64 AT90USB82 AT90USB646 AT90USB647 AT90USB1286 AT90USB1287 */ -static const Valueitem_t _values_ckout_at90can128[2] = { +static const Configvalue _values_ckout_at90can128[2] = { {0, "gpio_pc7", "clock output on GPIO PC7"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; // ATA6285 ATA6286 ATA6289 -static const Valueitem_t _values_ckout_ata6285[2] = { +static const Configvalue _values_ckout_ata6285[2] = { {0, "gpio_pc1", "clock output on GPIO PC1"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; @@ -8971,19 +8971,19 @@ static const Valueitem_t _values_ckout_ata6285[2] = { * AT90SCR100H ATmega164A ATmega164P ATmega164PA ATmega324A ATmega324P ATmega324PA ATmega324PB * ATmega644 ATmega644A ATmega644P ATmega644PA ATmega1284 ATmega1284P AT90SCR100 */ -static const Valueitem_t _values_ckout_at90scr100h[2] = { +static const Configvalue _values_ckout_at90scr100h[2] = { {0, "gpio_pb1", "clock output on GPIO PB1"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; // ATtiny24 ATtiny24A ATtiny44 ATtiny44A ATtiny84 ATtiny84A -static const Valueitem_t _values_ckout_attiny24[2] = { +static const Configvalue _values_ckout_attiny24[2] = { {0, "gpio_pb2", "clock output on GPIO PB2"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; // ATtiny25 ATtiny45 ATtiny85 -static const Valueitem_t _values_ckout_attiny25[2] = { +static const Configvalue _values_ckout_attiny25[2] = { {0, "gpio_pb4", "clock output on GPIO PB4"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; @@ -8992,13 +8992,13 @@ static const Valueitem_t _values_ckout_attiny25[2] = { * ATtiny43U ATtiny87 ATtiny167 ATtiny261 ATtiny261A ATtiny461 ATtiny461A ATtiny861 ATtiny861A * ATA5272 ATA5505 ATA6616C ATA6617C ATA664251 */ -static const Valueitem_t _values_ckout_attiny43u[2] = { +static const Configvalue _values_ckout_attiny43u[2] = { {0, "gpio_pb5", "clock output on GPIO PB5"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; // ATtiny2313 ATtiny2313A ATtiny4313 -static const Valueitem_t _values_ckout_attiny2313[2] = { +static const Configvalue _values_ckout_attiny2313[2] = { {0, "gpio_pd2", "clock output on GPIO PD2"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; @@ -9012,7 +9012,7 @@ static const Valueitem_t _values_ckout_attiny2313[2] = { * ATmega3290A ATmega3290P ATmega3290PA ATmega6450 ATmega6450A ATmega6450P ATmega6490 ATmega6490A * ATmega6490P */ -static const Valueitem_t _values_ckout_atmega64rfr2[2] = { +static const Configvalue _values_ckout_atmega64rfr2[2] = { {0, "gpio_pe7", "clock output on GPIO PE7"}, {1, "co_disabled", "clock signal is not output on a pin"}, }; @@ -9040,7 +9040,7 @@ static const Valueitem_t _values_ckout_atmega64rfr2[2] = { * ATA6612C ATA6613C ATA6614Q ATA6616C ATA6617C ATA8210 ATA8215 ATA8510 ATA8515 ATA664251 * ATmega32HVE2 */ -static const Valueitem_t _values_ckdiv8_atmega328[2] = { +static const Configvalue _values_ckdiv8_atmega328[2] = { {0, "by_8", "F_CPU prescaled by 8"}, {1, "by_1", "F_CPU prescaled by 1"}, }; @@ -9073,7 +9073,7 @@ static const Valueitem_t _values_ckdiv8_atmega328[2] = { * ATxmega256A3B ATxmega256A3BU ATxmega256A3U ATxmega256C3 ATxmega256D3 ATxmega384C3 ATxmega384D3 * ATmega32HVE2 */ -static const Valueitem_t _values_bootrst_atmega328[2] = { +static const Configvalue _values_bootrst_atmega328[2] = { {0, "boot_section", "reset jumps to start of boot section"}, {1, "application", "reset jumps to start of memory"}, }; @@ -9085,7 +9085,7 @@ static const Valueitem_t _values_bootrst_atmega328[2] = { * ATmega329PA ATmega3250 ATmega3250A ATmega3250P ATmega3250PA ATmega3290 ATmega3290A ATmega3290P * ATmega3290PA ATA6614Q */ -static const Valueitem_t _values_bootsz_atmega328[4] = { +static const Configvalue _values_bootsz_atmega328[4] = { {0, "bs_2048w", "boot size 4096 bytes; boot address 0x7000"}, {1, "bs_1024w", "boot size 2048 bytes; boot address 0x7800"}, {2, "bs_512w", "boot size 1024 bytes; boot address 0x7c00"}, @@ -9096,7 +9096,7 @@ static const Valueitem_t _values_bootsz_atmega328[4] = { * ATmega16M1 AT90USB162 ATmega16HVB ATmega16HVBrevB ATmega16U2 ATmega16U4 AT90USB82 AT90PWM216 * AT90PWM316 */ -static const Valueitem_t _values_bootsz_atmega16m1[4] = { +static const Configvalue _values_bootsz_atmega16m1[4] = { {0, "bs_2048w", "boot size 4096 bytes; boot address 0x3000"}, {1, "bs_1024w", "boot size 2048 bytes; boot address 0x3800"}, {2, "bs_512w", "boot size 1024 bytes; boot address 0x3c00"}, @@ -9109,7 +9109,7 @@ static const Valueitem_t _values_bootsz_atmega16m1[4] = { * ATmega645P ATmega649 ATmega649A ATmega649P ATmega6450 ATmega6450A ATmega6450P ATmega6490 * ATmega6490A ATmega6490P AT90CAN64 AT90SCR100 ATmega32HVE2 */ -static const Valueitem_t _values_bootsz_atmega64hve[4] = { +static const Configvalue _values_bootsz_atmega64hve[4] = { {0, "bs_4096w", "boot size 8192 bytes; boot address 0xe000"}, {1, "bs_2048w", "boot size 4096 bytes; boot address 0xf000"}, {2, "bs_1024w", "boot size 2048 bytes; boot address 0xf800"}, @@ -9121,7 +9121,7 @@ static const Valueitem_t _values_bootsz_atmega64hve[4] = { * ATmega88A ATmega88P ATmega88PA ATmega88PB ATmega8535 AT90PWM1 AT90PWM2B AT90PWM3 AT90PWM3B * AT90PWM161 AT90S8515comp ATA6612C */ -static const Valueitem_t _values_bootsz_atmega8515[4] = { +static const Configvalue _values_bootsz_atmega8515[4] = { {0, "bs_1024w", "boot size 2048 bytes; boot address 0x1800"}, {1, "bs_512w", "boot size 1024 bytes; boot address 0x1c00"}, {2, "bs_256w", "boot size 512 bytes; boot address 0x1e00"}, @@ -9132,7 +9132,7 @@ static const Valueitem_t _values_bootsz_atmega8515[4] = { * AT90CAN128 ATmega103comp ATmega128 ATmega128A ATmega128RFA1 ATmega128RFR2 ATmega1280 ATmega1281 * ATmega1284 ATmega1284P ATmega1284RFR2 AT90USB1286 AT90USB1287 */ -static const Valueitem_t _values_bootsz_at90can128[4] = { +static const Configvalue _values_bootsz_at90can128[4] = { {0, "bs_4096w", "boot size 8192 bytes; boot address 0x1e000"}, {1, "bs_2048w", "boot size 4096 bytes; boot address 0x1f000"}, {2, "bs_1024w", "boot size 2048 bytes; boot address 0x1f800"}, @@ -9140,7 +9140,7 @@ static const Valueitem_t _values_bootsz_at90can128[4] = { }; // ATA6285 ATA6286 ATA6289 -static const Valueitem_t _values_bootsz_ata6285[4] = { +static const Configvalue _values_bootsz_ata6285[4] = { {0, "bs_1024w", "boot size 2048 bytes"}, {1, "bs_512w", "boot size 1024 bytes"}, {2, "bs_256w", "boot size 512 bytes"}, @@ -9152,7 +9152,7 @@ static const Valueitem_t _values_bootsz_ata6285[4] = { * ATmega165A ATmega165P ATmega165PA ATmega168 ATmega168A ATmega168P ATmega168PA ATmega168PB * ATmega169 ATmega169A ATmega169P ATmega169PA ATA6613C */ -static const Valueitem_t _values_bootsz_atmega161comp[4] = { +static const Configvalue _values_bootsz_atmega161comp[4] = { {0, "bs_1024w", "boot size 2048 bytes; boot address 0x3800"}, {1, "bs_512w", "boot size 1024 bytes; boot address 0x3c00"}, {2, "bs_256w", "boot size 512 bytes; boot address 0x3e00"}, @@ -9160,7 +9160,7 @@ static const Valueitem_t _values_bootsz_atmega161comp[4] = { }; // ATmega8U2 -static const Valueitem_t _values_bootsz_atmega8u2[4] = { +static const Configvalue _values_bootsz_atmega8u2[4] = { {0, "bs_2048w", "boot size 4096 bytes; boot address 0x1000"}, {1, "bs_1024w", "boot size 2048 bytes; boot address 0x1800"}, {2, "bs_512w", "boot size 1024 bytes; boot address 0x1c00"}, @@ -9168,7 +9168,7 @@ static const Valueitem_t _values_bootsz_atmega8u2[4] = { }; // ATmega256RFR2 ATmega2560 ATmega2561 ATmega2564RFR2 -static const Valueitem_t _values_bootsz_atmega256rfr2[4] = { +static const Configvalue _values_bootsz_atmega256rfr2[4] = { {0, "bs_4096w", "boot size 8192 bytes; boot address 0x3e000"}, {1, "bs_2048w", "boot size 4096 bytes; boot address 0x3f000"}, {2, "bs_1024w", "boot size 2048 bytes; boot address 0x3f800"}, @@ -9176,7 +9176,7 @@ static const Valueitem_t _values_bootsz_atmega256rfr2[4] = { }; // ATmega406 -static const Valueitem_t _values_bootsz_atmega406[4] = { +static const Configvalue _values_bootsz_atmega406[4] = { {0, "bs_2048w", "boot size 4096 bytes; boot address 0x9000"}, {1, "bs_1024w", "boot size 2048 bytes; boot address 0x9800"}, {2, "bs_512w", "boot size 1024 bytes; boot address 0x9c00"}, @@ -9184,7 +9184,7 @@ static const Valueitem_t _values_bootsz_atmega406[4] = { }; // AT90CAN32 -static const Valueitem_t _values_bootsz_at90can32[4] = { +static const Configvalue _values_bootsz_at90can32[4] = { {0, "bs_4096w", "boot size 8192 bytes; boot address 0x6000"}, {1, "bs_2048w", "boot size 4096 bytes; boot address 0x7000"}, {2, "bs_1024w", "boot size 2048 bytes; boot address 0x7800"}, @@ -9192,7 +9192,7 @@ static const Valueitem_t _values_bootsz_at90can32[4] = { }; // AT90USB646 AT90USB647 -static const Valueitem_t _values_bootsz_at90usb646[4] = { +static const Configvalue _values_bootsz_at90usb646[4] = { {0, "bs_4096w", "boot size 8192 bytes; boot address 0xf000"}, {1, "bs_2408w", "boot size 2408 words; boot address 0xf800"}, {2, "bs_1024w", "boot size 2048 bytes; boot address 0xfc00"}, @@ -9232,7 +9232,7 @@ static const Valueitem_t _values_bootsz_at90usb646[4] = { * ATxmega256A3B ATxmega256A3BU ATxmega256A3U ATxmega256C3 ATxmega256D3 ATxmega384C3 ATxmega384D3 * ATmega32HVE2 */ -static const Valueitem_t _values_eesave_atmega328[2] = { +static const Configvalue _values_eesave_atmega328[2] = { {0, "ee_preserved", "EEPROM content is preserved during chip erase"}, {1, "ee_erased", "EEPROM content is erased during chip erase"}, }; @@ -9251,7 +9251,7 @@ static const Valueitem_t _values_eesave_atmega328[2] = { * AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 * AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_eesave_attiny204[2] = { +static const Configvalue _values_eesave_attiny204[2] = { {0, "eex_erased", "EEPROM content is erased during chip erase"}, {1, "eex_preserved", "EEPROM content is preserved during chip erase"}, }; @@ -9282,7 +9282,7 @@ static const Valueitem_t _values_eesave_attiny204[2] = { * ATA5833 ATA5835 ATA6286 ATA6289 ATA6612C ATA6613C ATA6614Q ATA6616C ATA6617C ATA8210 ATA8215 * ATA8510 ATA8515 ATA664251 ATmega32HVE2 */ -static const Valueitem_t _values_wdton_atmega328[2] = { +static const Configvalue _values_wdton_atmega328[2] = { {0, "wdt_always_on", "watchdog timer always on"}, {1, "wdt_programmable", "watchdog timer programmable"}, }; @@ -9315,7 +9315,7 @@ static const Valueitem_t _values_wdton_atmega328[2] = { * ATA6289 ATA6612C ATA6613C ATA6614Q ATA6616C ATA6617C ATA8210 ATA8215 ATA8510 ATA8515 ATA664251 * ATmega32HVE2 */ -static const Valueitem_t _values_spien_atmega328[2] = { +static const Configvalue _values_spien_atmega328[2] = { {0, "isp_enabled", "serial programming enabled"}, {1, "isp_disabled", "serial programming disabled"}, }; @@ -9334,7 +9334,7 @@ static const Valueitem_t _values_spien_atmega328[2] = { * ATA5795 ATA5831 ATA5832 ATA5833 ATA5835 ATA6286 ATA6289 ATA6612C ATA6613C ATA6614Q ATA6616C * ATA6617C ATA8210 ATA8215 ATA8510 ATA8515 ATA664251 ATmega32HVE2 */ -static const Valueitem_t _values_dwen_atmega328[2] = { +static const Configvalue _values_dwen_atmega328[2] = { {0, "dw_enabled", "debugWIRE enabled"}, {1, "dw_off", "debugWIRE off"}, }; @@ -9346,7 +9346,7 @@ static const Valueitem_t _values_dwen_atmega328[2] = { * ATmega88PB ATmega168 ATmega168A ATmega168P ATmega168PA ATmega168PB ATmega328P AT90PWM1 * AT90PWM2B AT90PWM3 AT90PWM3B AT90USB82 AT90PWM216 AT90PWM316 ATA6612C ATA6613C ATA6614Q */ -static const Valueitem_t _values_rstdisbl_atmega328[2] = { +static const Configvalue _values_rstdisbl_atmega328[2] = { {0, "gpio_pc6_warning_external_reset_disabled", "reset pin configured as GPIO PC6 (warning: external reset disabled)"}, {1, "external_reset", "reset pin configured as external reset"}, }; @@ -9367,31 +9367,31 @@ static const Valueitem_t _values_rstdisbl_atmega328[2] = { * ATxmega256A3 ATxmega256A3B ATxmega256A3BU ATxmega256A3U ATxmega256C3 ATxmega256D3 ATxmega384C3 * ATxmega384D3 */ -static const Valueitem_t _values_rstdisbl_attiny102[2] = { +static const Configvalue _values_rstdisbl_attiny102[2] = { {0, "gpio_warning_external_reset_disabled", "reset pin configured as GPIO (warning: external reset disabled)"}, {1, "external_reset", "reset pin configured as external reset"}, }; // ATtiny441 ATtiny841 ATtiny1634 ATtiny1634R -static const Valueitem_t _values_rstdisbl_attiny441[2] = { +static const Configvalue _values_rstdisbl_attiny441[2] = { {0, "gpio_pc2_warning_external_reset_disabled", "reset pin configured as GPIO PC2 (warning: external reset disabled)"}, {1, "external_reset", "reset pin configured as external reset"}, }; // AT90PWM81 AT90PWM161 -static const Valueitem_t _values_rstdisbl_at90pwm81[2] = { +static const Configvalue _values_rstdisbl_at90pwm81[2] = { {0, "gpio_pe0_warning_external_reset_disabled", "reset pin configured as GPIO PE0 (warning: external reset disabled)"}, {1, "external_reset", "reset pin configured as external reset"}, }; // ATtiny11 ATtiny12 ATtiny13 ATtiny13A ATtiny15 ATtiny25 ATtiny45 ATtiny85 -static const Valueitem_t _values_rstdisbl_attiny11[2] = { +static const Configvalue _values_rstdisbl_attiny11[2] = { {0, "gpio_pb5_warning_external_reset_disabled", "reset pin configured as GPIO PB5 (warning: external reset disabled)"}, {1, "external_reset", "reset pin configured as external reset"}, }; // ATtiny24 ATtiny24A ATtiny44 ATtiny44A ATtiny84 ATtiny84A -static const Valueitem_t _values_rstdisbl_attiny24[2] = { +static const Configvalue _values_rstdisbl_attiny24[2] = { {0, "gpio_pb3_warning_external_reset_disabled", "reset pin configured as GPIO PB3 (warning: external reset disabled)"}, {1, "external_reset", "reset pin configured as external reset"}, }; @@ -9400,7 +9400,7 @@ static const Valueitem_t _values_rstdisbl_attiny24[2] = { * ATtiny26 ATtiny43U ATtiny87 ATtiny167 ATtiny261 ATtiny261A ATtiny461 ATtiny461A ATtiny861 * ATtiny861A ATA5272 ATA5505 ATA6616C ATA6617C ATA664251 */ -static const Valueitem_t _values_rstdisbl_attiny26[2] = { +static const Configvalue _values_rstdisbl_attiny26[2] = { {0, "gpio_pb7_warning_external_reset_disabled", "reset pin configured as GPIO PB7 (warning: external reset disabled)"}, {1, "external_reset", "reset pin configured as external reset"}, }; @@ -9415,7 +9415,7 @@ static const Valueitem_t _values_rstdisbl_attiny26[2] = { * ATmega644 ATmega644A ATmega644P ATmega644PA ATmega1280 ATmega1281 ATmega1284 ATmega1284P * ATmega2560 ATmega2561 ATA6612C ATA6613C ATA6614Q */ -static const Valueitem_t _values_bodlevel_atmega328[4] = { +static const Configvalue _values_bodlevel_atmega328[4] = { {4, "bod_4v3", "brownout detection at 4.3 V"}, {5, "bod_2v7", "brownout detection at 2.7 V"}, {6, "bod_1v8", "brownout detection at 1.8 V"}, @@ -9426,7 +9426,7 @@ static const Valueitem_t _values_bodlevel_atmega328[4] = { * ATmega16M1 AT90PWM2 ATmega32C1 ATmega32M1 ATmega64C1 ATmega64M1 AT90PWM1 AT90PWM2B AT90PWM3 * AT90PWM3B AT90PWM216 AT90PWM316 */ -static const Valueitem_t _values_bodlevel_atmega16m1[8] = { +static const Configvalue _values_bodlevel_atmega16m1[8] = { {0, "bod_2v6", "brownout detection at 2.6 V"}, {1, "bod_2v8", "brownout detection at 2.8 V"}, {2, "bod_4v2", "brownout detection at 4.2 V"}, @@ -9442,13 +9442,13 @@ static const Valueitem_t _values_bodlevel_atmega16m1[8] = { * ATmega32 ATmega32A ATmega64 ATmega64A ATmega128 ATmega128A ATmega163 ATmega323 ATmega8535 * AT90S2333 AT90S4433 AT90S8515comp */ -static const Valueitem_t _values_bodlevel_atmega8515[2] = { +static const Configvalue _values_bodlevel_atmega8515[2] = { {0, "bod_4v0", "brownout detection at 4.0 V"}, {1, "bod_2v7", "brownout detection at 2.7 V"}, }; // ATtiny441 ATtiny841 ATtiny1634 ATtiny1634R -static const Valueitem_t _values_bodlevel_attiny441[4] = { +static const Configvalue _values_bodlevel_attiny441[4] = { {4, "bod_4v3", "brownout detection at 4.3 V"}, {5, "bod_2v7", "brownout detection at 2.7 V"}, {6, "bod_1v8", "brownout detection at 1.8 V"}, @@ -9459,7 +9459,7 @@ static const Valueitem_t _values_bodlevel_attiny441[4] = { * AT90PWM81 ATtiny43U ATtiny87 ATtiny167 ATtiny261 ATtiny261A ATtiny461 ATtiny461A ATtiny861 * ATtiny861A AT90PWM161 ATA5272 ATA5505 ATA6616C ATA6617C ATA664251 */ -static const Valueitem_t _values_bodlevel_at90pwm81[8] = { +static const Configvalue _values_bodlevel_at90pwm81[8] = { {0, "bod_2v0", "brownout detection at 2.0 V"}, {1, "bod_1v9", "brownout detection at 1.9 V"}, {2, "bod_2v2", "brownout detection at 2.2 V"}, @@ -9471,7 +9471,7 @@ static const Valueitem_t _values_bodlevel_at90pwm81[8] = { }; // AT90CAN128 AT90CAN32 AT90CAN64 -static const Valueitem_t _values_bodlevel_at90can128[8] = { +static const Configvalue _values_bodlevel_at90can128[8] = { {0, "bod_2v5", "brownout detection at 2.5 V"}, {1, "bod_2v6", "brownout detection at 2.6 V"}, {2, "bod_2v7", "brownout detection at 2.7 V"}, @@ -9483,7 +9483,7 @@ static const Valueitem_t _values_bodlevel_at90can128[8] = { }; // AT90USB162 ATmega8U2 ATmega16U2 ATmega32U2 AT90USB82 -static const Valueitem_t _values_bodlevel_at90usb162[8] = { +static const Configvalue _values_bodlevel_at90usb162[8] = { {0, "bod_4v3", "brownout detection at 4.3 V"}, {1, "bod_4v0", "brownout detection at 4.0 V"}, {2, "bod_3v6", "brownout detection at 3.6 V"}, @@ -9502,7 +9502,7 @@ static const Valueitem_t _values_bodlevel_at90usb162[8] = { * ATxmega192C3 ATxmega192D3 ATxmega256A3BU ATxmega256A3U ATxmega256C3 ATxmega256D3 ATxmega384C3 * ATxmega384D3 */ -static const Valueitem_t _values_bodlevel_atxmega16e5[8] = { +static const Configvalue _values_bodlevel_atxmega16e5[8] = { {0, "bod_3v0", "brownout detection at 3.0 V"}, {1, "bod_2v8", "brownout detection at 2.8 V"}, {2, "bod_2v6", "brownout detection at 2.6 V"}, @@ -9517,7 +9517,7 @@ static const Valueitem_t _values_bodlevel_atxmega16e5[8] = { * ATxmega128A3 ATxmega64A1 ATxmega64A3 ATxmega128A1 ATxmega128A1revD ATxmega192A3 ATxmega256A3 * ATxmega256A3B */ -static const Valueitem_t _values_bodlevel_atxmega128a3[8] = { +static const Configvalue _values_bodlevel_atxmega128a3[8] = { {0, "bod_3v4", "brownout detection at 3.4 V"}, {1, "bod_3v2", "brownout detection at 3.2 V"}, {2, "bod_2v9", "brownout detection at 2.9 V"}, @@ -9536,7 +9536,7 @@ static const Valueitem_t _values_bodlevel_atxmega128a3[8] = { * ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 ATmega3209 * ATmega4808 ATmega4809 */ -static const Valueitem_t _values_bodlevel_attiny204[3] = { +static const Configvalue _values_bodlevel_attiny204[3] = { {0, "bod_1v8", "brownout detection at 1.8 V"}, {2, "bod_2v6", "brownout detection at 2.6 V"}, {7, "bod_4v2", "brownout detection at 4.2 V"}, @@ -9549,7 +9549,7 @@ static const Valueitem_t _values_bodlevel_attiny204[3] = { * AVR64DU28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 * AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_bodlevel_avr32dd14[4] = { +static const Configvalue _values_bodlevel_avr32dd14[4] = { {0, "bod_1v9", "brownout detection at 1.9 V"}, {1, "bod_2v45", "brownout detection at 2.45 V"}, {2, "bod_2v7", "brownout detection at 2.7 V"}, @@ -9560,7 +9560,7 @@ static const Valueitem_t _values_bodlevel_avr32dd14[4] = { * AVR64EA48 AVR16EB14 AVR16EB20 AVR16EA28 AVR16EB28 AVR16EA32 AVR16EB32 AVR16EA48 AVR32EA28 * AVR32EA32 AVR32EA48 AVR64EA28 AVR64EA32 */ -static const Valueitem_t _values_bodlevel_avr64ea48[4] = { +static const Configvalue _values_bodlevel_avr64ea48[4] = { {0, "bod_disabled", "brownout detection disabled"}, {1, "bod_1v9", "brownout detection at 1.9 V"}, {2, "bod_2v7", "brownout detection at 2.7 V"}, @@ -9568,7 +9568,7 @@ static const Valueitem_t _values_bodlevel_avr64ea48[4] = { }; // ATmega161comp ATmega162 -static const Valueitem_t _values_bodlevel_atmega161comp[5] = { +static const Configvalue _values_bodlevel_atmega161comp[5] = { {3, "bod_2v3", "brownout detection at 2.3 V"}, {4, "bod_4v3", "brownout detection at 4.3 V"}, {5, "bod_2v7", "brownout detection at 2.7 V"}, @@ -9577,7 +9577,7 @@ static const Valueitem_t _values_bodlevel_atmega161comp[5] = { }; // ATtiny12 -static const Valueitem_t _values_bodlevel_attiny12[2] = { +static const Configvalue _values_bodlevel_attiny12[2] = { {0, "bod_2v7", "brownout detection at 2.7 V"}, {1, "bod_1v8", "brownout detection at 1.8 V"}, }; @@ -9588,7 +9588,7 @@ static const Valueitem_t _values_bodlevel_attiny12[2] = { * ATmega3250A ATmega3250P ATmega3250PA ATmega3290 ATmega3290A ATmega3290P ATmega3290PA ATmega6450 * ATmega6450A ATmega6450P ATmega6490 ATmega6490A ATmega6490P */ -static const Valueitem_t _values_bodlevel_attiny13[4] = { +static const Configvalue _values_bodlevel_attiny13[4] = { {0, "bod_4v3", "brownout detection at 4.3 V"}, {1, "bod_2v7", "brownout detection at 2.7 V"}, {2, "bod_1v8", "brownout detection at 1.8 V"}, @@ -9596,7 +9596,7 @@ static const Valueitem_t _values_bodlevel_attiny13[4] = { }; // ATmega16U4 ATmega32U4 ATmega32U6 AT90USB646 AT90USB647 AT90USB1286 AT90USB1287 -static const Valueitem_t _values_bodlevel_atmega16u4[8] = { +static const Configvalue _values_bodlevel_atmega16u4[8] = { {0, "bod_4v3", "brownout detection at 4.3 V"}, {1, "bod_3v5", "brownout detection at 3.5 V"}, {2, "bod_3v4", "brownout detection at 3.4 V"}, @@ -9611,7 +9611,7 @@ static const Valueitem_t _values_bodlevel_atmega16u4[8] = { * ATmega64RFR2 ATmega128RFA1 ATmega128RFR2 ATmega256RFR2 ATmega644RFR2 ATmega1284RFR2 * ATmega2564RFR2 */ -static const Valueitem_t _values_bodlevel_atmega64rfr2[8] = { +static const Configvalue _values_bodlevel_atmega64rfr2[8] = { {0, "bod_2v4", "brownout detection at 2.4 V"}, {1, "bod_2v3", "brownout detection at 2.3 V"}, {2, "bod_2v2", "brownout detection at 2.2 V"}, @@ -9623,7 +9623,7 @@ static const Valueitem_t _values_bodlevel_atmega64rfr2[8] = { }; // ATxmega16A4 ATxmega32A4 -static const Valueitem_t _values_bodlevel_atxmega16a4[8] = { +static const Configvalue _values_bodlevel_atxmega16a4[8] = { {0, "bod_3v5", "brownout detection at 3.5 V"}, {1, "bod_3v2", "brownout detection at 3.2 V"}, {2, "bod_3v0", "brownout detection at 3.0 V"}, @@ -9635,7 +9635,7 @@ static const Valueitem_t _values_bodlevel_atxmega16a4[8] = { }; // ATtiny416auto -static const Valueitem_t _values_bodlevel_attiny416auto[2] = { +static const Configvalue _values_bodlevel_attiny416auto[2] = { {2, "bod_2v6", "brownout detection at 2.6 V"}, {7, "bod_4v2", "brownout detection at 4.2 V"}, }; @@ -9669,7 +9669,7 @@ static const Valueitem_t _values_bodlevel_attiny416auto[2] = { * ATA6286 ATA6289 ATA6612C ATA6613C ATA6614Q ATA6616C ATA6617C ATA8210 ATA8215 ATA8510 ATA8515 * ATA664251 ATmega32HVE2 */ -static const Valueitem_t _values_lb_atmega328[3] = { +static const Configvalue _values_lb_atmega328[3] = { {0, "prog_ver_disabled", "further programming and verification disabled"}, {2, "prog_disabled", "further programming disabled"}, {3, "no_lock", "no memory lock features enabled"}, @@ -9684,7 +9684,7 @@ static const Valueitem_t _values_lb_atmega328[3] = { * ATxmega192A3U ATxmega192C3 ATxmega192D3 ATxmega256A3 ATxmega256A3B ATxmega256A3BU ATxmega256A3U * ATxmega256C3 ATxmega256D3 ATxmega384C3 ATxmega384D3 */ -static const Valueitem_t _values_lb_atxmega16e5[3] = { +static const Configvalue _values_lb_atxmega16e5[3] = { {0, "rwlock", "read and write not allowed"}, {2, "wlock", "write not allowed"}, {3, "nolock", "no locks"}, @@ -9698,13 +9698,13 @@ static const Valueitem_t _values_lb_atxmega16e5[3] = { * ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 * ATmega3209 ATmega4808 ATmega4809 */ -static const Valueitem_t _values_lb_attiny204[2] = { +static const Configvalue _values_lb_attiny204[2] = { {0x3a, "rwlock", "read and write not allowed"}, {0xc5, "nolock", "no locks"}, }; // AT90S2333 -static const Valueitem_t _values_lb_at90s2333[3] = { +static const Configvalue _values_lb_at90s2333[3] = { {0, "prog_ver_disabled", "further programming and verification disabled"}, {1, "prog_disabled", "further programming disabled"}, {3, "no_lock", "no memory lock features enabled"}, @@ -9731,7 +9731,7 @@ static const Valueitem_t _values_lb_at90s2333[3] = { * ATA5782 ATA5783 ATA5787 ATA5790N ATA5791 ATA5795 ATA5831 ATA5832 ATA5833 ATA5835 ATA6286 * ATA6289 ATA6612C ATA6613C ATA6614Q ATA8210 ATA8215 ATA8510 ATA8515 ATmega32HVE2 */ -static const Valueitem_t _values_blb0_atmega328[4] = { +static const Configvalue _values_blb0_atmega328[4] = { {0, "lpm_spm_disabled_in_app", "LPM and SPM prohibited in application section"}, {1, "lpm_disabled_in_app", "LPM prohibited in application section"}, {2, "spm_disabled_in_app", "SPM prohibited in application section"}, @@ -9759,7 +9759,7 @@ static const Valueitem_t _values_blb0_atmega328[4] = { * ATA5782 ATA5783 ATA5787 ATA5790N ATA5791 ATA5795 ATA5831 ATA5832 ATA5833 ATA5835 ATA6286 * ATA6289 ATA6612C ATA6613C ATA6614Q ATA8210 ATA8215 ATA8510 ATA8515 ATmega32HVE2 */ -static const Valueitem_t _values_blb1_atmega328[4] = { +static const Configvalue _values_blb1_atmega328[4] = { {0, "lpm_spm_disabled_in_boot", "LPM and SPM prohibited in boot section"}, {1, "lpm_disabled_in_boot", "LPM prohibited in boot section"}, {2, "spm_disabled_in_boot", "SPM prohibited in boot section"}, @@ -9767,25 +9767,25 @@ static const Valueitem_t _values_blb1_atmega328[4] = { }; // ATmega16M1 ATmega32C1 ATmega32M1 ATmega64C1 ATmega64M1 -static const Valueitem_t _values_pscrvb_atmega16m1[2] = { +static const Configvalue _values_pscrvb_atmega16m1[2] = { {0, "v_0", "PSC0UTnB reset value 0"}, {1, "v_1", "PSC0UTnB reset value 1"}, }; // ATmega16M1 ATmega32C1 ATmega32M1 ATmega64C1 ATmega64M1 -static const Valueitem_t _values_pscrva_atmega16m1[2] = { +static const Configvalue _values_pscrva_atmega16m1[2] = { {0, "v_0", "PSCOUTnA reset value 0"}, {1, "v_1", "PSCOUTnA reset value 1"}, }; // ATmega16M1 ATmega32C1 ATmega32M1 ATmega64C1 ATmega64M1 -static const Valueitem_t _values_pscrb_atmega16m1[2] = { +static const Configvalue _values_pscrb_atmega16m1[2] = { {0, "rb_enabled", "PSC reset behavior enabled"}, {1, "rb_disabled", "PSC reset behavior disabled"}, }; // ATmega16HVA2 ATmega8HVA ATmega16HVA -static const Valueitem_t _values_sut_atmega16hva2[8] = { +static const Configvalue _values_sut_atmega16hva2[8] = { {0, "sut_6ck_14ck_4ms", "startup time PWRDWN/RESET: 6 CK/14 CK + 4 ms"}, {1, "sut_6ck_14ck_8ms", "startup time PWRDWN/RESET: 6 CK/14 CK + 8 ms"}, {2, "sut_6ck_14ck_16ms", "startup time PWRDWN/RESET: 6 CK/14 CK + 16 ms"}, @@ -9797,7 +9797,7 @@ static const Valueitem_t _values_sut_atmega16hva2[8] = { }; // ATmega32HVBrevB ATmega16HVB ATmega16HVBrevB ATmega32HVB -static const Valueitem_t _values_sut_atmega32hvbrevb[8] = { +static const Configvalue _values_sut_atmega32hvbrevb[8] = { {0, "sut_14ck_4ms", "startup time: 14 CK + 4 ms"}, {1, "sut_14ck_8ms", "startup time: 14 CK + 8 ms"}, {2, "sut_14ck_16ms", "startup time: 14 CK + 16 ms"}, @@ -9809,7 +9809,7 @@ static const Valueitem_t _values_sut_atmega32hvbrevb[8] = { }; // ATmega64HVE ATmega64HVE2 ATmega32HVE2 -static const Valueitem_t _values_sut_atmega64hve[4] = { +static const Configvalue _values_sut_atmega64hve[4] = { {0, "sut_14ck_0ms", "startup time: 14 CK + 0 ms"}, {1, "sut_14ck_16ms", "startup time: 14 CK + 16 ms"}, {2, "sut_14ck_32ms", "startup time: 14 CK + 32 ms"}, @@ -9830,7 +9830,7 @@ static const Valueitem_t _values_sut_atmega64hve[4] = { * AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 * AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_sut_attiny204[8] = { +static const Configvalue _values_sut_attiny204[8] = { {0, "sut_0ms", "startup time 0 ms"}, {1, "sut_1ms", "startup time 1 ms"}, {2, "sut_2ms", "startup time 2 ms"}, @@ -9842,7 +9842,7 @@ static const Valueitem_t _values_sut_attiny204[8] = { }; // ATmega161 -static const Valueitem_t _values_sut_atmega161[2] = { +static const Configvalue _values_sut_atmega161[2] = { {0, "sut_long", "start up time long"}, {1, "sut_short", "start up time short"}, }; @@ -9854,29 +9854,29 @@ static const Valueitem_t _values_sut_atmega161[2] = { * ATtiny1634R ATtiny2313 ATtiny2313A ATtiny4313 ATmega8HVA ATmega16HVA ATmega48 ATmega48A * ATmega48P ATmega48PA ATmega48PB ATA5272 ATA5505 ATA6616C ATA6617C ATA664251 */ -static const Valueitem_t _values_selfprgen_atmega16hva2[2] = { +static const Configvalue _values_selfprgen_atmega16hva2[2] = { {0, "spm_enabled", "self programming enabled"}, {1, "spm_disabled", "self programming disabled"}, }; // ATmega16HVA2 -static const Valueitem_t _values_cksel_atmega16hva2[2] = { +static const Configvalue _values_cksel_atmega16hva2[2] = { {1, "slow_rcosc", "slow RC osc"}, {2, "ulp_rcosc", "ultra-low-power RC osc"}, }; // ATmega32HVBrevB ATmega16HVB ATmega16HVBrevB ATmega32HVB -static const Valueitem_t _values_cksel_atmega32hvbrevb[1] = { +static const Configvalue _values_cksel_atmega32hvbrevb[1] = { {1, "default", "default"}, }; // ATmega64HVE ATmega64HVE2 ATmega32HVE2 -static const Valueitem_t _values_cksel_atmega64hve[1] = { +static const Configvalue _values_cksel_atmega64hve[1] = { {1, "osel_default", "oscillator selection default"}, }; // ATtiny28 ATtiny12 -static const Valueitem_t _values_cksel_attiny28[16] = { +static const Configvalue _values_cksel_attiny28[16] = { {0x00, "extclkx00", "external clock"}, {0x01, "extclkx01", "external clock"}, {0x02, "intrcoscx02", "internal RC oscillator"}, @@ -9896,7 +9896,7 @@ static const Valueitem_t _values_cksel_attiny28[16] = { }; // ATtiny11 -static const Valueitem_t _values_cksel_attiny11[5] = { +static const Configvalue _values_cksel_attiny11[5] = { {0, "extclk", "external clock"}, {4, "intrcosc", "internal RC oscillator"}, {5, "extrcosc", "external RC oscillator"}, @@ -9905,7 +9905,7 @@ static const Valueitem_t _values_cksel_attiny11[5] = { }; // ATtiny15 -static const Valueitem_t _values_cksel_attiny15[4] = { +static const Configvalue _values_cksel_attiny15[4] = { {0, "slowpwrx00", "slowly rising power"}, {1, "slowpwrx01", "slowly rising power"}, {2, "quickpwr", "quickly rising power"}, @@ -9913,13 +9913,13 @@ static const Valueitem_t _values_cksel_attiny15[4] = { }; // AT90S1200 ATtiny22 AT90S2343 -static const Valueitem_t _values_cksel_at90s1200[2] = { +static const Configvalue _values_cksel_at90s1200[2] = { {0, "intrcosc", "internal RC oscillator"}, {1, "extclk", "external clock"}, }; // ATmega103 -static const Valueitem_t _values_cksel_atmega103[4] = { +static const Configvalue _values_cksel_atmega103[4] = { {0, "sut_5ck", "startup time 5 CPU cycles"}, {1, "sut_0ms5", "startup time 0.5 ms"}, {2, "sut_4ms", "startup time 4 ms"}, @@ -9927,7 +9927,7 @@ static const Valueitem_t _values_cksel_atmega103[4] = { }; // ATmega161 -static const Valueitem_t _values_cksel_atmega161[8] = { +static const Configvalue _values_cksel_atmega161[8] = { {0, "extclk_fastpwr", "ext clock; fast rising power"}, {1, "extclk_boden_por", "ext clock; brownout detection or power-on reset"}, {2, "xosc_slowpwr", "crystal osc; slowly rising power"}, @@ -9939,7 +9939,7 @@ static const Valueitem_t _values_cksel_atmega161[8] = { }; // ATmega163 ATmega323 -static const Valueitem_t _values_cksel_atmega163[16] = { +static const Configvalue _values_cksel_atmega163[16] = { {0x00, "extclk_fastpwr", "ext clock; fast rising power"}, {0x01, "extclk_boden", "ext clock; brownout detection"}, {0x02, "intrcosc_slowpwr", "int RC osc; slowly rising power"}, @@ -9959,13 +9959,13 @@ static const Valueitem_t _values_cksel_atmega163[16] = { }; // ATmega16HVA2 -static const Valueitem_t _values_compmode_atmega16hva2[2] = { +static const Configvalue _values_compmode_atmega16hva2[2] = { {0, "cm_programmed", "compatibility mode programmed"}, {1, "cm_unprogrammed", "compatibility mode unprogrammed"}, }; // ATmega32HVBrevB ATmega16HVBrevB -static const Valueitem_t _values_duvrdinit_atmega32hvbrevb[2] = { +static const Configvalue _values_duvrdinit_atmega32hvbrevb[2] = { {0, "duvr_on", "DUVR mode on"}, {1, "duvr_off", "DUVR mode off"}, }; @@ -9976,19 +9976,19 @@ static const Valueitem_t _values_duvrdinit_atmega32hvbrevb[2] = { * ATmega128A ATmega163 ATmega323 ATmega8535 AT90S2333 AT90S4433 AT90S8515comp ATA6286 ATA6289 * ATmega32HVE2 */ -static const Valueitem_t _values_boden_atmega64hve[2] = { +static const Configvalue _values_boden_atmega64hve[2] = { {0, "bod_enabled", "brownout detection enabled"}, {1, "bod_disabled", "brownout detection disabled"}, }; // AT90SCR100H AT90SCR100 -static const Valueitem_t _values_boden_at90scr100h[2] = { +static const Configvalue _values_boden_at90scr100h[2] = { {0, "bod_disabled", "brownout detection disabled"}, {1, "bod_enabled", "brownout detection enabled"}, }; // ATmega328PB ATmega324PB -static const Valueitem_t _values_cfd_atmega328pb[2] = { +static const Configvalue _values_cfd_atmega328pb[2] = { {0, "cfd_disabled", "clock failure detection disabled"}, {1, "cfd_enabled", "clock failure detection enabled"}, }; @@ -9997,25 +9997,25 @@ static const Valueitem_t _values_cfd_atmega328pb[2] = { * ATmega8515 ATmega103comp AT90S8535comp ATmega8 ATmega8A ATmega16 ATmega16A ATmega32 ATmega32A * ATmega64 ATmega64A ATmega128 ATmega128A ATmega8535 AT90S8515comp */ -static const Valueitem_t _values_ckopt_atmega8515[2] = { +static const Configvalue _values_ckopt_atmega8515[2] = { {0, "full_railtorail", "oscillator swings full rail-to-rail"}, {1, "less_than_full_railtorail", "oscillator swings less than full rail-to-rail"}, }; // ATtiny26 -static const Valueitem_t _values_ckopt_attiny26[2] = { +static const Configvalue _values_ckopt_attiny26[2] = { {0, "int_caps_enabled", "internal capacitors on XTAL1 and XTAL2 enabled"}, {1, "no_int_caps", "no internal capacitors on XTAL1 and XTAL2"}, }; // ATmega8515 AT90S8515comp -static const Valueitem_t _values_s8515c_atmega8515[2] = { +static const Configvalue _values_s8515c_atmega8515[2] = { {0, "c8515_enabled", "AT90S4414/8515 compatibility mode enabled"}, {1, "c8515_disabled", "AT90S4414/8515 compatibility mode disabled"}, }; // ATtiny28 -static const Valueitem_t _values_intcap_attiny28[2] = { +static const Configvalue _values_intcap_attiny28[2] = { {0, "cap_enabled", "internal load capacitors between XTAL1/XTAL2 and GND enabled"}, {1, "cap_disabled", "internal load capacitors between XTAL1/XTAL2 and GND disabled"}, }; @@ -10024,7 +10024,7 @@ static const Valueitem_t _values_intcap_attiny28[2] = { * ATtiny441 ATtiny441 ATtiny828 ATtiny828 ATtiny828R ATtiny828R ATtiny841 ATtiny841 ATtiny1634 * ATtiny1634 ATtiny1634R ATtiny1634R */ -static const Valueitem_t _values_bodact_attiny441[3] = { +static const Configvalue _values_bodact_attiny441[3] = { {1, "bod_sampled", "brownout detection in sampled mode"}, {2, "bod_enabled", "brownout detection enabled"}, {3, "bod_disabled", "brownout detection disabled"}, @@ -10046,7 +10046,7 @@ static const Valueitem_t _values_bodact_attiny441[3] = { * ATxmega256A3U ATxmega256C3 ATxmega256C3 ATxmega256D3 ATxmega256D3 ATxmega384C3 ATxmega384C3 * ATxmega384D3 ATxmega384D3 */ -static const Valueitem_t _values_bodact_atxmega16e5[3] = { +static const Configvalue _values_bodact_atxmega16e5[3] = { {1, "bod_sampled", "brownout detection in sampled mode"}, {2, "bod_continuous", "brownout detection enabled in continuous mode"}, {3, "bod_disabled", "brownout detection disabled"}, @@ -10056,7 +10056,7 @@ static const Valueitem_t _values_bodact_atxmega16e5[3] = { * ATtiny441 ATtiny441 ATtiny828 ATtiny828 ATtiny828R ATtiny828R ATtiny841 ATtiny841 ATtiny1634 * ATtiny1634 ATtiny1634R ATtiny1634R */ -static const Valueitem_t _values_bodpd_attiny441[3] = { +static const Configvalue _values_bodpd_attiny441[3] = { {1, "bod_sampled", "brownout detection in sampled mode"}, {2, "bod_enabled", "brownout detection enabled"}, {3, "bod_disabled", "brownout detection disabled"}, @@ -10078,14 +10078,14 @@ static const Valueitem_t _values_bodpd_attiny441[3] = { * ATxmega256A3U ATxmega256C3 ATxmega256C3 ATxmega256D3 ATxmega256D3 ATxmega384C3 ATxmega384C3 * ATxmega384D3 ATxmega384D3 */ -static const Valueitem_t _values_bodpd_atxmega16e5[3] = { +static const Configvalue _values_bodpd_atxmega16e5[3] = { {1, "bod_sampled", "brownout detection in sampled mode"}, {2, "bod_continuous", "brownout detection enabled in continuous mode"}, {3, "bod_disabled", "brownout detection disabled"}, }; // ATtiny441 ATtiny841 -static const Valueitem_t _values_ulposcsel_attiny441[5] = { +static const Configvalue _values_ulposcsel_attiny441[5] = { {3, "ulposc_512khz", "ultra-low-power clock running at 512 kHz"}, {4, "ulposc_256khz", "ultra-low-power clock running at 256 kHz"}, {5, "ulposc_128khz", "ultra-low-power clock running at 128 kHz"}, @@ -10094,37 +10094,37 @@ static const Valueitem_t _values_ulposcsel_attiny441[5] = { }; // AT90PWM2 AT90PWM81 AT90PWM1 AT90PWM2B AT90PWM3 AT90PWM3B AT90PWM161 AT90PWM216 AT90PWM316 -static const Valueitem_t _values_pscrv_at90pwm2[2] = { +static const Configvalue _values_pscrv_at90pwm2[2] = { {0, "v_0", "PSCOUT reset value 0"}, {1, "v_1", "PSCOUT reset value 1"}, }; // AT90PWM2 AT90PWM81 AT90PWM1 AT90PWM2B AT90PWM3 AT90PWM3B AT90PWM161 AT90PWM216 AT90PWM316 -static const Valueitem_t _values_psc0rb_at90pwm2[2] = { +static const Configvalue _values_psc0rb_at90pwm2[2] = { {0, "rb_enabled", "PSC0 reset behavior enabled"}, {1, "rb_disabled", "PSC0 reset behavior disabled"}, }; // AT90PWM2 AT90PWM2B AT90PWM3 AT90PWM3B AT90PWM216 AT90PWM316 -static const Valueitem_t _values_psc1rb_at90pwm2[2] = { +static const Configvalue _values_psc1rb_at90pwm2[2] = { {0, "rb_enabled", "PSC1 reset behavior enabled"}, {1, "rb_disabled", "PSC1 reset behavior disabled"}, }; // AT90PWM2 AT90PWM81 AT90PWM1 AT90PWM2B AT90PWM3 AT90PWM3B AT90PWM161 AT90PWM216 AT90PWM316 -static const Valueitem_t _values_psc2rb_at90pwm2[2] = { +static const Configvalue _values_psc2rb_at90pwm2[2] = { {0, "rb_enabled", "PSC2 reset behavior enabled"}, {1, "rb_disabled", "PSC2 reset behavior disabled"}, }; // AT90PWM81 AT90PWM161 -static const Valueitem_t _values_pscinrb_at90pwm81[2] = { +static const Configvalue _values_pscinrb_at90pwm81[2] = { {0, "rb_enabled", "PSC2 and PSC0 input reset behavior enabled"}, {1, "rb_disabled", "PSC2 and PSC0 input reset behavior disabled"}, }; // AT90PWM81 AT90PWM161 -static const Valueitem_t _values_psc2rba_at90pwm81[2] = { +static const Configvalue _values_psc2rba_at90pwm81[2] = { {0, "rb_enabled", "PSC2 reset behavior for 22 and 23 enabled"}, {1, "rb_disabled", "PSC2 reset behavior for 22 and 23 disabled"}, }; @@ -10146,7 +10146,7 @@ static const Valueitem_t _values_psc2rba_at90pwm81[2] = { * ATxmega128B1 ATxmega128B3 ATxmega128A4U ATxmega192A3 ATxmega192A3U ATxmega256A3 ATxmega256A3B * ATxmega256A3BU ATxmega256A3U */ -static const Valueitem_t _values_jtagen_at90can128[2] = { +static const Configvalue _values_jtagen_at90can128[2] = { {0, "jtag_enabled", "JTAG interface enabled"}, {1, "jtag_disabled", "JTAG interface disabled"}, }; @@ -10164,13 +10164,13 @@ static const Valueitem_t _values_jtagen_at90can128[2] = { * ATmega3290P ATmega3290PA ATmega6450 ATmega6450A ATmega6450P ATmega6490 ATmega6490A ATmega6490P * AT90CAN32 AT90CAN64 AT90SCR100 AT90USB646 AT90USB647 AT90USB1286 AT90USB1287 */ -static const Valueitem_t _values_ocden_at90can128[2] = { +static const Configvalue _values_ocden_at90can128[2] = { {0, "ocd_enabled", "on-chip debug enabled"}, {1, "ocd_disabled", "on-chip debug disabled"}, }; // AT90CAN128 AT90CAN32 AT90CAN64 -static const Valueitem_t _values_ta0sel_at90can128[2] = { +static const Configvalue _values_ta0sel_at90can128[2] = { {0, "ft_enabled", "factory tests enabled"}, {1, "ft_disabled", "factory tests disabled"}, }; @@ -10179,37 +10179,37 @@ static const Valueitem_t _values_ta0sel_at90can128[2] = { * AT90USB162 ATmega8U2 ATmega16U2 ATmega16U4 ATmega32U2 ATmega32U4 ATmega32U6 AT90USB82 AT90USB646 * AT90USB647 AT90USB1286 AT90USB1287 */ -static const Valueitem_t _values_hwbe_at90usb162[2] = { +static const Configvalue _values_hwbe_at90usb162[2] = { {0, "gpio_pin_can_force_reset_to_boot_section", "GPIO pin can force reset to boot section"}, {1, "gpio_pin_cannot_force_reset_to_boot_section", "GPIO pin cannot force reset to boot section"}, }; // AT90S1200 ATtiny22 AT90S2343 -static const Valueitem_t _values_rcen_at90s1200[2] = { +static const Configvalue _values_rcen_at90s1200[2] = { {0, "intrcosc", "internal RC oscillator"}, {1, "extclk", "external clock"}, }; // AT90S2313 ATtiny11 AT90S2323 AT90S4414 AT90S4434 AT90S8515 AT90S8535 -static const Valueitem_t _values_fstrt_at90s2313[2] = { +static const Configvalue _values_fstrt_at90s2313[2] = { {0, "sut_short", "startup time short"}, {1, "sut_long", "startup time long"}, }; // ATA5700M322 ATA5702M322 -static const Valueitem_t _values_pcee1_ata5700m322[2] = { +static const Configvalue _values_pcee1_ata5700m322[2] = { {0, "cee_protected", "customer EEPROM section protected"}, {1, "cee_unprotected", "customer EEPROM section unprotected"}, }; // ATA5700M322 ATA5702M322 -static const Valueitem_t _values_eeacc_ata5700m322[2] = { +static const Configvalue _values_eeacc_ata5700m322[2] = { {0, "eea_enabled", "EEPROM access control enabled"}, {1, "eea_disabled", "EEPROM access control disabled"}, }; // ATA5700M322 ATA5702M322 -static const Valueitem_t _values_ckstart_ata5700m322[2] = { +static const Configvalue _values_ckstart_ata5700m322[2] = { {0, "mrc_selected", "MRC selected"}, {1, "mrc_not_selected", "MRC not selected"}, }; @@ -10218,7 +10218,7 @@ static const Valueitem_t _values_ckstart_ata5700m322[2] = { * ATA5781 ATA5790 ATA5782 ATA5783 ATA5787 ATA5791 ATA5831 ATA5832 ATA5833 ATA5835 ATA8210 ATA8215 * ATA8510 ATA8515 */ -static const Valueitem_t _values_extclken_ata5781[2] = { +static const Configvalue _values_extclken_ata5781[2] = { {0, "xclk_enabled", "external clock enabled"}, {1, "xclk_disabled", "external clock disabled"}, }; @@ -10244,7 +10244,7 @@ static const Valueitem_t _values_extclken_ata5781[2] = { * ATA5782 ATA5783 ATA5787 ATA5790N ATA5791 ATA5795 ATA5831 ATA5832 ATA5833 ATA5835 ATA6286 * ATA6289 ATA6612C ATA6613C ATA6614Q ATA8210 ATA8215 ATA8510 ATA8515 ATmega32HVE2 */ -static const Valueitem_t _values_ap_atmega328[4] = { +static const Configvalue _values_ap_atmega328[4] = { {0, "lpm_spm_disabled_in_app", "LPM and SPM prohibited in application section"}, {1, "lpm_disabled_in_app", "LPM prohibited in application section"}, {2, "spm_disabled_in_app", "SPM prohibited in application section"}, @@ -10272,7 +10272,7 @@ static const Valueitem_t _values_ap_atmega328[4] = { * ATA5782 ATA5783 ATA5787 ATA5790N ATA5791 ATA5795 ATA5831 ATA5832 ATA5833 ATA5835 ATA6286 * ATA6289 ATA6612C ATA6613C ATA6614Q ATA8210 ATA8215 ATA8510 ATA8515 ATmega32HVE2 */ -static const Valueitem_t _values_blp_atmega328[4] = { +static const Configvalue _values_blp_atmega328[4] = { {0, "lpm_spm_disabled_in_boot", "LPM and SPM prohibited in boot section"}, {1, "lpm_disabled_in_boot", "LPM prohibited in boot section"}, {2, "spm_disabled_in_boot", "SPM prohibited in boot section"}, @@ -10280,36 +10280,36 @@ static const Valueitem_t _values_blp_atmega328[4] = { }; // ATA5790 ATA5790N ATA5791 ATA5795 -static const Valueitem_t _values__32oen_ata5790[2] = { +static const Configvalue _values__32oen_ata5790[2] = { {0, "o32_enabled", "32 kHz oscillator enabled"}, {1, "o32_disabled", "32 kHz oscillator disabled"}, }; // ATA5790 ATA5790N ATA5791 ATA5795 -static const Valueitem_t _values_reserved_ata5790[1] = { +static const Configvalue _values_reserved_ata5790[1] = { {0, "must_be_0", "bit must be programmed"}, }; // ATA6285 ATA6286 ATA6289 -static const Valueitem_t _values_tsrdi_ata6285[2] = { +static const Configvalue _values_tsrdi_ata6285[2] = { {0, "tsr_disabled", "temperature shutdown reset disabled"}, {1, "tsr_enabled", "temperature shutdown reset enabled"}, }; // ATA6285 ATA6286 ATA6289 -static const Valueitem_t _values_frcfs_ata6285[2] = { +static const Configvalue _values_frcfs_ata6285[2] = { {0, "osc_4mhz", "fast RC oscillator frequency 4 MHz"}, {1, "osc_1mhz", "fast RC oscillator frequency 1 MHz"}, }; // ATA6285 ATA6286 ATA6289 -static const Valueitem_t _values_wdrcon_ata6285[2] = { +static const Configvalue _values_wdrcon_ata6285[2] = { {0, "wdrc_enabled", "watchdog RC oscillator enabled"}, {1, "wdrc_disabled", "watchdog RC oscillator disabled"}, }; // ATA6285 ATA6286 ATA6289 -static const Valueitem_t _values_eelock_ata6285[2] = { +static const Configvalue _values_eelock_ata6285[2] = { {0, "eel_locked", "upper EEPROM locked"}, {1, "eel_unlocked", "upper EEPROM unlocked"}, }; @@ -10330,7 +10330,7 @@ static const Valueitem_t _values_eelock_ata6285[2] = { * ATxmega256A3U ATxmega256C3 ATxmega256C3 ATxmega256D3 ATxmega256D3 ATxmega384C3 ATxmega384C3 * ATxmega384D3 ATxmega384D3 */ -static const Valueitem_t _values_wdper_atxmega16e5[11] = { +static const Configvalue _values_wdper_atxmega16e5[11] = { {0x00, "t_0s008", "8 cycles (8 ms)"}, {0x01, "t_0s016", "16 cycles (16 ms)"}, {0x02, "t_0s032", "32 cycles (32 ms)"}, @@ -10360,7 +10360,7 @@ static const Valueitem_t _values_wdper_atxmega16e5[11] = { * ATxmega256A3U ATxmega256C3 ATxmega256C3 ATxmega256D3 ATxmega256D3 ATxmega384C3 ATxmega384C3 * ATxmega384D3 ATxmega384D3 */ -static const Valueitem_t _values_wdwper_atxmega16e5[11] = { +static const Configvalue _values_wdwper_atxmega16e5[11] = { {0x00, "t_0s008", "8 cycles (8 ms)"}, {0x01, "t_0s016", "16 cycles (16 ms)"}, {0x02, "t_0s032", "32 cycles (32 ms)"}, @@ -10383,7 +10383,7 @@ static const Valueitem_t _values_wdwper_atxmega16e5[11] = { * ATxmega192A3U ATxmega192C3 ATxmega192D3 ATxmega256A3 ATxmega256A3B ATxmega256A3BU ATxmega256A3U * ATxmega256C3 ATxmega256D3 ATxmega384C3 ATxmega384D3 */ -static const Valueitem_t _values_wdlock_atxmega16e5[2] = { +static const Configvalue _values_wdlock_atxmega16e5[2] = { {0, "wd_locked", "watchdog timer locked"}, {1, "wd_unlocked", "watchdog timer unlocked"}, }; @@ -10397,20 +10397,20 @@ static const Valueitem_t _values_wdlock_atxmega16e5[2] = { * ATxmega192A3U ATxmega192C3 ATxmega192D3 ATxmega256A3 ATxmega256A3B ATxmega256A3BU ATxmega256A3U * ATxmega256C3 ATxmega256D3 ATxmega384C3 ATxmega384D3 */ -static const Valueitem_t _values_startuptime_atxmega16e5[3] = { +static const Configvalue _values_startuptime_atxmega16e5[3] = { {0, "sut_64ms", "startup time 64 ms"}, {1, "sut_4ms", "startup time 4 ms"}, {3, "sut_0ms", "startup time 0 ms"}, }; // ATxmega16E5 ATxmega16E5 ATxmega8E5 ATxmega8E5 ATxmega32E5 ATxmega32E5 -static const Valueitem_t _values_fdact4_atxmega16e5[2] = { +static const Configvalue _values_fdact4_atxmega16e5[2] = { {0, "gpio_from_value_fuse", "during reset and until a timer/counter compare channel is enabled the port pins are set to the VALUEn fuse bits"}, {1, "default_io", "default I/O pin configuration"}, }; // ATxmega16E5 ATxmega16E5 ATxmega8E5 ATxmega8E5 ATxmega32E5 ATxmega32E5 -static const Valueitem_t _values_fdact5_atxmega16e5[2] = { +static const Configvalue _values_fdact5_atxmega16e5[2] = { {0, "gpio_from_value_fuse", "during reset and until a timer/counter compare channel is enabled the port pins are set to the VALUEn fuse bits"}, {1, "default_io", "default I/O pin configuration"}, }; @@ -10437,7 +10437,7 @@ static const Valueitem_t _values_fdact5_atxmega16e5[2] = { * ATxmega256C3 ATxmega256C3 ATxmega256C3 ATxmega256D3 ATxmega256D3 ATxmega256D3 ATxmega384C3 * ATxmega384C3 ATxmega384C3 ATxmega384D3 ATxmega384D3 ATxmega384D3 */ -static const Valueitem_t _values_blbat_atxmega16e5[4] = { +static const Configvalue _values_blbat_atxmega16e5[4] = { {0, "rwlock", "read and write not allowed"}, {1, "rlock", "read not allowed"}, {2, "wlock", "write not allowed"}, @@ -10466,7 +10466,7 @@ static const Valueitem_t _values_blbat_atxmega16e5[4] = { * ATxmega256C3 ATxmega256C3 ATxmega256C3 ATxmega256D3 ATxmega256D3 ATxmega256D3 ATxmega384C3 * ATxmega384C3 ATxmega384C3 ATxmega384D3 ATxmega384D3 ATxmega384D3 */ -static const Valueitem_t _values_blba_atxmega16e5[4] = { +static const Configvalue _values_blba_atxmega16e5[4] = { {0, "rwlock", "read and write not allowed"}, {1, "rlock", "read not allowed"}, {2, "wlock", "write not allowed"}, @@ -10495,7 +10495,7 @@ static const Valueitem_t _values_blba_atxmega16e5[4] = { * ATxmega256C3 ATxmega256C3 ATxmega256C3 ATxmega256D3 ATxmega256D3 ATxmega256D3 ATxmega384C3 * ATxmega384C3 ATxmega384C3 ATxmega384D3 ATxmega384D3 ATxmega384D3 */ -static const Valueitem_t _values_blbb_atxmega16e5[4] = { +static const Configvalue _values_blbb_atxmega16e5[4] = { {0, "rwlock", "read and write not allowed"}, {1, "rlock", "read not allowed"}, {2, "wlock", "write not allowed"}, @@ -10509,7 +10509,7 @@ static const Valueitem_t _values_blbb_atxmega16e5[4] = { * ATxmega128D3 ATxmega128A4U ATxmega128D4 ATxmega192A3U ATxmega192C3 ATxmega192D3 ATxmega256A3BU * ATxmega256A3U ATxmega256C3 ATxmega256D3 ATxmega384C3 ATxmega384D3 */ -static const Valueitem_t _values_toscsel_atxmega128a3u[2] = { +static const Configvalue _values_toscsel_atxmega128a3u[2] = { {0, "alternate", "TOSC1/TOSC2 on separate pins"}, {1, "xtal", "TOSC1/TOSC2 shared with XTAL1/XTAL2"}, }; @@ -10522,7 +10522,7 @@ static const Valueitem_t _values_toscsel_atxmega128a3u[2] = { * ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 * ATmega3209 ATmega4808 ATmega4809 */ -static const Valueitem_t _values_wdtperiod_attiny204[12] = { +static const Configvalue _values_wdtperiod_attiny204[12] = { {0x00, "t_off", "watchdog timer off"}, {0x01, "t_0s008", "8 cycles (8 ms)"}, {0x02, "t_0s016", "16 cycles (16 ms)"}, @@ -10546,7 +10546,7 @@ static const Valueitem_t _values_wdtperiod_attiny204[12] = { * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 * AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_wdtperiod_avr32dd14[12] = { +static const Configvalue _values_wdtperiod_avr32dd14[12] = { {0x00, "t_off", "watchdog timer off"}, {0x01, "t_0s008", "8 cycles (8 ms)"}, {0x02, "t_0s016", "16 cycles (16 ms)"}, @@ -10569,7 +10569,7 @@ static const Valueitem_t _values_wdtperiod_avr32dd14[12] = { * ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 * ATmega3209 ATmega4808 ATmega4809 */ -static const Valueitem_t _values_wdtwindow_attiny204[12] = { +static const Configvalue _values_wdtwindow_attiny204[12] = { {0x00, "t_off", "window mode off"}, {0x01, "t_0s008", "8 cycles (8 ms)"}, {0x02, "t_0s016", "16 cycles (16 ms)"}, @@ -10593,7 +10593,7 @@ static const Valueitem_t _values_wdtwindow_attiny204[12] = { * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 * AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_wdtwindow_avr32dd14[12] = { +static const Configvalue _values_wdtwindow_avr32dd14[12] = { {0x00, "t_off", "window mode off"}, {0x01, "t_0s008", "8 cycles (8 ms)"}, {0x02, "t_0s016", "16 cycles (16 ms)"}, @@ -10616,7 +10616,7 @@ static const Valueitem_t _values_wdtwindow_avr32dd14[12] = { * ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 * ATmega3209 ATmega4808 ATmega4809 */ -static const Valueitem_t _values_bodsleep_attiny204[3] = { +static const Configvalue _values_bodsleep_attiny204[3] = { {0, "bod_disabled", "brownout detection disabled"}, {1, "bod_enabled", "brownout detection enabled"}, {2, "bod_sampled", "brownout detection in sampled mode"}, @@ -10631,7 +10631,7 @@ static const Valueitem_t _values_bodsleep_attiny204[3] = { * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 * AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_bodsleep_avr32dd14[3] = { +static const Configvalue _values_bodsleep_avr32dd14[3] = { {0, "bod_disabled", "brownout detection disabled"}, {1, "bod_continuous", "brownout detection enabled in continuous mode"}, {2, "bod_sampled", "brownout detection in sampled mode"}, @@ -10645,7 +10645,7 @@ static const Valueitem_t _values_bodsleep_avr32dd14[3] = { * ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 * ATmega3209 ATmega4808 ATmega4809 */ -static const Valueitem_t _values_bodactive_attiny204[4] = { +static const Configvalue _values_bodactive_attiny204[4] = { {0, "bod_disabled", "brownout detection disabled"}, {1, "bod_enabled", "brownout detection enabled"}, {2, "bod_sampled", "brownout detection in sampled mode"}, @@ -10661,7 +10661,7 @@ static const Valueitem_t _values_bodactive_attiny204[4] = { * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 * AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_bodactive_avr32dd14[4] = { +static const Configvalue _values_bodactive_avr32dd14[4] = { {0, "bod_disabled", "brownout detection disabled"}, {1, "bod_continuous", "brownout detection enabled in continuous mode"}, {2, "bod_sampled", "brownout detection in sampled mode"}, @@ -10676,7 +10676,7 @@ static const Valueitem_t _values_bodactive_avr32dd14[4] = { * ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 * ATmega3209 ATmega4808 ATmega4809 */ -static const Valueitem_t _values_bodsampfreq_attiny204[2] = { +static const Configvalue _values_bodsampfreq_attiny204[2] = { {0, "bod_1khz", "1 kHz sampling frequency"}, {1, "bod_125hz", "125 Hz sampling frequency"}, }; @@ -10690,7 +10690,7 @@ static const Valueitem_t _values_bodsampfreq_attiny204[2] = { * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 * AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_bodsampfreq_avr32dd14[2] = { +static const Configvalue _values_bodsampfreq_avr32dd14[2] = { {0, "bod_128hz", "128 Hz sampling frequency"}, {1, "bod_32hz", "32 Hz sampling frequency"}, }; @@ -10703,7 +10703,7 @@ static const Valueitem_t _values_bodsampfreq_avr32dd14[2] = { * ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 ATmega3209 * ATmega4808 ATmega4809 */ -static const Valueitem_t _values_freqsel_attiny204[2] = { +static const Configvalue _values_freqsel_attiny204[2] = { {1, "fcpu_16mhz", "internal clock running at 16 MHz"}, {2, "fcpu_20mhz", "internal clock running at 20 MHz"}, }; @@ -10712,13 +10712,13 @@ static const Valueitem_t _values_freqsel_attiny204[2] = { * AVR64EA48 AVR16EB14 AVR16EB20 AVR16EA28 AVR16EB28 AVR16EA32 AVR16EB32 AVR16EA48 AVR32EA28 * AVR32EA32 AVR32EA48 AVR64EA28 AVR64EA32 */ -static const Valueitem_t _values_freqsel_avr64ea48[2] = { +static const Configvalue _values_freqsel_avr64ea48[2] = { {0, "fcpu_20mhz", "OSCHF running at 20 MHz"}, {1, "fcpu_16mhz", "OSCHF running at 16 MHz"}, }; // ATtiny416auto -static const Valueitem_t _values_freqsel_attiny416auto[1] = { +static const Configvalue _values_freqsel_attiny416auto[1] = { {1, "fcpu_16mhz", "internal clock running at 16 MHz"}, }; @@ -10730,7 +10730,7 @@ static const Valueitem_t _values_freqsel_attiny416auto[1] = { * ATtiny3224 ATtiny3226 ATtiny3227 ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 * ATmega3209 ATmega4808 ATmega4809 */ -static const Valueitem_t _values_osclock_attiny204[2] = { +static const Configvalue _values_osclock_attiny204[2] = { {0, "olock_disabled", "oscillator lock disabled"}, {1, "olock_enabled", "oscillator lock enabled"}, }; @@ -10740,7 +10740,7 @@ static const Valueitem_t _values_osclock_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 * ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_cmpa_attiny204[2] = { +static const Configvalue _values_cmpa_attiny204[2] = { {0, "v_0", "compare A default output value 0"}, {1, "v_1", "compare A default output value 1"}, }; @@ -10750,7 +10750,7 @@ static const Valueitem_t _values_cmpa_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 * ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_cmpb_attiny204[2] = { +static const Configvalue _values_cmpb_attiny204[2] = { {0, "v_0", "compare B default output value 0"}, {1, "v_1", "compare B default output value 1"}, }; @@ -10760,7 +10760,7 @@ static const Valueitem_t _values_cmpb_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 * ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_cmpc_attiny204[2] = { +static const Configvalue _values_cmpc_attiny204[2] = { {0, "v_0", "compare C default output value 0"}, {1, "v_1", "compare C default output value 1"}, }; @@ -10770,7 +10770,7 @@ static const Valueitem_t _values_cmpc_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 * ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_cmpd_attiny204[2] = { +static const Configvalue _values_cmpd_attiny204[2] = { {0, "v_0", "compare D default output value 0"}, {1, "v_1", "compare D default output value 1"}, }; @@ -10780,7 +10780,7 @@ static const Valueitem_t _values_cmpd_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 * ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_cmpaen_attiny204[2] = { +static const Configvalue _values_cmpaen_attiny204[2] = { {0, "cpa_disabled", "compare A output disabled"}, {1, "cpa_enabled", "compare A output enabled"}, }; @@ -10790,7 +10790,7 @@ static const Valueitem_t _values_cmpaen_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 * ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_cmpben_attiny204[2] = { +static const Configvalue _values_cmpben_attiny204[2] = { {0, "cpb_disabled", "compare B output disabled"}, {1, "cpb_enabled", "compare B output enabled"}, }; @@ -10800,7 +10800,7 @@ static const Valueitem_t _values_cmpben_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 * ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_cmpcen_attiny204[2] = { +static const Configvalue _values_cmpcen_attiny204[2] = { {0, "cpc_disabled", "compare C output disabled"}, {1, "cpc_enabled", "compare C output enabled"}, }; @@ -10810,7 +10810,7 @@ static const Valueitem_t _values_cmpcen_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 * ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_cmpden_attiny204[2] = { +static const Configvalue _values_cmpden_attiny204[2] = { {0, "cpd_disabled", "compare D output disabled"}, {1, "cpd_enabled", "compare D output enabled"}, }; @@ -10820,7 +10820,7 @@ static const Valueitem_t _values_cmpden_attiny204[2] = { * ATtiny416 ATtiny416auto ATtiny417 ATtiny804 ATtiny806 ATtiny807 ATtiny814 ATtiny816 ATtiny817 * ATtiny1604 ATtiny1606 ATtiny1607 ATtiny1614 ATtiny1616 ATtiny1617 ATtiny3216 ATtiny3217 */ -static const Valueitem_t _values_rstpincfg_attiny204[3] = { +static const Configvalue _values_rstpincfg_attiny204[3] = { {0, "gpio", "GPIO mode"}, {1, "updi", "UPDI mode"}, {2, "rst", "reset mode"}, @@ -10830,7 +10830,7 @@ static const Valueitem_t _values_rstpincfg_attiny204[3] = { * ATtiny1624 ATtiny424 ATtiny426 ATtiny427 ATtiny824 ATtiny826 ATtiny827 ATtiny1626 ATtiny1627 * ATtiny3224 ATtiny3226 ATtiny3227 */ -static const Valueitem_t _values_rstpincfg_attiny1624[4] = { +static const Configvalue _values_rstpincfg_attiny1624[4] = { {0, "gpio", "GPIO mode"}, {1, "updi", "UPDI mode"}, {2, "rst", "reset mode"}, @@ -10843,7 +10843,7 @@ static const Valueitem_t _values_rstpincfg_attiny1624[4] = { * AVR32DD20 AVR32DU20 AVR32DD28 AVR32DU28 AVR32DD32 AVR32DU32 AVR64DD14 AVR64DD20 AVR64DD28 * AVR64DU28 AVR64DD32 AVR64DU32 */ -static const Valueitem_t _values_rstpincfg_avr32dd14[2] = { +static const Configvalue _values_rstpincfg_avr32dd14[2] = { {0, "gpio", "GPIO mode"}, {1, "rst", "reset mode"}, }; @@ -10852,7 +10852,7 @@ static const Valueitem_t _values_rstpincfg_avr32dd14[2] = { * AVR64EA48 AVR16EB14 AVR16EB20 AVR16EA28 AVR16EB28 AVR16EA32 AVR16EB32 AVR16EA48 AVR32EA28 * AVR32EA32 AVR32EA48 AVR64EA28 AVR64EA32 */ -static const Valueitem_t _values_rstpincfg_avr64ea48[2] = { +static const Configvalue _values_rstpincfg_avr64ea48[2] = { {0, "none", "no external reset"}, {1, "reset", "PF6 configured as reset pin"}, }; @@ -10862,7 +10862,7 @@ static const Valueitem_t _values_rstpincfg_avr64ea48[2] = { * AVR64DB32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 * AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_rstpincfg_avr32da28[2] = { +static const Configvalue _values_rstpincfg_avr32da28[2] = { {0, "gpio", "GPIO mode"}, {2, "rst", "reset mode"}, }; @@ -10881,7 +10881,7 @@ static const Valueitem_t _values_rstpincfg_avr32da28[2] = { * AVR64DD32 AVR64DU32 AVR64EA32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 * AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_crcsrc_attiny204[4] = { +static const Configvalue _values_crcsrc_attiny204[4] = { {0, "flash", "CRC of entire flash (boot, application code and application data)"}, {1, "boot", "CRC of boot section"}, {2, "bootapp", "CRC of application code and boot sections"}, @@ -10892,7 +10892,7 @@ static const Valueitem_t _values_crcsrc_attiny204[4] = { * ATtiny1624 ATtiny424 ATtiny426 ATtiny427 ATtiny824 ATtiny826 ATtiny827 ATtiny1626 ATtiny1627 * ATtiny3224 ATtiny3226 ATtiny3227 */ -static const Valueitem_t _values_toutdis_attiny1624[2] = { +static const Configvalue _values_toutdis_attiny1624[2] = { {0, "to_disabled", "timeout disabled"}, {1, "to_enabled", "timeout enabled"}, }; @@ -10904,7 +10904,7 @@ static const Valueitem_t _values_toutdis_attiny1624[2] = { * AVR64DU28 AVR64DA32 AVR64DB32 AVR64DD32 AVR64DU32 AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 * AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_clksel_avr32dd14[2] = { +static const Configvalue _values_clksel_avr32dd14[2] = { {0, "oschf", "1-32 MHz internal oscillator"}, {1, "osc32k", "32.768 kHz internal oscillator"}, }; @@ -10914,7 +10914,7 @@ static const Valueitem_t _values_clksel_avr32dd14[2] = { * AVR32DU14 AVR32DD20 AVR32DU20 AVR32DD28 AVR32DU28 AVR32DD32 AVR32DU32 AVR64DD14 AVR64DD20 * AVR64DD28 AVR64DU28 AVR64DD32 AVR64DU32 */ -static const Valueitem_t _values_updipincfg_avr32dd14[2] = { +static const Configvalue _values_updipincfg_avr32dd14[2] = { {0, "gpio", "GPIO mode"}, {1, "updi", "UPDI mode"}, }; @@ -10923,7 +10923,7 @@ static const Valueitem_t _values_updipincfg_avr32dd14[2] = { * AVR64EA48 AVR16EB14 AVR16EB20 AVR16EA28 AVR16EB28 AVR16EA32 AVR16EB32 AVR16EA48 AVR32EA28 * AVR32EA32 AVR32EA48 AVR64EA28 AVR64EA32 */ -static const Valueitem_t _values_updipincfg_avr64ea48[2] = { +static const Configvalue _values_updipincfg_avr64ea48[2] = { {0, "gpio", "PF7 configured as GPIO pin"}, {1, "updi", "PF7 configured as UPDI pin"}, }; @@ -10937,7 +10937,7 @@ static const Valueitem_t _values_updipincfg_avr64ea48[2] = { * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 * AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_crcsel_avr32dd14[2] = { +static const Configvalue _values_crcsel_avr32dd14[2] = { {0, "crc16", "enable CRC16"}, {1, "crc32", "enable CRC32"}, }; @@ -10947,7 +10947,7 @@ static const Valueitem_t _values_crcsel_avr32dd14[2] = { * AVR32DD32 AVR32DB48 AVR64DD14 AVR64DD20 AVR64DB28 AVR64DD28 AVR64DB32 AVR64DD32 AVR64DB48 * AVR64DB64 AVR128DB28 AVR128DB32 AVR128DB48 AVR128DB64 */ -static const Valueitem_t _values_mvsyscfg_avr32dd14[2] = { +static const Configvalue _values_mvsyscfg_avr32dd14[2] = { {1, "dual", "device used in a dual supply configuration"}, {2, "single", "device used in a single supply configuration"}, }; @@ -10961,25 +10961,25 @@ static const Valueitem_t _values_mvsyscfg_avr32dd14[2] = { * AVR64DA48 AVR64DB48 AVR64DA64 AVR64DB64 AVR128DA28 AVR128DB28 AVR128DA32 AVR128DB32 AVR128DA48 * AVR128DB48 AVR128DA64 AVR128DB64 */ -static const Valueitem_t _values_key_avr32dd14[2] = { +static const Configvalue _values_key_avr32dd14[2] = { {0x5cc5c55c, "nolock", "no locks"}, {0xa33a3aa3, "rwlock", "read and write not allowed"}, }; // ATmega103comp ATmega64 ATmega64A ATmega128 ATmega128A -static const Valueitem_t _values_m103c_atmega103comp[2] = { +static const Configvalue _values_m103c_atmega103comp[2] = { {0, "c103_enabled", "ATmega103 compatibility mode enabled"}, {1, "c103_disabled", "ATmega103 compatibility mode disabled"}, }; // ATmega161comp ATmega162 -static const Valueitem_t _values_m161c_atmega161comp[2] = { +static const Configvalue _values_m161c_atmega161comp[2] = { {0, "c161_enabled", "ATmega161 compatibility mode enabled"}, {1, "c161_disabled", "ATmega161 compatibility mode disabled"}, }; // AT90S8535comp ATmega8535 -static const Valueitem_t _values_s8535c_at90s8535comp[2] = { +static const Configvalue _values_s8535c_at90s8535comp[2] = { {0, "c8535_enabled", "AT90S4434/8535 compatibility mode enabled"}, {1, "c8535_disabled", "AT90S4434/8535 compatibility mode disabled"}, }; @@ -10988,7 +10988,7 @@ static const Valueitem_t _values_s8535c_at90s8535comp[2] = { * AVR16DU14 AVR16DU20 AVR16DU28 AVR16DU32 AVR32DU14 AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 * AVR64DU32 */ -static const Valueitem_t _values_usbsink_avr16du14[2] = { +static const Configvalue _values_usbsink_avr16du14[2] = { {0, "disable", "USB VREG cannot sink current"}, {1, "enable", "USB VREG can sink current"}, }; @@ -10997,13 +10997,13 @@ static const Valueitem_t _values_usbsink_avr16du14[2] = { * AVR16DU14 AVR16DU20 AVR16DU28 AVR16DU32 AVR32DU14 AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 * AVR64DU32 */ -static const Valueitem_t _values_nvmlevel_avr16du14[2] = { +static const Configvalue _values_nvmlevel_avr16du14[2] = { {1, "nvmaccdis", "NVM access through UPDI disabled"}, {3, "basic", "UPDI and UPDI pins working normally"}, }; // AVR16EB14 AVR16EB20 AVR16EB28 AVR16EB32 -static const Valueitem_t _values_nvmlevel_avr16eb14[2] = { +static const Configvalue _values_nvmlevel_avr16eb14[2] = { {2, "nvmaccdis", "NVM access through UPDI disabled"}, {3, "basic", "UPDI and UPDI pins working normally"}, }; @@ -11012,7 +11012,7 @@ static const Valueitem_t _values_nvmlevel_avr16eb14[2] = { * AVR16DU14 AVR16EB14 AVR16DU20 AVR16EB20 AVR16DU28 AVR16EB28 AVR16DU32 AVR16EB32 AVR32DU14 * AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 AVR64DU32 */ -static const Valueitem_t _values_nvmkey_avr16du14[2] = { +static const Configvalue _values_nvmkey_avr16du14[2] = { {0x00, "notact", "not active"}, {0xb45, "nvmact", "NVM protection active"}, }; @@ -11021,7 +11021,7 @@ static const Valueitem_t _values_nvmkey_avr16du14[2] = { // Configuration tables // ATmega328 ATmega328P ATA6614Q -const Configitem_t cfgtab_atmega328[14] = { +const Configitem cfgtab_atmega328[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega328, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11039,7 +11039,7 @@ const Configitem_t cfgtab_atmega328[14] = { }; // ATmega16M1 -const Configitem_t cfgtab_atmega16m1[17] = { +const Configitem cfgtab_atmega16m1[17] = { {"sut_cksel", 53, _values_sut_cksel_atmega16m1, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega16m1, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11060,7 +11060,7 @@ const Configitem_t cfgtab_atmega16m1[17] = { }; // ATmega16HVA2 -const Configitem_t cfgtab_atmega16hva2[9] = { +const Configitem cfgtab_atmega16hva2[9] = { {"sut", 8, _values_sut_atmega16hva2, "lfuse", 0, 0x07, 0, -1, "startup time"}, {"selfprgen", 2, _values_selfprgen_atmega16hva2, "lfuse", 0, 0x08, 3, -1, "self programming"}, {"dwen", 2, _values_dwen_atmega328, "lfuse", 0, 0x10, 4, -1, "debugWIRE"}, @@ -11073,7 +11073,7 @@ const Configitem_t cfgtab_atmega16hva2[9] = { }; // ATmega32HVBrevB -const Configitem_t cfgtab_atmega32hvbrevb[12] = { +const Configitem cfgtab_atmega32hvbrevb[12] = { {"cksel", 1, _values_cksel_atmega32hvbrevb, "lfuse", 0, 0x03, 0, 1, "oscillator"}, {"sut", 8, _values_sut_atmega32hvbrevb, "lfuse", 0, 0x1c, 2, 7, "startup time"}, {"spien", 2, _values_spien_atmega328, "lfuse", 0, 0x20, 5, 0, "serial programming"}, @@ -11089,7 +11089,7 @@ const Configitem_t cfgtab_atmega32hvbrevb[12] = { }; // ATmega64HVE -const Configitem_t cfgtab_atmega64hve[13] = { +const Configitem cfgtab_atmega64hve[13] = { {"cksel", 1, _values_cksel_atmega64hve, "lfuse", 0, 0x01, 0, -1, "oscillator"}, {"sut", 4, _values_sut_atmega64hve, "lfuse", 0, 0x06, 1, -1, "startup time"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x08, 3, -1, "clock prescaled"}, @@ -11106,7 +11106,7 @@ const Configitem_t cfgtab_atmega64hve[13] = { }; // ATmega328PB -const Configitem_t cfgtab_atmega328pb[15] = { +const Configitem cfgtab_atmega328pb[15] = { {"sut_cksel", 47, _values_sut_cksel_atmega328pb, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11125,7 +11125,7 @@ const Configitem_t cfgtab_atmega328pb[15] = { }; // ATmega8515 -const Configitem_t cfgtab_atmega8515[13] = { +const Configitem cfgtab_atmega8515[13] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, 0x21, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, 1, "brownout detection trigger level"}, @@ -11142,7 +11142,7 @@ const Configitem_t cfgtab_atmega8515[13] = { }; // ATtiny102 ATtiny104 -const Configitem_t cfgtab_attiny102[5] = { +const Configitem cfgtab_attiny102[5] = { {"rstdisbl", 2, _values_rstdisbl_attiny102, "fuse", 0, 0x01, 0, 1, "reset configuration"}, {"wdton", 2, _values_wdton_atmega328, "fuse", 0, 0x02, 1, 1, "watchdog timer"}, {"ckout", 2, _values_ckout_attiny102, "fuse", 0, 0x04, 2, 1, "clock output"}, @@ -11151,14 +11151,14 @@ const Configitem_t cfgtab_attiny102[5] = { }; // ATtiny28 -const Configitem_t cfgtab_attiny28[3] = { +const Configitem cfgtab_attiny28[3] = { {"cksel", 16, _values_cksel_attiny28, "fuse", 0, 0x0f, 0, 0x02, "clock source"}, {"intcap", 2, _values_intcap_attiny28, "fuse", 0, 0x10, 4, 1, "internal load capacitors between XTAL1/XTAL2 and GND"}, {"lb", 3, _values_lb_atmega328, "lock", 0, 0x06, 1, 3, "lock bits"}, }; // ATtiny441 ATtiny841 -const Configitem_t cfgtab_attiny441[14] = { +const Configitem cfgtab_attiny441[14] = { {"sut_cksel", 17, _values_sut_cksel_attiny441, "lfuse", 0, 0x1f, 0, 0x02, "clock source"}, {"ckout", 2, _values_ckout_attiny441, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11176,7 +11176,7 @@ const Configitem_t cfgtab_attiny441[14] = { }; // AT90PWM2 AT90PWM3 -const Configitem_t cfgtab_at90pwm2[18] = { +const Configitem cfgtab_at90pwm2[18] = { {"sut_cksel", 42, _values_sut_cksel_at90pwm2, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11198,7 +11198,7 @@ const Configitem_t cfgtab_at90pwm2[18] = { }; // AT90PWM81 AT90PWM161 -const Configitem_t cfgtab_at90pwm81[19] = { +const Configitem cfgtab_at90pwm81[19] = { {"sut_cksel", 56, _values_sut_cksel_at90pwm81, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega16m1, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11221,7 +11221,7 @@ const Configitem_t cfgtab_at90pwm81[19] = { }; // AT90CAN128 -const Configitem_t cfgtab_at90can128[15] = { +const Configitem cfgtab_at90can128[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11240,7 +11240,7 @@ const Configitem_t cfgtab_at90can128[15] = { }; // AT90USB162 ATmega16U2 AT90USB82 -const Configitem_t cfgtab_at90usb162[15] = { +const Configitem cfgtab_at90usb162[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x1e, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11259,21 +11259,21 @@ const Configitem_t cfgtab_at90usb162[15] = { }; // AT90S1200 -const Configitem_t cfgtab_at90s1200[3] = { +const Configitem cfgtab_at90s1200[3] = { {"rcen", 2, _values_rcen_at90s1200, "fuse", 0, 0x01, 0, 1, "clock source"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, 0, "serial programming"}, {"lb", 3, _values_lb_atmega328, "lock", 0, 0x06, 1, 3, "lock bits"}, }; // AT90S2313 AT90S4414 AT90S4434 AT90S8515 AT90S8535 -const Configitem_t cfgtab_at90s2313[3] = { +const Configitem cfgtab_at90s2313[3] = { {"fstrt", 2, _values_fstrt_at90s2313, "fuse", 0, 0x01, 0, 1, "startup time"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, 0, "serial programming"}, {"lb", 3, _values_lb_atmega328, "lock", 0, 0x06, 1, 3, "lock bits"}, }; // ATA5700M322 ATA5702M322 -const Configitem_t cfgtab_ata5700m322[9] = { +const Configitem cfgtab_ata5700m322[9] = { {"pcee1", 2, _values_pcee1_ata5700m322, "fuse", 0, 0x01, 0, 1, "protect customer EEPROM section"}, {"eeacc", 2, _values_eeacc_ata5700m322, "fuse", 0, 0x02, 1, 1, "EEPROM access control"}, {"bootrst", 2, _values_bootrst_atmega328, "fuse", 0, 0x04, 2, 1, "reset address"}, @@ -11286,7 +11286,7 @@ const Configitem_t cfgtab_ata5700m322[9] = { }; // ATA5781 ATA5782 ATA5783 ATA5831 ATA5832 ATA5833 ATA8210 ATA8215 ATA8510 ATA8515 -const Configitem_t cfgtab_ata5781[11] = { +const Configitem cfgtab_ata5781[11] = { {"extclken", 2, _values_extclken_ata5781, "fuse", 0, 0x01, 0, 1, "external clock"}, {"rstdisbl", 2, _values_rstdisbl_attiny102, "fuse", 0, 0x02, 1, 1, "reset configuration"}, {"bootrst", 2, _values_bootrst_atmega328, "fuse", 0, 0x04, 2, 1, "reset address"}, @@ -11301,7 +11301,7 @@ const Configitem_t cfgtab_ata5781[11] = { }; // ATA5790 ATA5791 -const Configitem_t cfgtab_ata5790[11] = { +const Configitem cfgtab_ata5790[11] = { {"extclken", 2, _values_extclken_ata5781, "fuse", 0, 0x01, 0, 1, "external clock"}, {"_32oen", 2, _values__32oen_ata5790, "fuse", 0, 0x02, 1, 0, "32 kHz oscillator"}, {"reserved", 1, _values_reserved_ata5790, "fuse", 0, 0x04, 2, 0, "bit must be programmed"}, @@ -11316,7 +11316,7 @@ const Configitem_t cfgtab_ata5790[11] = { }; // ATA6285 ATA6286 -const Configitem_t cfgtab_ata6285[17] = { +const Configitem cfgtab_ata6285[17] = { {"tsrdi", 2, _values_tsrdi_ata6285, "lfuse", 0, 0x01, 0, 1, "temperature shutdown reset"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x02, 1, 0, "brownout detection"}, {"frcfs", 2, _values_frcfs_ata6285, "lfuse", 0, 0x04, 2, 0, "fast RC oscillator frequency"}, @@ -11337,7 +11337,7 @@ const Configitem_t cfgtab_ata6285[17] = { }; // ATxmega16E5 ATxmega8E5 ATxmega32E5 -const Configitem_t cfgtab_atxmega16e5[17] = { +const Configitem cfgtab_atxmega16e5[17] = { {"wdper", 11, _values_wdper_atxmega16e5, "fuse1", 1, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdwper", 11, _values_wdwper_atxmega16e5, "fuse1", 1, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodpd", 3, _values_bodpd_atxmega16e5, "fuse2", 2, 0x03, 0, 3, "brownout detection in power-down mode"}, @@ -11361,7 +11361,7 @@ const Configitem_t cfgtab_atxmega16e5[17] = { * ATxmega128A3 ATxmega64A1 ATxmega64A3 ATxmega128A1 ATxmega128A1revD ATxmega192A3 ATxmega256A3 * ATxmega256A3B */ -const Configitem_t cfgtab_atxmega128a3[16] = { +const Configitem cfgtab_atxmega128a3[16] = { {"jtaguserid", 0, NULL, "fuse0", 0, 0xff, 0, 0xff, "JTAG User ID"}, {"wdper", 11, _values_wdper_atxmega16e5, "fuse1", 1, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdwper", 11, _values_wdwper_atxmega16e5, "fuse1", 1, 0xf0, 4, 0x00, "watchdog window timeout period"}, @@ -11384,7 +11384,7 @@ const Configitem_t cfgtab_atxmega128a3[16] = { * ATxmega128A3U ATxmega16A4U ATxmega32A4U ATxmega64A1U ATxmega64A3U ATxmega64A4U ATxmega128A1U * ATxmega128A4U ATxmega192A3U ATxmega256A3BU ATxmega256A3U */ -const Configitem_t cfgtab_atxmega128a3u[17] = { +const Configitem cfgtab_atxmega128a3u[17] = { {"jtaguid", 0, NULL, "fuse0", 0, 0xff, 0, 0xff, "JTAG User ID"}, {"wdper", 11, _values_wdper_atxmega16e5, "fuse1", 1, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdwper", 11, _values_wdwper_atxmega16e5, "fuse1", 1, 0xf0, 4, 0x00, "watchdog window timeout period"}, @@ -11409,7 +11409,7 @@ const Configitem_t cfgtab_atxmega128a3u[17] = { * ATtiny416 ATtiny417 ATtiny814 ATtiny816 ATtiny817 ATtiny1614 ATtiny1616 ATtiny1617 ATtiny3216 * ATtiny3217 */ -const Configitem_t cfgtab_attiny204[23] = { +const Configitem cfgtab_attiny204[23] = { {"wdtperiod", 12, _values_wdtperiod_attiny204, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_attiny204, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_attiny204, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -11439,7 +11439,7 @@ const Configitem_t cfgtab_attiny204[23] = { * ATtiny1624 ATtiny424 ATtiny426 ATtiny427 ATtiny824 ATtiny826 ATtiny827 ATtiny1626 ATtiny1627 * ATtiny3224 ATtiny3226 ATtiny3227 */ -const Configitem_t cfgtab_attiny1624[16] = { +const Configitem cfgtab_attiny1624[16] = { {"wdtperiod", 12, _values_wdtperiod_attiny204, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_attiny204, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_attiny204, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -11462,7 +11462,7 @@ const Configitem_t cfgtab_attiny1624[16] = { * AVR32DD14 AVR16DD14 AVR16DD20 AVR16DD28 AVR16DD32 AVR32DD20 AVR32DD28 AVR32DD32 AVR64DD14 * AVR64DD20 AVR64DD28 AVR64DD32 */ -const Configitem_t cfgtab_avr32dd14[17] = { +const Configitem cfgtab_avr32dd14[17] = { {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_avr32dd14, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_avr32dd14, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -11483,7 +11483,7 @@ const Configitem_t cfgtab_avr32dd14[17] = { }; // AVR64EA48 AVR16EA28 AVR16EA32 AVR16EA48 AVR32EA28 AVR32EA32 AVR32EA48 AVR64EA28 AVR64EA32 -const Configitem_t cfgtab_avr64ea48[16] = { +const Configitem cfgtab_avr64ea48[16] = { {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_avr32dd14, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_avr32dd14, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -11503,7 +11503,7 @@ const Configitem_t cfgtab_avr64ea48[16] = { }; // ATmega103comp -const Configitem_t cfgtab_atmega103comp[15] = { +const Configitem cfgtab_atmega103comp[15] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, -1, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, -1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, -1, "brownout detection trigger level"}, @@ -11522,7 +11522,7 @@ const Configitem_t cfgtab_atmega103comp[15] = { }; // AT90SCR100H AT90SCR100 -const Configitem_t cfgtab_at90scr100h[13] = { +const Configitem cfgtab_at90scr100h[13] = { {"sut_cksel", 14, _values_sut_cksel_at90scr100h, "lfuse", 0, 0x39, 0, -1, "clock source"}, {"ckout", 2, _values_ckout_at90scr100h, "lfuse", 0, 0x40, 6, -1, "clock output"}, {"bootrst", 2, _values_bootrst_atmega328, "hfuse", 1, 0x01, 0, -1, "reset address"}, @@ -11539,7 +11539,7 @@ const Configitem_t cfgtab_at90scr100h[13] = { }; // ATmega161comp -const Configitem_t cfgtab_atmega161comp[15] = { +const Configitem cfgtab_atmega161comp[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, -1, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, -1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, -1, "clock prescaled"}, @@ -11558,7 +11558,7 @@ const Configitem_t cfgtab_atmega161comp[15] = { }; // AT90S8535comp -const Configitem_t cfgtab_at90s8535comp[13] = { +const Configitem cfgtab_at90s8535comp[13] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, -1, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, -1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, -1, "brownout detection trigger level"}, @@ -11575,7 +11575,7 @@ const Configitem_t cfgtab_at90s8535comp[13] = { }; // ATtiny4 ATtiny5 ATtiny9 ATtiny10 -const Configitem_t cfgtab_attiny4[4] = { +const Configitem cfgtab_attiny4[4] = { {"rstdisbl", 2, _values_rstdisbl_attiny102, "fuse", 0, 0x01, 0, 1, "reset configuration"}, {"wdton", 2, _values_wdton_atmega328, "fuse", 0, 0x02, 1, 1, "watchdog timer"}, {"ckout", 2, _values_ckout_attiny102, "fuse", 0, 0x04, 2, 1, "clock output"}, @@ -11583,7 +11583,7 @@ const Configitem_t cfgtab_attiny4[4] = { }; // ATtiny20 ATtiny40 -const Configitem_t cfgtab_attiny20[5] = { +const Configitem cfgtab_attiny20[5] = { {"rstdisbl", 2, _values_rstdisbl_attiny102, "fuse", 0, 0x01, 0, 1, "reset configuration"}, {"wdton", 2, _values_wdton_atmega328, "fuse", 0, 0x02, 1, 1, "watchdog timer"}, {"ckout", 2, _values_ckout_attiny102, "fuse", 0, 0x04, 2, 1, "clock output"}, @@ -11592,7 +11592,7 @@ const Configitem_t cfgtab_attiny20[5] = { }; // ATtiny11 -const Configitem_t cfgtab_attiny11[4] = { +const Configitem cfgtab_attiny11[4] = { {"cksel", 5, _values_cksel_attiny11, "fuse", 0, 0x07, 0, 4, "clock source"}, {"rstdisbl", 2, _values_rstdisbl_attiny11, "fuse", 0, 0x08, 3, 0, "reset configuration"}, {"fstrt", 2, _values_fstrt_at90s2313, "fuse", 0, 0x10, 4, 1, "startup time"}, @@ -11600,7 +11600,7 @@ const Configitem_t cfgtab_attiny11[4] = { }; // ATtiny12 -const Configitem_t cfgtab_attiny12[6] = { +const Configitem cfgtab_attiny12[6] = { {"cksel", 16, _values_cksel_attiny28, "fuse", 0, 0x0f, 0, 0x02, "clock source"}, {"rstdisbl", 2, _values_rstdisbl_attiny11, "fuse", 0, 0x10, 4, 1, "reset configuration"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, 0, "serial programming"}, @@ -11610,7 +11610,7 @@ const Configitem_t cfgtab_attiny12[6] = { }; // ATtiny13 ATtiny13A -const Configitem_t cfgtab_attiny13[10] = { +const Configitem cfgtab_attiny13[10] = { {"sut_cksel", 12, _values_sut_cksel_attiny13, "lfuse", 0, 0x0f, 0, 0x0a, "clock source"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x10, 4, 0, "clock prescaled"}, {"wdton", 2, _values_wdton_atmega328, "lfuse", 0, 0x20, 5, 1, "watchdog timer"}, @@ -11624,7 +11624,7 @@ const Configitem_t cfgtab_attiny13[10] = { }; // ATtiny15 -const Configitem_t cfgtab_attiny15[6] = { +const Configitem cfgtab_attiny15[6] = { {"cksel", 4, _values_cksel_attiny15, "fuse", 0, 0x03, 0, 0, "clock source"}, {"rstdisbl", 2, _values_rstdisbl_attiny11, "fuse", 0, 0x10, 4, 1, "reset configuration"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, 0, "serial programming"}, @@ -11634,14 +11634,14 @@ const Configitem_t cfgtab_attiny15[6] = { }; // ATtiny22 -const Configitem_t cfgtab_attiny22[3] = { +const Configitem cfgtab_attiny22[3] = { {"cksel", 2, _values_cksel_at90s1200, "fuse", 0, 0x01, 0, -1, "clock source"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, -1, "serial programming"}, {"lb", 3, _values_lb_atmega328, "lock", 0, 0x06, 1, 3, "lock bits"}, }; // ATtiny24 ATtiny24A ATtiny44 ATtiny44A ATtiny84 ATtiny84A -const Configitem_t cfgtab_attiny24[11] = { +const Configitem cfgtab_attiny24[11] = { {"sut_cksel", 44, _values_sut_cksel_attiny24, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_attiny24, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11656,7 +11656,7 @@ const Configitem_t cfgtab_attiny24[11] = { }; // ATtiny25 ATtiny45 ATtiny85 -const Configitem_t cfgtab_attiny25[11] = { +const Configitem cfgtab_attiny25[11] = { {"sut_cksel", 51, _values_sut_cksel_attiny25, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_attiny25, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11671,7 +11671,7 @@ const Configitem_t cfgtab_attiny25[11] = { }; // ATtiny26 -const Configitem_t cfgtab_attiny26[8] = { +const Configitem cfgtab_attiny26[8] = { {"ckopt", 2, _values_ckopt_attiny26, "lfuse", 0, 0x40, 6, 1, "internal capacitors on XTAL1 and XTAL2"}, {"sut_cksel", 62, _values_sut_cksel_attiny26, "lfuse", 0, 0xbf, 0, 0xa1, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "hfuse", 1, 0x01, 0, 1, "brownout detection"}, @@ -11683,7 +11683,7 @@ const Configitem_t cfgtab_attiny26[8] = { }; // ATtiny43U ATtiny261 ATtiny261A ATtiny461 ATtiny461A ATtiny861 ATtiny861A -const Configitem_t cfgtab_attiny43u[11] = { +const Configitem cfgtab_attiny43u[11] = { {"sut_cksel", 48, _values_sut_cksel_attiny43u, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_attiny43u, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11698,7 +11698,7 @@ const Configitem_t cfgtab_attiny43u[11] = { }; // ATtiny48 ATtiny88 -const Configitem_t cfgtab_attiny48[11] = { +const Configitem cfgtab_attiny48[11] = { {"sut_cksel", 9, _values_sut_cksel_attiny48, "lfuse", 0, 0x3f, 0, 0x2e, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11713,7 +11713,7 @@ const Configitem_t cfgtab_attiny48[11] = { }; // ATtiny87 ATtiny167 ATA5272 ATA5505 ATA6616C ATA6617C ATA664251 -const Configitem_t cfgtab_attiny87[11] = { +const Configitem cfgtab_attiny87[11] = { {"sut_cksel", 44, _values_sut_cksel_attiny87, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_attiny43u, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11728,7 +11728,7 @@ const Configitem_t cfgtab_attiny87[11] = { }; // ATtiny828 ATtiny828R -const Configitem_t cfgtab_attiny828[16] = { +const Configitem cfgtab_attiny828[16] = { {"sut_cksel", 16, _values_sut_cksel_attiny828, "lfuse", 0, 0x33, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11748,7 +11748,7 @@ const Configitem_t cfgtab_attiny828[16] = { }; // ATtiny1634 ATtiny1634R -const Configitem_t cfgtab_attiny1634[13] = { +const Configitem cfgtab_attiny1634[13] = { {"sut_cksel", 15, _values_sut_cksel_attiny1634, "lfuse", 0, 0x1f, 0, 0x02, "clock source"}, {"ckout", 2, _values_ckout_attiny441, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11765,7 +11765,7 @@ const Configitem_t cfgtab_attiny1634[13] = { }; // ATtiny2313 -const Configitem_t cfgtab_attiny2313[11] = { +const Configitem cfgtab_attiny2313[11] = { {"sut_cksel", 44, _values_sut_cksel_attiny2313, "lfuse", 0, 0x3f, 0, 0x24, "clock source"}, {"ckout", 2, _values_ckout_attiny2313, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11780,7 +11780,7 @@ const Configitem_t cfgtab_attiny2313[11] = { }; // ATtiny2313A ATtiny4313 -const Configitem_t cfgtab_attiny2313a[11] = { +const Configitem cfgtab_attiny2313a[11] = { {"sut_cksel", 44, _values_sut_cksel_attiny2313, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_attiny2313, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11795,7 +11795,7 @@ const Configitem_t cfgtab_attiny2313a[11] = { }; // ATmega8 ATmega8A -const Configitem_t cfgtab_atmega8[13] = { +const Configitem cfgtab_atmega8[13] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, 0x21, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, 1, "brownout detection trigger level"}, @@ -11812,7 +11812,7 @@ const Configitem_t cfgtab_atmega8[13] = { }; // ATmega8HVA ATmega16HVA -const Configitem_t cfgtab_atmega8hva[7] = { +const Configitem cfgtab_atmega8hva[7] = { {"sut", 8, _values_sut_atmega16hva2, "fuse", 0, 0x07, 0, 7, "startup time"}, {"selfprgen", 2, _values_selfprgen_atmega16hva2, "fuse", 0, 0x08, 3, 1, "self programming"}, {"dwen", 2, _values_dwen_atmega328, "fuse", 0, 0x10, 4, 1, "debugWIRE"}, @@ -11823,7 +11823,7 @@ const Configitem_t cfgtab_atmega8hva[7] = { }; // ATmega8U2 -const Configitem_t cfgtab_atmega8u2[15] = { +const Configitem cfgtab_atmega8u2[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x1e, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11842,7 +11842,7 @@ const Configitem_t cfgtab_atmega8u2[15] = { }; // ATmega16 ATmega16A -const Configitem_t cfgtab_atmega16[13] = { +const Configitem cfgtab_atmega16[13] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, 0x21, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, 1, "brownout detection trigger level"}, @@ -11859,7 +11859,7 @@ const Configitem_t cfgtab_atmega16[13] = { }; // ATmega16HVB -const Configitem_t cfgtab_atmega16hvb[12] = { +const Configitem cfgtab_atmega16hvb[12] = { {"cksel", 1, _values_cksel_atmega32hvbrevb, "lfuse", 0, 0x03, 0, 1, "oscillator"}, {"sut", 8, _values_sut_atmega32hvbrevb, "lfuse", 0, 0x1c, 2, 7, "startup time"}, {"spien", 2, _values_spien_atmega328, "lfuse", 0, 0x20, 5, 0, "serial programming"}, @@ -11875,7 +11875,7 @@ const Configitem_t cfgtab_atmega16hvb[12] = { }; // ATmega16HVBrevB -const Configitem_t cfgtab_atmega16hvbrevb[12] = { +const Configitem cfgtab_atmega16hvbrevb[12] = { {"cksel", 1, _values_cksel_atmega32hvbrevb, "lfuse", 0, 0x03, 0, 1, "oscillator"}, {"sut", 8, _values_sut_atmega32hvbrevb, "lfuse", 0, 0x1c, 2, 7, "startup time"}, {"spien", 2, _values_spien_atmega328, "lfuse", 0, 0x20, 5, 0, "serial programming"}, @@ -11891,7 +11891,7 @@ const Configitem_t cfgtab_atmega16hvbrevb[12] = { }; // ATmega16U4 -const Configitem_t cfgtab_atmega16u4[15] = { +const Configitem cfgtab_atmega16u4[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x12, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11910,7 +11910,7 @@ const Configitem_t cfgtab_atmega16u4[15] = { }; // ATmega32 ATmega32A -const Configitem_t cfgtab_atmega32[13] = { +const Configitem cfgtab_atmega32[13] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, 0x21, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, 1, "brownout detection trigger level"}, @@ -11927,7 +11927,7 @@ const Configitem_t cfgtab_atmega32[13] = { }; // ATmega32HVB -const Configitem_t cfgtab_atmega32hvb[12] = { +const Configitem cfgtab_atmega32hvb[12] = { {"cksel", 1, _values_cksel_atmega32hvbrevb, "lfuse", 0, 0x03, 0, 1, "oscillator"}, {"sut", 8, _values_sut_atmega32hvbrevb, "lfuse", 0, 0x1c, 2, 7, "startup time"}, {"spien", 2, _values_spien_atmega328, "lfuse", 0, 0x20, 5, 0, "serial programming"}, @@ -11943,7 +11943,7 @@ const Configitem_t cfgtab_atmega32hvb[12] = { }; // ATmega32C1 ATmega32M1 -const Configitem_t cfgtab_atmega32c1[17] = { +const Configitem cfgtab_atmega32c1[17] = { {"sut_cksel", 53, _values_sut_cksel_atmega16m1, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega16m1, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11964,7 +11964,7 @@ const Configitem_t cfgtab_atmega32c1[17] = { }; // ATmega32U2 -const Configitem_t cfgtab_atmega32u2[15] = { +const Configitem cfgtab_atmega32u2[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x1e, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -11983,7 +11983,7 @@ const Configitem_t cfgtab_atmega32u2[15] = { }; // ATmega32U4 -const Configitem_t cfgtab_atmega32u4[15] = { +const Configitem cfgtab_atmega32u4[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x12, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12002,7 +12002,7 @@ const Configitem_t cfgtab_atmega32u4[15] = { }; // ATmega32U6 -const Configitem_t cfgtab_atmega32u6[15] = { +const Configitem cfgtab_atmega32u6[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, -1, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, -1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, -1, "clock prescaled"}, @@ -12021,7 +12021,7 @@ const Configitem_t cfgtab_atmega32u6[15] = { }; // ATmega48 ATmega48A ATmega48P ATmega48PA -const Configitem_t cfgtab_atmega48[11] = { +const Configitem cfgtab_atmega48[11] = { {"sut_cksel", 55, _values_sut_cksel_atmega328, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12036,7 +12036,7 @@ const Configitem_t cfgtab_atmega48[11] = { }; // ATmega48PB -const Configitem_t cfgtab_atmega48pb[11] = { +const Configitem cfgtab_atmega48pb[11] = { {"sut_cksel", 47, _values_sut_cksel_atmega328pb, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12051,7 +12051,7 @@ const Configitem_t cfgtab_atmega48pb[11] = { }; // ATmega64 ATmega64A -const Configitem_t cfgtab_atmega64[15] = { +const Configitem cfgtab_atmega64[15] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, 0x21, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, 1, "brownout detection trigger level"}, @@ -12070,7 +12070,7 @@ const Configitem_t cfgtab_atmega64[15] = { }; // ATmega64C1 ATmega64M1 -const Configitem_t cfgtab_atmega64c1[17] = { +const Configitem cfgtab_atmega64c1[17] = { {"sut_cksel", 53, _values_sut_cksel_atmega16m1, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega16m1, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12091,7 +12091,7 @@ const Configitem_t cfgtab_atmega64c1[17] = { }; // ATmega64HVE2 ATmega32HVE2 -const Configitem_t cfgtab_atmega64hve2[13] = { +const Configitem cfgtab_atmega64hve2[13] = { {"cksel", 1, _values_cksel_atmega64hve, "lfuse", 0, 0x01, 0, 1, "oscillator"}, {"sut", 4, _values_sut_atmega64hve, "lfuse", 0, 0x06, 1, 3, "startup time"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x08, 3, 0, "clock prescaled"}, @@ -12108,7 +12108,7 @@ const Configitem_t cfgtab_atmega64hve2[13] = { }; // ATmega64RFR2 ATmega644RFR2 -const Configitem_t cfgtab_atmega64rfr2[14] = { +const Configitem cfgtab_atmega64rfr2[14] = { {"sut_cksel", 49, _values_sut_cksel_atmega64rfr2, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12126,7 +12126,7 @@ const Configitem_t cfgtab_atmega64rfr2[14] = { }; // ATmega88 ATmega88A ATmega88P ATmega88PA ATA6612C -const Configitem_t cfgtab_atmega88[14] = { +const Configitem cfgtab_atmega88[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega328, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12144,7 +12144,7 @@ const Configitem_t cfgtab_atmega88[14] = { }; // ATmega88PB -const Configitem_t cfgtab_atmega88pb[14] = { +const Configitem cfgtab_atmega88pb[14] = { {"sut_cksel", 47, _values_sut_cksel_atmega328pb, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12162,7 +12162,7 @@ const Configitem_t cfgtab_atmega88pb[14] = { }; // ATmega103 -const Configitem_t cfgtab_atmega103[4] = { +const Configitem cfgtab_atmega103[4] = { {"cksel", 4, _values_cksel_atmega103, "fuse", 0, 0x03, 0, 3, "clock source"}, {"eesave", 2, _values_eesave_atmega328, "fuse", 0, 0x08, 3, 1, "EEPROM after chip erase"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, 0, "serial programming"}, @@ -12170,7 +12170,7 @@ const Configitem_t cfgtab_atmega103[4] = { }; // ATmega128 ATmega128A -const Configitem_t cfgtab_atmega128[15] = { +const Configitem cfgtab_atmega128[15] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, 0x21, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, 1, "brownout detection trigger level"}, @@ -12189,7 +12189,7 @@ const Configitem_t cfgtab_atmega128[15] = { }; // ATmega128RFA1 -const Configitem_t cfgtab_atmega128rfa1[14] = { +const Configitem cfgtab_atmega128rfa1[14] = { {"sut_cksel", 17, _values_sut_cksel_atmega128rfa1, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12207,7 +12207,7 @@ const Configitem_t cfgtab_atmega128rfa1[14] = { }; // ATmega128RFR2 ATmega1284RFR2 -const Configitem_t cfgtab_atmega128rfr2[14] = { +const Configitem cfgtab_atmega128rfr2[14] = { {"sut_cksel", 49, _values_sut_cksel_atmega64rfr2, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12225,7 +12225,7 @@ const Configitem_t cfgtab_atmega128rfr2[14] = { }; // ATmega161 -const Configitem_t cfgtab_atmega161[7] = { +const Configitem cfgtab_atmega161[7] = { {"cksel", 8, _values_cksel_atmega161, "fuse", 0, 0x07, 0, 2, "clock source"}, {"sut", 2, _values_sut_atmega161, "fuse", 0, 0x10, 4, 1, "startup time"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, 0, "serial programming"}, @@ -12236,7 +12236,7 @@ const Configitem_t cfgtab_atmega161[7] = { }; // ATmega162 -const Configitem_t cfgtab_atmega162[15] = { +const Configitem cfgtab_atmega162[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12255,7 +12255,7 @@ const Configitem_t cfgtab_atmega162[15] = { }; // ATmega163 -const Configitem_t cfgtab_atmega163[9] = { +const Configitem cfgtab_atmega163[9] = { {"cksel", 16, _values_cksel_atmega163, "lfuse", 0, 0x0f, 0, 0x0f, "clock source"}, {"spien", 2, _values_spien_atmega328, "lfuse", 0, 0x20, 5, 0, "serial programming"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, @@ -12268,7 +12268,7 @@ const Configitem_t cfgtab_atmega163[9] = { }; // ATmega164A ATmega164P ATmega164PA -const Configitem_t cfgtab_atmega164a[14] = { +const Configitem cfgtab_atmega164a[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega164a, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_at90scr100h, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12286,7 +12286,7 @@ const Configitem_t cfgtab_atmega164a[14] = { }; // ATmega165 ATmega165A ATmega165P ATmega165PA ATmega169 ATmega169A ATmega169P ATmega169PA -const Configitem_t cfgtab_atmega165[15] = { +const Configitem cfgtab_atmega165[15] = { {"sut_cksel", 44, _values_sut_cksel_atmega165, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12305,7 +12305,7 @@ const Configitem_t cfgtab_atmega165[15] = { }; // ATmega168 ATmega168A ATmega168P ATmega168PA ATA6613C -const Configitem_t cfgtab_atmega168[14] = { +const Configitem cfgtab_atmega168[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega328, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12323,7 +12323,7 @@ const Configitem_t cfgtab_atmega168[14] = { }; // ATmega168PB -const Configitem_t cfgtab_atmega168pb[14] = { +const Configitem cfgtab_atmega168pb[14] = { {"sut_cksel", 47, _values_sut_cksel_atmega328pb, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12341,7 +12341,7 @@ const Configitem_t cfgtab_atmega168pb[14] = { }; // ATmega256RFR2 ATmega2564RFR2 -const Configitem_t cfgtab_atmega256rfr2[14] = { +const Configitem cfgtab_atmega256rfr2[14] = { {"sut_cksel", 49, _values_sut_cksel_atmega64rfr2, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12359,7 +12359,7 @@ const Configitem_t cfgtab_atmega256rfr2[14] = { }; // ATmega323 -const Configitem_t cfgtab_atmega323[12] = { +const Configitem cfgtab_atmega323[12] = { {"cksel", 16, _values_cksel_atmega163, "lfuse", 0, 0x0f, 0, 0x02, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, 1, "brownout detection trigger level"}, @@ -12375,7 +12375,7 @@ const Configitem_t cfgtab_atmega323[12] = { }; // ATmega324A ATmega324P ATmega324PA -const Configitem_t cfgtab_atmega324a[14] = { +const Configitem cfgtab_atmega324a[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega164a, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_at90scr100h, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12393,7 +12393,7 @@ const Configitem_t cfgtab_atmega324a[14] = { }; // ATmega324PB -const Configitem_t cfgtab_atmega324pb[15] = { +const Configitem cfgtab_atmega324pb[15] = { {"sut_cksel", 47, _values_sut_cksel_atmega328pb, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_at90scr100h, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12415,7 +12415,7 @@ const Configitem_t cfgtab_atmega324pb[15] = { * ATmega325 ATmega325A ATmega325P ATmega325PA ATmega329 ATmega329A ATmega329P ATmega329PA * ATmega3250 ATmega3250A ATmega3250P ATmega3250PA ATmega3290 ATmega3290A ATmega3290P ATmega3290PA */ -const Configitem_t cfgtab_atmega325[15] = { +const Configitem cfgtab_atmega325[15] = { {"sut_cksel", 44, _values_sut_cksel_atmega165, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12434,7 +12434,7 @@ const Configitem_t cfgtab_atmega325[15] = { }; // ATmega406 -const Configitem_t cfgtab_atmega406[10] = { +const Configitem cfgtab_atmega406[10] = { {"sut_cksel", 6, _values_sut_cksel_atmega406, "lfuse", 0, 0x07, 0, 5, "clock source"}, {"bootrst", 2, _values_bootrst_atmega328, "lfuse", 0, 0x08, 3, 1, "reset address"}, {"bootsz", 4, _values_bootsz_atmega406, "lfuse", 0, 0x30, 4, 0, "boot section size"}, @@ -12448,7 +12448,7 @@ const Configitem_t cfgtab_atmega406[10] = { }; // ATmega640 -const Configitem_t cfgtab_atmega640[14] = { +const Configitem cfgtab_atmega640[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega164a, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12466,7 +12466,7 @@ const Configitem_t cfgtab_atmega640[14] = { }; // ATmega644 ATmega644A ATmega644P ATmega644PA -const Configitem_t cfgtab_atmega644[14] = { +const Configitem cfgtab_atmega644[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega164a, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_at90scr100h, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12487,7 +12487,7 @@ const Configitem_t cfgtab_atmega644[14] = { * ATmega645 ATmega645A ATmega645P ATmega649 ATmega649A ATmega649P ATmega6450 ATmega6450A * ATmega6450P ATmega6490 ATmega6490A ATmega6490P */ -const Configitem_t cfgtab_atmega645[15] = { +const Configitem cfgtab_atmega645[15] = { {"sut_cksel", 44, _values_sut_cksel_atmega165, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12506,7 +12506,7 @@ const Configitem_t cfgtab_atmega645[15] = { }; // ATmega1280 ATmega1281 -const Configitem_t cfgtab_atmega1280[14] = { +const Configitem cfgtab_atmega1280[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega164a, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12524,7 +12524,7 @@ const Configitem_t cfgtab_atmega1280[14] = { }; // ATmega1284 ATmega1284P -const Configitem_t cfgtab_atmega1284[14] = { +const Configitem cfgtab_atmega1284[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega164a, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_at90scr100h, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12542,7 +12542,7 @@ const Configitem_t cfgtab_atmega1284[14] = { }; // ATmega2560 ATmega2561 -const Configitem_t cfgtab_atmega2560[14] = { +const Configitem cfgtab_atmega2560[14] = { {"sut_cksel", 55, _values_sut_cksel_atmega164a, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega64rfr2, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12560,7 +12560,7 @@ const Configitem_t cfgtab_atmega2560[14] = { }; // ATmega8535 -const Configitem_t cfgtab_atmega8535[13] = { +const Configitem cfgtab_atmega8535[13] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, 0x21, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, 1, "brownout detection trigger level"}, @@ -12577,7 +12577,7 @@ const Configitem_t cfgtab_atmega8535[13] = { }; // AT90PWM1 -const Configitem_t cfgtab_at90pwm1[17] = { +const Configitem cfgtab_at90pwm1[17] = { {"sut_cksel", 42, _values_sut_cksel_at90pwm2, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12598,7 +12598,7 @@ const Configitem_t cfgtab_at90pwm1[17] = { }; // AT90PWM2B AT90PWM3B -const Configitem_t cfgtab_at90pwm2b[18] = { +const Configitem cfgtab_at90pwm2b[18] = { {"sut_cksel", 53, _values_sut_cksel_atmega16m1, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12620,7 +12620,7 @@ const Configitem_t cfgtab_at90pwm2b[18] = { }; // AT90CAN32 -const Configitem_t cfgtab_at90can32[15] = { +const Configitem cfgtab_at90can32[15] = { {"sut_cksel", 38, _values_sut_cksel_at90can32, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12639,7 +12639,7 @@ const Configitem_t cfgtab_at90can32[15] = { }; // AT90CAN64 -const Configitem_t cfgtab_at90can64[15] = { +const Configitem cfgtab_at90can64[15] = { {"sut_cksel", 38, _values_sut_cksel_at90can32, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12658,7 +12658,7 @@ const Configitem_t cfgtab_at90can64[15] = { }; // AT90PWM216 -const Configitem_t cfgtab_at90pwm216[18] = { +const Configitem cfgtab_at90pwm216[18] = { {"sut_cksel", 42, _values_sut_cksel_at90pwm2, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12680,7 +12680,7 @@ const Configitem_t cfgtab_at90pwm216[18] = { }; // AT90PWM316 -const Configitem_t cfgtab_at90pwm316[18] = { +const Configitem cfgtab_at90pwm316[18] = { {"sut_cksel", 53, _values_sut_cksel_atmega16m1, "lfuse", 0, 0x3f, 0, 0x22, "clock source"}, {"ckout", 2, _values_ckout_atmega328, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12702,7 +12702,7 @@ const Configitem_t cfgtab_at90pwm316[18] = { }; // AT90USB646 AT90USB647 -const Configitem_t cfgtab_at90usb646[15] = { +const Configitem cfgtab_at90usb646[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x1e, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12721,7 +12721,7 @@ const Configitem_t cfgtab_at90usb646[15] = { }; // AT90USB1286 AT90USB1287 -const Configitem_t cfgtab_at90usb1286[15] = { +const Configitem cfgtab_at90usb1286[15] = { {"sut_cksel", 50, _values_sut_cksel_at90can128, "lfuse", 0, 0x3f, 0, 0x1e, "clock source"}, {"ckout", 2, _values_ckout_at90can128, "lfuse", 0, 0x40, 6, 1, "clock output"}, {"ckdiv8", 2, _values_ckdiv8_atmega328, "lfuse", 0, 0x80, 7, 0, "clock prescaled"}, @@ -12740,14 +12740,14 @@ const Configitem_t cfgtab_at90usb1286[15] = { }; // AT90S2323 -const Configitem_t cfgtab_at90s2323[3] = { +const Configitem cfgtab_at90s2323[3] = { {"fstrt", 2, _values_fstrt_at90s2313, "fuse", 0, 0x01, 0, 0, "startup time"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, 0, "serial programming"}, {"lb", 3, _values_lb_atmega328, "lock", 0, 0x06, 1, 3, "lock bits"}, }; // AT90S2333 -const Configitem_t cfgtab_at90s2333[5] = { +const Configitem cfgtab_at90s2333[5] = { {"sut_cksel", 8, _values_sut_cksel_at90s2333, "fuse", 0, 0x07, 0, -1, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "fuse", 0, 0x08, 3, -1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "fuse", 0, 0x10, 4, -1, "brownout detection trigger level"}, @@ -12756,14 +12756,14 @@ const Configitem_t cfgtab_at90s2333[5] = { }; // AT90S2343 -const Configitem_t cfgtab_at90s2343[3] = { +const Configitem cfgtab_at90s2343[3] = { {"rcen", 2, _values_rcen_at90s1200, "fuse", 0, 0x01, 0, 0, "clock source"}, {"spien", 2, _values_spien_atmega328, "fuse", 0, 0x20, 5, 0, "serial programming"}, {"lb", 3, _values_lb_atmega328, "lock", 0, 0x06, 1, 3, "lock bits"}, }; // AT90S4433 -const Configitem_t cfgtab_at90s4433[5] = { +const Configitem cfgtab_at90s4433[5] = { {"sut_cksel", 8, _values_sut_cksel_at90s2333, "fuse", 0, 0x07, 0, 2, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "fuse", 0, 0x08, 3, 1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "fuse", 0, 0x10, 4, 1, "brownout detection trigger level"}, @@ -12772,7 +12772,7 @@ const Configitem_t cfgtab_at90s4433[5] = { }; // AT90S8515comp -const Configitem_t cfgtab_at90s8515comp[13] = { +const Configitem cfgtab_at90s8515comp[13] = { {"sut_cksel", 58, _values_sut_cksel_atmega8515, "lfuse", 0, 0x3f, 0, -1, "clock source"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x40, 6, -1, "brownout detection"}, {"bodlevel", 2, _values_bodlevel_atmega8515, "lfuse", 0, 0x80, 7, -1, "brownout detection trigger level"}, @@ -12789,7 +12789,7 @@ const Configitem_t cfgtab_at90s8515comp[13] = { }; // ATA5787 ATA5835 -const Configitem_t cfgtab_ata5787[11] = { +const Configitem cfgtab_ata5787[11] = { {"extclken", 2, _values_extclken_ata5781, "fuse", 0, 0x01, 0, 1, "external clock"}, {"rstdisbl", 2, _values_rstdisbl_attiny102, "fuse", 0, 0x02, 1, 1, "reset configuration"}, {"bootrst", 2, _values_bootrst_atmega328, "fuse", 0, 0x04, 2, 1, "reset address"}, @@ -12804,7 +12804,7 @@ const Configitem_t cfgtab_ata5787[11] = { }; // ATA5790N ATA5795 -const Configitem_t cfgtab_ata5790n[10] = { +const Configitem cfgtab_ata5790n[10] = { {"_32oen", 2, _values__32oen_ata5790, "fuse", 0, 0x02, 1, 0, "32 kHz oscillator"}, {"reserved", 1, _values_reserved_ata5790, "fuse", 0, 0x04, 2, 0, "bit must be programmed"}, {"eesave", 2, _values_eesave_atmega328, "fuse", 0, 0x08, 3, 1, "EEPROM after chip erase"}, @@ -12818,7 +12818,7 @@ const Configitem_t cfgtab_ata5790n[10] = { }; // ATA6289 -const Configitem_t cfgtab_ata6289[17] = { +const Configitem cfgtab_ata6289[17] = { {"tsrdi", 2, _values_tsrdi_ata6285, "lfuse", 0, 0x01, 0, -1, "temperature shutdown reset"}, {"boden", 2, _values_boden_atmega64hve, "lfuse", 0, 0x02, 1, -1, "brownout detection"}, {"frcfs", 2, _values_frcfs_ata6285, "lfuse", 0, 0x04, 2, -1, "fast RC oscillator frequency"}, @@ -12839,7 +12839,7 @@ const Configitem_t cfgtab_ata6289[17] = { }; // ATxmega16A4 ATxmega32A4 -const Configitem_t cfgtab_atxmega16a4[16] = { +const Configitem cfgtab_atxmega16a4[16] = { {"jtaguserid", 0, NULL, "fuse0", 0, 0xff, 0, 0xff, "JTAG User ID"}, {"wdper", 11, _values_wdper_atxmega16e5, "fuse1", 1, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdwper", 11, _values_wdwper_atxmega16e5, "fuse1", 1, 0xf0, 4, 0x00, "watchdog window timeout period"}, @@ -12863,7 +12863,7 @@ const Configitem_t cfgtab_atxmega16a4[16] = { * ATxmega64D4 ATxmega128C3 ATxmega128D3 ATxmega128D4 ATxmega192C3 ATxmega192D3 ATxmega256C3 * ATxmega256D3 ATxmega384C3 ATxmega384D3 */ -const Configitem_t cfgtab_atxmega16c4[15] = { +const Configitem cfgtab_atxmega16c4[15] = { {"wdper", 11, _values_wdper_atxmega16e5, "fuse1", 1, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdwper", 11, _values_wdwper_atxmega16e5, "fuse1", 1, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodpd", 3, _values_bodpd_atxmega16e5, "fuse2", 2, 0x03, 0, 3, "brownout detection in power-down mode"}, @@ -12882,7 +12882,7 @@ const Configitem_t cfgtab_atxmega16c4[15] = { }; // ATxmega64B1 ATxmega64B3 ATxmega128B1 ATxmega128B3 -const Configitem_t cfgtab_atxmega64b1[17] = { +const Configitem cfgtab_atxmega64b1[17] = { {"jtaguserid", 0, NULL, "fuse0", 0, 0xff, 0, 0xff, "JTAG User ID"}, {"wdper", 11, _values_wdper_atxmega16e5, "fuse1", 1, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdwper", 11, _values_wdwper_atxmega16e5, "fuse1", 1, 0xf0, 4, 0x00, "watchdog window timeout period"}, @@ -12903,7 +12903,7 @@ const Configitem_t cfgtab_atxmega64b1[17] = { }; // ATtiny416auto -const Configitem_t cfgtab_attiny416auto[23] = { +const Configitem cfgtab_attiny416auto[23] = { {"wdtperiod", 12, _values_wdtperiod_attiny204, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_attiny204, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_attiny204, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -12930,7 +12930,7 @@ const Configitem_t cfgtab_attiny416auto[23] = { }; // ATtiny804 ATtiny806 ATtiny807 ATtiny1604 ATtiny1606 ATtiny1607 -const Configitem_t cfgtab_attiny804[15] = { +const Configitem cfgtab_attiny804[15] = { {"wdtperiod", 12, _values_wdtperiod_attiny204, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_attiny204, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_attiny204, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -12949,7 +12949,7 @@ const Configitem_t cfgtab_attiny804[15] = { }; // ATmega808 ATmega809 ATmega1608 ATmega1609 ATmega3208 ATmega3209 ATmega4808 ATmega4809 -const Configitem_t cfgtab_atmega808[15] = { +const Configitem cfgtab_atmega808[15] = { {"wdtperiod", 12, _values_wdtperiod_attiny204, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_attiny204, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_attiny204, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -12971,7 +12971,7 @@ const Configitem_t cfgtab_atmega808[15] = { * AVR16DU14 AVR16DU20 AVR16DU28 AVR16DU32 AVR32DU14 AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 * AVR64DU32 */ -const Configitem_t cfgtab_avr16du14[20] = { +const Configitem cfgtab_avr16du14[20] = { {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_avr32dd14, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_avr32dd14, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -12995,7 +12995,7 @@ const Configitem_t cfgtab_avr16du14[20] = { }; // AVR16EB14 AVR16EB20 AVR16EB28 AVR16EB32 -const Configitem_t cfgtab_avr16eb14[18] = { +const Configitem cfgtab_avr16eb14[18] = { {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_avr32dd14, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_avr32dd14, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -13020,7 +13020,7 @@ const Configitem_t cfgtab_avr16eb14[18] = { * AVR32DA28 AVR32DA32 AVR32DA48 AVR64DA28 AVR64DA32 AVR64DA48 AVR64DA64 AVR128DA28 AVR128DA32 * AVR128DA48 AVR128DA64 */ -const Configitem_t cfgtab_avr32da28[15] = { +const Configitem cfgtab_avr32da28[15] = { {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_avr32dd14, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_avr32dd14, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -13042,7 +13042,7 @@ const Configitem_t cfgtab_avr32da28[15] = { * AVR32DB28 AVR32DB32 AVR32DB48 AVR64DB28 AVR64DB32 AVR64DB48 AVR64DB64 AVR128DB28 AVR128DB32 * AVR128DB48 AVR128DB64 */ -const Configitem_t cfgtab_avr32db28[16] = { +const Configitem cfgtab_avr32db28[16] = { {"wdtperiod", 12, _values_wdtperiod_avr32dd14, "wdtcfg", 0, 0x0f, 0, 0x00, "watchdog timeout period"}, {"wdtwindow", 12, _values_wdtwindow_avr32dd14, "wdtcfg", 0, 0xf0, 4, 0x00, "watchdog window timeout period"}, {"bodsleep", 3, _values_bodsleep_avr32dd14, "bodcfg", 1, 0x03, 0, 0, "brownout detection in sleep mode"}, @@ -13065,7 +13065,7 @@ const Configitem_t cfgtab_avr32db28[16] = { // I/O Register files // ATmega328 ATmega328P -const Register_file_t rgftab_atmega328[81] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega328[81] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -13150,7 +13150,7 @@ const Register_file_t rgftab_atmega328[81] = { // I/O memory [0, 223] + 32 }; // ATmega16M1 ATmega32M1 -const Register_file_t rgftab_atmega16m1[136] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega16m1[136] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -13290,7 +13290,7 @@ const Register_file_t rgftab_atmega16m1[136] = { // I/O memory [0, 223] + 32 }; // ATmega32HVBrevB ATmega16HVB ATmega16HVBrevB ATmega32HVB -const Register_file_t rgftab_atmega32hvbrevb[91] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega32hvbrevb[91] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0x0f, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0x0f, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0x0f, -1, "port A data register"}, @@ -13385,7 +13385,7 @@ const Register_file_t rgftab_atmega32hvbrevb[91] = { // I/O memory [0, 223] + 32 }; // ATmega328PB -const Register_file_t rgftab_atmega328pb[123] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega328pb[123] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -13512,7 +13512,7 @@ const Register_file_t rgftab_atmega328pb[123] = { // I/O memory [0, 223] + 32 }; // ATmega8515 -const Register_file_t rgftab_atmega8515[52] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_atmega8515[52] = { // I/O memory [0, 63] + 32 {"cpu.osccal", 0x04, 1, 0xff, -1, "oscillator calibration register"}, {"porte.pine", 0x05, 1, 0x07, -1, "port E input register"}, {"porte.ddre", 0x06, 1, 0x07, -1, "port E data direction register"}, @@ -13568,7 +13568,7 @@ const Register_file_t rgftab_atmega8515[52] = { // I/O memory [0, 63] + 32 }; // ATtiny102 ATtiny104 -const Register_file_t rgftab_attiny102[55] = { // I/O memory [0, 63] +const Register_file rgftab_attiny102[55] = { // I/O memory [0, 63] {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -13627,7 +13627,7 @@ const Register_file_t rgftab_attiny102[55] = { // I/O memory [0, 63] }; // ATtiny28 -const Register_file_t rgftab_attiny28[20] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny28[20] = { // I/O memory [0, 63] + 32 {"cpu.osccal", 0x00, 1, 0xff, -1, "oscillator calibration register"}, {"watchdog.wdtcr", 0x01, 1, -1, -1, "watchdog timer control register"}, {"modulator.modcr", 0x02, 1, -1, -1, "modulation control register"}, @@ -13651,7 +13651,7 @@ const Register_file_t rgftab_attiny28[20] = { // I/O memory [0, 63] + 32 }; // ATtiny441 ATtiny841 -const Register_file_t rgftab_attiny441[101] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_attiny441[101] = { // I/O memory [0, 223] + 32 {"adc.adcsrb", 0x04, 1, -1, -1, "ADC control and status register B"}, {"adc.adcsra", 0x05, 1, -1, -1, "ADC control and status register A"}, {"adc.adc", 0x06, 2, 0xffff, -1, "ADC data register (16 bits)"}, @@ -13756,7 +13756,7 @@ const Register_file_t rgftab_attiny441[101] = { // I/O memory [0, 223] + 32 }; // AT90PWM81 -const Register_file_t rgftab_at90pwm81[84] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90pwm81[84] = { // I/O memory [0, 223] + 32 {"ac.acsr", 0x00, 1, -1, -1, "analog comparator control and status register"}, {"tc1.timsk1", 0x01, 1, -1, -1, "T/C 1 interrupt mask register"}, {"tc1.tifr1", 0x02, 1, -1, -1, "T/C 1 interrupt flag register"}, @@ -13844,7 +13844,7 @@ const Register_file_t rgftab_at90pwm81[84] = { // I/O memory [0, 223] + 32 }; // AT90CAN128 AT90CAN32 AT90CAN64 -const Register_file_t rgftab_at90can128[137] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90can128[137] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -13985,7 +13985,7 @@ const Register_file_t rgftab_at90can128[137] = { // I/O memory [0, 223] + 32 }; // AT90USB162 AT90USB82 -const Register_file_t rgftab_at90usb162[92] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90usb162[92] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -14081,7 +14081,7 @@ const Register_file_t rgftab_at90usb162[92] = { // I/O memory [0, 223] + 32 }; // ATA5700M322 -const Register_file_t rgftab_ata5700m322[337] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_ata5700m322[337] = { // I/O memory [0, 479] + 32 {"gpioregs_dvcc.gpior0", 0x000, 1, 0xff, -1, "general purpose I/O register 0"}, {"clk.prr1", 0x001, 1, -1, -1, "power reduction register 1"}, {"clk.prr2", 0x002, 1, -1, -1, "power reduction register 2"}, @@ -14422,7 +14422,7 @@ const Register_file_t rgftab_ata5700m322[337] = { // I/O memory [0, 479] + 32 }; // ATA5781 ATA5782 ATA5783 ATA8210 ATA8215 -const Register_file_t rgftab_ata5781[262] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_ata5781[262] = { // I/O memory [0, 479] + 32 {"clk.prr0", 0x001, 1, -1, -1, "power reduction register 0"}, {"clk.prr1", 0x002, 1, -1, -1, "power reduction register 1"}, {"clk.prr2", 0x003, 1, -1, -1, "power reduction register 2"}, @@ -14688,7 +14688,7 @@ const Register_file_t rgftab_ata5781[262] = { // I/O memory [0, 479] + 32 }; // ATA5790 -const Register_file_t rgftab_ata5790[112] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_ata5790[112] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -14804,7 +14804,7 @@ const Register_file_t rgftab_ata5790[112] = { // I/O memory [0, 223] + 32 }; // ATA6285 ATA6286 -const Register_file_t rgftab_ata6285[79] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_ata6285[79] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -14887,7 +14887,7 @@ const Register_file_t rgftab_ata6285[79] = { // I/O memory [0, 223] + 32 }; // ATxmega16E5 ATxmega8E5 ATxmega32E5 -const Register_file_t rgftab_atxmega16e5[438] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega16e5[438] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -15329,7 +15329,7 @@ const Register_file_t rgftab_atxmega16e5[438] = { // I/O memory [0, 4095] }; // ATxmega128A3 ATxmega64A3 ATxmega192A3 ATxmega256A3 -const Register_file_t rgftab_atxmega128a3[680] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega128a3[680] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -16013,7 +16013,7 @@ const Register_file_t rgftab_atxmega128a3[680] = { // I/O memory [0, 4095] }; // ATxmega128A3U ATxmega64A3U ATxmega192A3U ATxmega256A3U -const Register_file_t rgftab_atxmega128a3u[792] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega128a3u[792] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -16809,7 +16809,7 @@ const Register_file_t rgftab_atxmega128a3u[792] = { // I/O memory [0, 4095] }; // ATtiny204 ATtiny404 -const Register_file_t rgftab_attiny204[235] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny204[235] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -17048,7 +17048,7 @@ const Register_file_t rgftab_attiny204[235] = { // I/O memory [0, 4351] }; // ATtiny1624 ATtiny424 ATtiny824 ATtiny3224 -const Register_file_t rgftab_attiny1624[307] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny1624[307] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -17362,7 +17362,7 @@ const Register_file_t rgftab_attiny1624[307] = { // I/O memory [0, 4351] * AVR32DD14 AVR16DD14 AVR16DD20 AVR16DD28 AVR16DD32 AVR32DD20 AVR32DD28 AVR32DD32 AVR64DD14 * AVR64DD20 AVR64DD28 AVR64DD32 */ -const Register_file_t rgftab_avr32dd14[401] = { // I/O memory [0, 4159] +const Register_file rgftab_avr32dd14[401] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -17767,7 +17767,7 @@ const Register_file_t rgftab_avr32dd14[401] = { // I/O memory [0, 4159] }; // AVR64EA48 AVR16EA48 AVR32EA48 -const Register_file_t rgftab_avr64ea48[502] = { // I/O memory [0, 4159] +const Register_file rgftab_avr64ea48[502] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -18273,7 +18273,7 @@ const Register_file_t rgftab_avr64ea48[502] = { // I/O memory [0, 4159] }; // ATtiny4 ATtiny9 -const Register_file_t rgftab_attiny4[36] = { // I/O memory [0, 63] +const Register_file rgftab_attiny4[36] = { // I/O memory [0, 63] {"portb.pinb", 0x00, 1, 0x0f, -1, "port B input register"}, {"portb.ddrb", 0x01, 1, 0x0f, -1, "port B data direction register"}, {"portb.portb", 0x02, 1, 0x0f, -1, "port B data register"}, @@ -18313,7 +18313,7 @@ const Register_file_t rgftab_attiny4[36] = { // I/O memory [0, 63] }; // ATtiny5 ATtiny10 -const Register_file_t rgftab_attiny5[41] = { // I/O memory [0, 63] +const Register_file rgftab_attiny5[41] = { // I/O memory [0, 63] {"portb.pinb", 0x00, 1, 0x0f, -1, "port B input register"}, {"portb.ddrb", 0x01, 1, 0x0f, -1, "port B data direction register"}, {"portb.portb", 0x02, 1, 0x0f, -1, "port B data register"}, @@ -18358,7 +18358,7 @@ const Register_file_t rgftab_attiny5[41] = { // I/O memory [0, 63] }; // ATtiny20 -const Register_file_t rgftab_attiny20[61] = { // I/O memory [0, 63] +const Register_file rgftab_attiny20[61] = { // I/O memory [0, 63] {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -18423,7 +18423,7 @@ const Register_file_t rgftab_attiny20[61] = { // I/O memory [0, 63] }; // ATtiny40 -const Register_file_t rgftab_attiny40[63] = { // I/O memory [0, 63] +const Register_file rgftab_attiny40[63] = { // I/O memory [0, 63] {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -18490,7 +18490,7 @@ const Register_file_t rgftab_attiny40[63] = { // I/O memory [0, 63] }; // ATtiny11 -const Register_file_t rgftab_attiny11[14] = { // I/O memory [0, 63] +const Register_file rgftab_attiny11[14] = { // I/O memory [0, 63] {"ac.acsr", 0x08, 1, -1, -1, "analog comparator control and status register"}, {"portb.pinb", 0x16, 1, 0x3f, -1, "port B input register"}, {"portb.ddrb", 0x17, 1, 0x1f, -1, "port B data direction register"}, @@ -18508,7 +18508,7 @@ const Register_file_t rgftab_attiny11[14] = { // I/O memory [0, 63] }; // ATtiny12 -const Register_file_t rgftab_attiny12[18] = { // I/O memory [0, 63] +const Register_file rgftab_attiny12[18] = { // I/O memory [0, 63] {"ac.acsr", 0x08, 1, -1, -1, "analog comparator control and status register"}, {"portb.pinb", 0x16, 1, 0x3f, -1, "port B input register"}, {"portb.ddrb", 0x17, 1, 0x3f, -1, "port B data direction register"}, @@ -18530,7 +18530,7 @@ const Register_file_t rgftab_attiny12[18] = { // I/O memory [0, 63] }; // ATtiny13 -const Register_file_t rgftab_attiny13[35] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny13[35] = { // I/O memory [0, 63] + 32 {"ac.adcsrb", 0x03, 1, -1, -1, "ADC control and status register B"}, {"adc.adcsrb", 0x03, 1, -1, -1, "ADC control and status register B"}, {"adc.adc", 0x04, 2, 0xffff, -1, "ADC data register (16 bits)"}, @@ -18569,7 +18569,7 @@ const Register_file_t rgftab_attiny13[35] = { // I/O memory [0, 63] + 32 }; // ATtiny13A -const Register_file_t rgftab_attiny13a[37] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny13a[37] = { // I/O memory [0, 63] + 32 {"ac.adcsrb", 0x03, 1, -1, -1, "ADC control and status register B"}, {"adc.adcsrb", 0x03, 1, -1, -1, "ADC control and status register B"}, {"adc.adc", 0x04, 2, 0xffff, -1, "ADC data register (16 bits)"}, @@ -18610,7 +18610,7 @@ const Register_file_t rgftab_attiny13a[37] = { // I/O memory [0, 63] + 32 }; // ATtiny15 -const Register_file_t rgftab_attiny15[28] = { // I/O memory [0, 63] +const Register_file rgftab_attiny15[28] = { // I/O memory [0, 63] {"adc.adc", 0x04, 2, 0xffff, -1, "ADC data register (16 bits)"}, {"adc.adcsr", 0x06, 1, -1, -1, "ADC control and status register"}, {"adc.admux", 0x07, 1, -1, -1, "ADC multiplexer selection register"}, @@ -18642,7 +18642,7 @@ const Register_file_t rgftab_attiny15[28] = { // I/O memory [0, 63] }; // ATtiny24 ATtiny24A -const Register_file_t rgftab_attiny24[55] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny24[55] = { // I/O memory [0, 63] + 32 {"cpu.prr", 0x00, 1, -1, -1, "power reduction register"}, {"ac.didr0", 0x01, 1, -1, -1, "digital input disable register 0"}, {"adc.didr0", 0x01, 1, 0xff, -1, "digital input disable register 0"}, @@ -18701,7 +18701,7 @@ const Register_file_t rgftab_attiny24[55] = { // I/O memory [0, 63] + 32 }; // ATtiny25 -const Register_file_t rgftab_attiny25[55] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny25[55] = { // I/O memory [0, 63] + 32 {"ac.adcsrb", 0x03, 1, -1, -1, "ADC control and status register B"}, {"adc.adcsrb", 0x03, 1, -1, -1, "ADC control and status register B"}, {"adc.adc", 0x04, 2, 0xffff, -1, "ADC data register (16 bits)"}, @@ -18760,7 +18760,7 @@ const Register_file_t rgftab_attiny25[55] = { // I/O memory [0, 63] + 32 }; // ATtiny26 -const Register_file_t rgftab_attiny26[37] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny26[37] = { // I/O memory [0, 63] + 32 {"adc.adc", 0x04, 2, 0xffff, -1, "ADC data register (16 bits)"}, {"adc.adcsr", 0x06, 1, -1, -1, "ADC control and status register"}, {"adc.admux", 0x07, 1, -1, -1, "ADC multiplexer selection register"}, @@ -18801,7 +18801,7 @@ const Register_file_t rgftab_attiny26[37] = { // I/O memory [0, 63] + 32 }; // ATtiny43U -const Register_file_t rgftab_attiny43u[54] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny43u[54] = { // I/O memory [0, 63] + 32 {"cpu.prr", 0x00, 1, -1, -1, "power reduction register"}, {"ac.didr0", 0x01, 1, -1, -1, "digital input disable register 0"}, {"adc.didr0", 0x01, 1, -1, -1, "digital input disable register 0"}, @@ -18859,7 +18859,7 @@ const Register_file_t rgftab_attiny43u[54] = { // I/O memory [0, 63] + 32 }; // ATtiny44 ATtiny44A -const Register_file_t rgftab_attiny44[55] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny44[55] = { // I/O memory [0, 63] + 32 {"cpu.prr", 0x00, 1, -1, -1, "power reduction register"}, {"ac.didr0", 0x01, 1, -1, -1, "digital input disable register 0"}, {"adc.didr0", 0x01, 1, 0xff, -1, "digital input disable register 0"}, @@ -18918,7 +18918,7 @@ const Register_file_t rgftab_attiny44[55] = { // I/O memory [0, 63] + 32 }; // ATtiny45 ATtiny85 -const Register_file_t rgftab_attiny45[55] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny45[55] = { // I/O memory [0, 63] + 32 {"ac.adcsrb", 0x03, 1, -1, -1, "ADC control and status register B"}, {"adc.adcsrb", 0x03, 1, -1, -1, "ADC control and status register B"}, {"adc.adc", 0x04, 2, 0xffff, -1, "ADC data register (16 bits)"}, @@ -18977,7 +18977,7 @@ const Register_file_t rgftab_attiny45[55] = { // I/O memory [0, 63] + 32 }; // ATtiny48 -const Register_file_t rgftab_attiny48[74] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_attiny48[74] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -19055,7 +19055,7 @@ const Register_file_t rgftab_attiny48[74] = { // I/O memory [0, 223] + 32 }; // ATtiny84 ATtiny84A -const Register_file_t rgftab_attiny84[55] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny84[55] = { // I/O memory [0, 63] + 32 {"cpu.prr", 0x00, 1, -1, -1, "power reduction register"}, {"ac.didr0", 0x01, 1, -1, -1, "digital input disable register 0"}, {"adc.didr0", 0x01, 1, 0xff, -1, "digital input disable register 0"}, @@ -19114,7 +19114,7 @@ const Register_file_t rgftab_attiny84[55] = { // I/O memory [0, 63] + 32 }; // ATtiny87 ATtiny167 -const Register_file_t rgftab_attiny87[80] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_attiny87[80] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -19198,7 +19198,7 @@ const Register_file_t rgftab_attiny87[80] = { // I/O memory [0, 223] + 32 }; // ATtiny88 -const Register_file_t rgftab_attiny88[74] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_attiny88[74] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -19276,7 +19276,7 @@ const Register_file_t rgftab_attiny88[74] = { // I/O memory [0, 223] + 32 }; // ATtiny261 ATtiny261A -const Register_file_t rgftab_attiny261[63] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny261[63] = { // I/O memory [0, 63] + 32 {"tc1.tccr1e", 0x00, 1, -1, -1, "T/C 1 control register E"}, {"adc.didr0", 0x01, 1, -1, -1, "digital input disable register 0"}, {"adc.didr1", 0x02, 1, -1, -1, "digital input disable register 1"}, @@ -19343,7 +19343,7 @@ const Register_file_t rgftab_attiny261[63] = { // I/O memory [0, 63] + 32 }; // ATtiny461 ATtiny461A -const Register_file_t rgftab_attiny461[63] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny461[63] = { // I/O memory [0, 63] + 32 {"tc1.tccr1e", 0x00, 1, -1, -1, "T/C 1 control register E"}, {"adc.didr0", 0x01, 1, -1, -1, "digital input disable register 0"}, {"adc.didr1", 0x02, 1, -1, -1, "digital input disable register 1"}, @@ -19410,7 +19410,7 @@ const Register_file_t rgftab_attiny461[63] = { // I/O memory [0, 63] + 32 }; // ATtiny828 -const Register_file_t rgftab_attiny828[94] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_attiny828[94] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -19508,7 +19508,7 @@ const Register_file_t rgftab_attiny828[94] = { // I/O memory [0, 223] + 32 }; // ATtiny861 ATtiny861A -const Register_file_t rgftab_attiny861[63] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny861[63] = { // I/O memory [0, 63] + 32 {"tc1.tccr1e", 0x00, 1, -1, -1, "T/C 1 control register E"}, {"adc.didr0", 0x01, 1, -1, -1, "digital input disable register 0"}, {"adc.didr1", 0x02, 1, -1, -1, "digital input disable register 1"}, @@ -19575,7 +19575,7 @@ const Register_file_t rgftab_attiny861[63] = { // I/O memory [0, 63] + 32 }; // ATtiny1634 -const Register_file_t rgftab_attiny1634[89] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_attiny1634[89] = { // I/O memory [0, 223] + 32 {"adc.adc", 0x00, 2, 0xffff, -1, "ADC data register (16 bits)"}, {"adc.adcsrb", 0x02, 1, -1, -1, "ADC control and status register B"}, {"adc.adcsra", 0x03, 1, -1, -1, "ADC control and status register A"}, @@ -19668,7 +19668,7 @@ const Register_file_t rgftab_attiny1634[89] = { // I/O memory [0, 223] + 32 }; // ATtiny2313 -const Register_file_t rgftab_attiny2313[54] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny2313[54] = { // I/O memory [0, 63] + 32 {"ac.didr", 0x01, 1, 0x03, -1, "digital input disable register"}, {"usart.ubrrh", 0x02, 1, 0x0f, -1, "USART baud rate register high byte"}, {"usart.ucsrc", 0x03, 1, -1, -1, "USART control and status register C"}, @@ -19726,7 +19726,7 @@ const Register_file_t rgftab_attiny2313[54] = { // I/O memory [0, 63] + 32 }; // ATtiny2313A -const Register_file_t rgftab_attiny2313a[58] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny2313a[58] = { // I/O memory [0, 63] + 32 {"ac.didr", 0x01, 1, 0x03, -1, "digital input disable register"}, {"usart.ubrrh", 0x02, 1, 0x0f, -1, "USART baud rate register high byte"}, {"usart.ucsrc", 0x03, 1, -1, -1, "USART control and status register C"}, @@ -19788,7 +19788,7 @@ const Register_file_t rgftab_attiny2313a[58] = { // I/O memory [0, 63] + 32 }; // ATtiny4313 -const Register_file_t rgftab_attiny4313[58] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_attiny4313[58] = { // I/O memory [0, 63] + 32 {"ac.didr", 0x01, 1, 0x03, -1, "digital input disable register"}, {"usart.ubrrh", 0x02, 1, 0x0f, -1, "USART baud rate register high byte"}, {"usart.ucsrc", 0x03, 1, -1, -1, "USART control and status register C"}, @@ -19850,7 +19850,7 @@ const Register_file_t rgftab_attiny4313[58] = { // I/O memory [0, 63] + 32 }; // ATmega8 ATmega8A -const Register_file_t rgftab_atmega8[61] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_atmega8[61] = { // I/O memory [0, 63] + 32 {"twi.twbr", 0x00, 1, 0xff, -1, "TWI bit rate register"}, {"twi.twsr", 0x01, 1, -1, -1, "TWI status register"}, {"twi.twar", 0x02, 1, -1, -1, "TWI peripheral address register"}, @@ -19915,7 +19915,7 @@ const Register_file_t rgftab_atmega8[61] = { // I/O memory [0, 63] + 32 }; // ATmega8HVA ATmega16HVA -const Register_file_t rgftab_atmega8hva[74] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega8hva[74] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0x03, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0x03, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0x03, -1, "port A data register"}, @@ -19993,7 +19993,7 @@ const Register_file_t rgftab_atmega8hva[74] = { // I/O memory [0, 223] + 32 }; // ATmega8U2 ATmega16U2 ATmega32U2 -const Register_file_t rgftab_atmega8u2[92] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega8u2[92] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -20089,7 +20089,7 @@ const Register_file_t rgftab_atmega8u2[92] = { // I/O memory [0, 223] + 32 }; // ATmega16 -const Register_file_t rgftab_atmega16[70] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_atmega16[70] = { // I/O memory [0, 63] + 32 {"twi.twbr", 0x00, 1, 0xff, -1, "TWI bit rate register"}, {"twi.twsr", 0x01, 1, -1, -1, "TWI status register"}, {"twi.twar", 0x02, 1, -1, -1, "TWI peripheral address register"}, @@ -20163,7 +20163,7 @@ const Register_file_t rgftab_atmega16[70] = { // I/O memory [0, 63] + 32 }; // ATmega16A -const Register_file_t rgftab_atmega16a[70] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_atmega16a[70] = { // I/O memory [0, 63] + 32 {"twi.twbr", 0x00, 1, 0xff, -1, "TWI bit rate register"}, {"twi.twsr", 0x01, 1, -1, -1, "TWI status register"}, {"twi.twar", 0x02, 1, -1, -1, "TWI peripheral address register"}, @@ -20237,7 +20237,7 @@ const Register_file_t rgftab_atmega16a[70] = { // I/O memory [0, 63] + 32 }; // ATmega16U4 ATmega32U4 -const Register_file_t rgftab_atmega16u4[139] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega16u4[139] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -20380,7 +20380,7 @@ const Register_file_t rgftab_atmega16u4[139] = { // I/O memory [0, 223] + 32 }; // ATmega32 -const Register_file_t rgftab_atmega32[68] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_atmega32[68] = { // I/O memory [0, 63] + 32 {"twi.twbr", 0x00, 1, 0xff, -1, "TWI bit rate register"}, {"twi.twsr", 0x01, 1, -1, -1, "TWI status register"}, {"twi.twar", 0x02, 1, 0xff, -1, "TWI peripheral address register"}, @@ -20452,7 +20452,7 @@ const Register_file_t rgftab_atmega32[68] = { // I/O memory [0, 63] + 32 }; // ATmega32A -const Register_file_t rgftab_atmega32a[66] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_atmega32a[66] = { // I/O memory [0, 63] + 32 {"twi.twbr", 0x00, 1, 0xff, -1, "TWI bit rate register"}, {"twi.twsr", 0x01, 1, -1, -1, "TWI status register"}, {"twi.twar", 0x02, 1, 0xff, -1, "TWI peripheral address register"}, @@ -20522,7 +20522,7 @@ const Register_file_t rgftab_atmega32a[66] = { // I/O memory [0, 63] + 32 }; // ATmega32C1 -const Register_file_t rgftab_atmega32c1[117] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega32c1[117] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -20643,7 +20643,7 @@ const Register_file_t rgftab_atmega32c1[117] = { // I/O memory [0, 223] + 32 }; // ATmega48 ATmega48P -const Register_file_t rgftab_atmega48[81] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega48[81] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -20728,7 +20728,7 @@ const Register_file_t rgftab_atmega48[81] = { // I/O memory [0, 223] + 32 }; // ATmega48A ATmega48PA -const Register_file_t rgftab_atmega48a[82] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega48a[82] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -20814,7 +20814,7 @@ const Register_file_t rgftab_atmega48a[82] = { // I/O memory [0, 223] + 32 }; // ATmega48PB -const Register_file_t rgftab_atmega48pb[95] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega48pb[95] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -20913,7 +20913,7 @@ const Register_file_t rgftab_atmega48pb[95] = { // I/O memory [0, 223] + 32 }; // ATmega64 ATmega64A -const Register_file_t rgftab_atmega64[103] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega64[103] = { // I/O memory [0, 223] + 32 {"portf.pinf", 0x00, 1, 0xff, -1, "port F input register"}, {"porte.pine", 0x01, 1, 0xff, -1, "port E input register"}, {"porte.ddre", 0x02, 1, 0xff, -1, "port E data direction register"}, @@ -21020,7 +21020,7 @@ const Register_file_t rgftab_atmega64[103] = { // I/O memory [0, 223] + 32 }; // ATmega64C1 -const Register_file_t rgftab_atmega64c1[122] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega64c1[122] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -21146,7 +21146,7 @@ const Register_file_t rgftab_atmega64c1[122] = { // I/O memory [0, 223] + 32 }; // ATmega64M1 -const Register_file_t rgftab_atmega64m1[136] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega64m1[136] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -21286,7 +21286,7 @@ const Register_file_t rgftab_atmega64m1[136] = { // I/O memory [0, 223] + 32 }; // ATmega64HVE2 -const Register_file_t rgftab_atmega64hve2[89] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega64hve2[89] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0x03, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0x03, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0x03, -1, "port A data register"}, @@ -21379,7 +21379,7 @@ const Register_file_t rgftab_atmega64hve2[89] = { // I/O memory [0, 223] + 32 }; // ATmega64RFR2 ATmega644RFR2 -const Register_file_t rgftab_atmega64rfr2[269] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega64rfr2[269] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -21652,7 +21652,7 @@ const Register_file_t rgftab_atmega64rfr2[269] = { // I/O memory [0, 479] + 32 }; // ATmega88 ATmega88A ATmega88P ATmega88PA ATmega168 ATmega168A ATmega168P ATmega168PA -const Register_file_t rgftab_atmega88[81] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega88[81] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -21737,7 +21737,7 @@ const Register_file_t rgftab_atmega88[81] = { // I/O memory [0, 223] + 32 }; // ATmega88PB ATmega168PB -const Register_file_t rgftab_atmega88pb[95] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega88pb[95] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -21836,7 +21836,7 @@ const Register_file_t rgftab_atmega88pb[95] = { // I/O memory [0, 223] + 32 }; // ATmega128 -const Register_file_t rgftab_atmega128[103] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega128[103] = { // I/O memory [0, 223] + 32 {"portf.pinf", 0x00, 1, 0xff, -1, "port F input register"}, {"porte.pine", 0x01, 1, 0xff, -1, "port E input register"}, {"porte.ddre", 0x02, 1, 0xff, -1, "port E data direction register"}, @@ -21943,7 +21943,7 @@ const Register_file_t rgftab_atmega128[103] = { // I/O memory [0, 223] + 32 }; // ATmega128A -const Register_file_t rgftab_atmega128a[103] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega128a[103] = { // I/O memory [0, 223] + 32 {"portf.pinf", 0x00, 1, 0xff, -1, "port F input register"}, {"porte.pine", 0x01, 1, 0xff, -1, "port E input register"}, {"porte.ddre", 0x02, 1, 0xff, -1, "port E data direction register"}, @@ -22050,7 +22050,7 @@ const Register_file_t rgftab_atmega128a[103] = { // I/O memory [0, 223] + 32 }; // ATmega128RFA1 -const Register_file_t rgftab_atmega128rfa1[237] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega128rfa1[237] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -22291,7 +22291,7 @@ const Register_file_t rgftab_atmega128rfa1[237] = { // I/O memory [0, 479] + 32 }; // ATmega128RFR2 ATmega1284RFR2 -const Register_file_t rgftab_atmega128rfr2[270] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega128rfr2[270] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -22565,7 +22565,7 @@ const Register_file_t rgftab_atmega128rfr2[270] = { // I/O memory [0, 479] + 32 }; // ATmega162 -const Register_file_t rgftab_atmega162[79] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega162[79] = { // I/O memory [0, 223] + 32 {"usart1.ubrr1l", 0x00, 1, 0xff, -1, "USART 1 baud rate register low byte"}, {"usart1.ucsr1b", 0x01, 1, -1, -1, "USART 1 control and status register B"}, {"usart1.ucsr1a", 0x02, 1, -1, -1, "USART 1 control and status register A"}, @@ -22648,7 +22648,7 @@ const Register_file_t rgftab_atmega162[79] = { // I/O memory [0, 223] + 32 }; // ATmega164A ATmega164P ATmega164PA ATmega324A ATmega324P ATmega324PA -const Register_file_t rgftab_atmega164a[96] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega164a[96] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -22748,7 +22748,7 @@ const Register_file_t rgftab_atmega164a[96] = { // I/O memory [0, 223] + 32 }; // ATmega165A ATmega165P ATmega165PA -const Register_file_t rgftab_atmega165a[86] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega165a[86] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -22838,7 +22838,7 @@ const Register_file_t rgftab_atmega165a[86] = { // I/O memory [0, 223] + 32 }; // ATmega169A ATmega169P ATmega169PA -const Register_file_t rgftab_atmega169a[106] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega169a[106] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -22948,7 +22948,7 @@ const Register_file_t rgftab_atmega169a[106] = { // I/O memory [0, 223] + 32 }; // ATmega256RFR2 -const Register_file_t rgftab_atmega256rfr2[271] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega256rfr2[271] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -23223,7 +23223,7 @@ const Register_file_t rgftab_atmega256rfr2[271] = { // I/O memory [0, 479] + 32 }; // ATmega324PB -const Register_file_t rgftab_atmega324pb[134] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega324pb[134] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -23361,7 +23361,7 @@ const Register_file_t rgftab_atmega324pb[134] = { // I/O memory [0, 223] + 32 }; // ATmega325 ATmega325A ATmega325P ATmega325PA -const Register_file_t rgftab_atmega325[86] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega325[86] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -23451,7 +23451,7 @@ const Register_file_t rgftab_atmega325[86] = { // I/O memory [0, 223] + 32 }; // ATmega329 -const Register_file_t rgftab_atmega329[106] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega329[106] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -23561,7 +23561,7 @@ const Register_file_t rgftab_atmega329[106] = { // I/O memory [0, 223] + 32 }; // ATmega329A ATmega329PA -const Register_file_t rgftab_atmega329a[106] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega329a[106] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -23671,7 +23671,7 @@ const Register_file_t rgftab_atmega329a[106] = { // I/O memory [0, 223] + 32 }; // ATmega329P -const Register_file_t rgftab_atmega329p[106] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega329p[106] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -23781,7 +23781,7 @@ const Register_file_t rgftab_atmega329p[106] = { // I/O memory [0, 223] + 32 }; // ATmega406 -const Register_file_t rgftab_atmega406[79] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega406[79] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -23864,7 +23864,7 @@ const Register_file_t rgftab_atmega406[79] = { // I/O memory [0, 223] + 32 }; // ATmega640 -const Register_file_t rgftab_atmega640[160] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega640[160] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -24028,7 +24028,7 @@ const Register_file_t rgftab_atmega640[160] = { // I/O memory [0, 479] + 32 }; // ATmega644 -const Register_file_t rgftab_atmega644[88] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega644[88] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -24120,7 +24120,7 @@ const Register_file_t rgftab_atmega644[88] = { // I/O memory [0, 223] + 32 }; // ATmega644A ATmega644P ATmega644PA -const Register_file_t rgftab_atmega644a[93] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega644a[93] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -24217,7 +24217,7 @@ const Register_file_t rgftab_atmega644a[93] = { // I/O memory [0, 223] + 32 }; // ATmega645 ATmega645A ATmega645P -const Register_file_t rgftab_atmega645[86] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega645[86] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -24307,7 +24307,7 @@ const Register_file_t rgftab_atmega645[86] = { // I/O memory [0, 223] + 32 }; // ATmega649 ATmega649A ATmega649P -const Register_file_t rgftab_atmega649[106] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega649[106] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -24417,7 +24417,7 @@ const Register_file_t rgftab_atmega649[106] = { // I/O memory [0, 223] + 32 }; // ATmega1280 ATmega2560 -const Register_file_t rgftab_atmega1280[161] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega1280[161] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -24582,7 +24582,7 @@ const Register_file_t rgftab_atmega1280[161] = { // I/O memory [0, 479] + 32 }; // ATmega1281 -const Register_file_t rgftab_atmega1281[138] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega1281[138] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -24724,7 +24724,7 @@ const Register_file_t rgftab_atmega1281[138] = { // I/O memory [0, 479] + 32 }; // ATmega1284 ATmega1284P -const Register_file_t rgftab_atmega1284[104] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega1284[104] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -24832,7 +24832,7 @@ const Register_file_t rgftab_atmega1284[104] = { // I/O memory [0, 223] + 32 }; // ATmega2561 -const Register_file_t rgftab_atmega2561[139] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega2561[139] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -24975,7 +24975,7 @@ const Register_file_t rgftab_atmega2561[139] = { // I/O memory [0, 479] + 32 }; // ATmega2564RFR2 -const Register_file_t rgftab_atmega2564rfr2[271] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_atmega2564rfr2[271] = { // I/O memory [0, 479] + 32 {"porta.pina", 0x000, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x001, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x002, 1, 0xff, -1, "port A data register"}, @@ -25250,7 +25250,7 @@ const Register_file_t rgftab_atmega2564rfr2[271] = { // I/O memory [0, 479] + 32 }; // ATmega3250 ATmega3250A ATmega3250P ATmega3250PA -const Register_file_t rgftab_atmega3250[94] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega3250[94] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -25348,7 +25348,7 @@ const Register_file_t rgftab_atmega3250[94] = { // I/O memory [0, 223] + 32 }; // ATmega3290 ATmega3290A -const Register_file_t rgftab_atmega3290[118] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega3290[118] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -25470,7 +25470,7 @@ const Register_file_t rgftab_atmega3290[118] = { // I/O memory [0, 223] + 32 }; // ATmega3290P -const Register_file_t rgftab_atmega3290p[118] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega3290p[118] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -25592,7 +25592,7 @@ const Register_file_t rgftab_atmega3290p[118] = { // I/O memory [0, 223] + 32 }; // ATmega3290PA -const Register_file_t rgftab_atmega3290pa[118] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega3290pa[118] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -25714,7 +25714,7 @@ const Register_file_t rgftab_atmega3290pa[118] = { // I/O memory [0, 223] + 32 }; // ATmega6450 ATmega6450A ATmega6450P -const Register_file_t rgftab_atmega6450[94] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega6450[94] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -25812,7 +25812,7 @@ const Register_file_t rgftab_atmega6450[94] = { // I/O memory [0, 223] + 32 }; // ATmega6490 ATmega6490A ATmega6490P -const Register_file_t rgftab_atmega6490[118] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_atmega6490[118] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -25934,7 +25934,7 @@ const Register_file_t rgftab_atmega6490[118] = { // I/O memory [0, 223] + 32 }; // ATmega8535 -const Register_file_t rgftab_atmega8535[67] = { // I/O memory [0, 63] + 32 +const Register_file rgftab_atmega8535[67] = { // I/O memory [0, 63] + 32 {"twi.twbr", 0x00, 1, 0xff, -1, "TWI bit rate register"}, {"twi.twsr", 0x01, 1, -1, -1, "TWI status register"}, {"twi.twar", 0x02, 1, -1, -1, "TWI peripheral address register"}, @@ -26005,7 +26005,7 @@ const Register_file_t rgftab_atmega8535[67] = { // I/O memory [0, 63] + 32 }; // AT90PWM1 -const Register_file_t rgftab_at90pwm1[92] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90pwm1[92] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -26101,7 +26101,7 @@ const Register_file_t rgftab_at90pwm1[92] = { // I/O memory [0, 223] + 32 }; // AT90PWM2B -const Register_file_t rgftab_at90pwm2b[100] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90pwm2b[100] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -26205,7 +26205,7 @@ const Register_file_t rgftab_at90pwm2b[100] = { // I/O memory [0, 223] + 32 }; // AT90PWM3 -const Register_file_t rgftab_at90pwm3[115] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90pwm3[115] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -26324,7 +26324,7 @@ const Register_file_t rgftab_at90pwm3[115] = { // I/O memory [0, 223] + 32 }; // AT90PWM3B -const Register_file_t rgftab_at90pwm3b[115] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90pwm3b[115] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -26443,7 +26443,7 @@ const Register_file_t rgftab_at90pwm3b[115] = { // I/O memory [0, 223] + 32 }; // AT90PWM161 -const Register_file_t rgftab_at90pwm161[86] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90pwm161[86] = { // I/O memory [0, 223] + 32 {"ac.acsr", 0x00, 1, -1, -1, "analog comparator control and status register"}, {"tc1.timsk1", 0x01, 1, -1, -1, "T/C 1 interrupt mask register"}, {"tc1.tifr1", 0x02, 1, -1, -1, "T/C 1 interrupt flag register"}, @@ -26533,7 +26533,7 @@ const Register_file_t rgftab_at90pwm161[86] = { // I/O memory [0, 223] + 32 }; // AT90PWM216 -const Register_file_t rgftab_at90pwm216[102] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90pwm216[102] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -26639,7 +26639,7 @@ const Register_file_t rgftab_at90pwm216[102] = { // I/O memory [0, 223] + 32 }; // AT90PWM316 -const Register_file_t rgftab_at90pwm316[117] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90pwm316[117] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -26760,7 +26760,7 @@ const Register_file_t rgftab_at90pwm316[117] = { // I/O memory [0, 223] + 32 }; // AT90USB646 AT90USB647 AT90USB1287 -const Register_file_t rgftab_at90usb646[157] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90usb646[157] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -26921,7 +26921,7 @@ const Register_file_t rgftab_at90usb646[157] = { // I/O memory [0, 223] + 32 }; // AT90USB1286 -const Register_file_t rgftab_at90usb1286[132] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_at90usb1286[132] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -27057,7 +27057,7 @@ const Register_file_t rgftab_at90usb1286[132] = { // I/O memory [0, 223] + 32 }; // ATA5272 ATA5505 -const Register_file_t rgftab_ata5272[80] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_ata5272[80] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, 0xff, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -27141,7 +27141,7 @@ const Register_file_t rgftab_ata5272[80] = { // I/O memory [0, 223] + 32 }; // ATA5702M322 -const Register_file_t rgftab_ata5702m322[378] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_ata5702m322[378] = { // I/O memory [0, 479] + 32 {"gpioregs_dvcc.gpior0", 0x000, 1, 0xff, -1, "general purpose I/O register 0"}, {"clk.prr1", 0x001, 1, -1, -1, "power reduction register 1"}, {"clk.prr2", 0x002, 1, -1, -1, "power reduction register 2"}, @@ -27523,7 +27523,7 @@ const Register_file_t rgftab_ata5702m322[378] = { // I/O memory [0, 479] + 32 }; // ATA5787 -const Register_file_t rgftab_ata5787[292] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_ata5787[292] = { // I/O memory [0, 479] + 32 {"clk.prr0", 0x001, 1, -1, -1, "power reduction register 0"}, {"clk.prr1", 0x002, 1, -1, -1, "power reduction register 1"}, {"clk.prr2", 0x003, 1, -1, -1, "power reduction register 2"}, @@ -27819,7 +27819,7 @@ const Register_file_t rgftab_ata5787[292] = { // I/O memory [0, 479] + 32 }; // ATA5790N ATA5791 -const Register_file_t rgftab_ata5790n[117] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_ata5790n[117] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -27940,7 +27940,7 @@ const Register_file_t rgftab_ata5790n[117] = { // I/O memory [0, 223] + 32 }; // ATA5795 -const Register_file_t rgftab_ata5795[84] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_ata5795[84] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, 0xff, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -28028,7 +28028,7 @@ const Register_file_t rgftab_ata5795[84] = { // I/O memory [0, 223] + 32 }; // ATA5831 ATA5832 ATA5833 ATA8510 ATA8515 -const Register_file_t rgftab_ata5831[279] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_ata5831[279] = { // I/O memory [0, 479] + 32 {"clk.prr0", 0x001, 1, -1, -1, "power reduction register 0"}, {"clk.prr1", 0x002, 1, -1, -1, "power reduction register 1"}, {"clk.prr2", 0x003, 1, -1, -1, "power reduction register 2"}, @@ -28311,7 +28311,7 @@ const Register_file_t rgftab_ata5831[279] = { // I/O memory [0, 479] + 32 }; // ATA5835 -const Register_file_t rgftab_ata5835[307] = { // I/O memory [0, 479] + 32 +const Register_file rgftab_ata5835[307] = { // I/O memory [0, 479] + 32 {"clk.prr0", 0x001, 1, -1, -1, "power reduction register 0"}, {"clk.prr1", 0x002, 1, -1, -1, "power reduction register 1"}, {"clk.prr2", 0x003, 1, -1, -1, "power reduction register 2"}, @@ -28622,7 +28622,7 @@ const Register_file_t rgftab_ata5835[307] = { // I/O memory [0, 479] + 32 }; // ATA6612C ATA6613C -const Register_file_t rgftab_ata6612c[81] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_ata6612c[81] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, -1, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -28707,7 +28707,7 @@ const Register_file_t rgftab_ata6612c[81] = { // I/O memory [0, 223] + 32 }; // ATA6614Q -const Register_file_t rgftab_ata6614q[81] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_ata6614q[81] = { // I/O memory [0, 223] + 32 {"portb.pinb", 0x03, 1, 0xff, -1, "port B input register"}, {"portb.ddrb", 0x04, 1, -1, -1, "port B data direction register"}, {"portb.portb", 0x05, 1, 0xff, -1, "port B data register"}, @@ -28792,7 +28792,7 @@ const Register_file_t rgftab_ata6614q[81] = { // I/O memory [0, 223] + 32 }; // ATA6616C ATA6617C ATA664251 -const Register_file_t rgftab_ata6616c[81] = { // I/O memory [0, 223] + 32 +const Register_file rgftab_ata6616c[81] = { // I/O memory [0, 223] + 32 {"porta.pina", 0x00, 1, 0xff, -1, "port A input register"}, {"porta.ddra", 0x01, 1, -1, -1, "port A data direction register"}, {"porta.porta", 0x02, 1, 0xff, -1, "port A data register"}, @@ -28877,7 +28877,7 @@ const Register_file_t rgftab_ata6616c[81] = { // I/O memory [0, 223] + 32 }; // ATxmega16A4 ATxmega32A4 -const Register_file_t rgftab_atxmega16a4[553] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega16a4[553] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -29434,7 +29434,7 @@ const Register_file_t rgftab_atxmega16a4[553] = { // I/O memory [0, 4095] }; // ATxmega16A4U ATxmega32A4U -const Register_file_t rgftab_atxmega16a4u[630] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega16a4u[630] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -30068,7 +30068,7 @@ const Register_file_t rgftab_atxmega16a4u[630] = { // I/O memory [0, 4095] }; // ATxmega16C4 ATxmega32C4 -const Register_file_t rgftab_atxmega16c4[482] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega16c4[482] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -30554,7 +30554,7 @@ const Register_file_t rgftab_atxmega16c4[482] = { // I/O memory [0, 4095] }; // ATxmega16D4 ATxmega32D4 -const Register_file_t rgftab_atxmega16d4[460] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega16d4[460] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -31018,7 +31018,7 @@ const Register_file_t rgftab_atxmega16d4[460] = { // I/O memory [0, 4095] }; // ATxmega32C3 ATxmega64C3 ATxmega128C3 ATxmega192C3 ATxmega256C3 -const Register_file_t rgftab_atxmega32c3[569] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega32c3[569] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -31591,7 +31591,7 @@ const Register_file_t rgftab_atxmega32c3[569] = { // I/O memory [0, 4095] }; // ATxmega32D3 ATxmega64D3 ATxmega128D3 ATxmega192D3 ATxmega256D3 -const Register_file_t rgftab_atxmega32d3[567] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega32d3[567] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -32162,7 +32162,7 @@ const Register_file_t rgftab_atxmega32d3[567] = { // I/O memory [0, 4095] }; // ATxmega64A1 ATxmega128A1 -const Register_file_t rgftab_atxmega64a1[814] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega64a1[814] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -32980,7 +32980,7 @@ const Register_file_t rgftab_atxmega64a1[814] = { // I/O memory [0, 4095] }; // ATxmega64A1U ATxmega128A1U -const Register_file_t rgftab_atxmega64a1u[943] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega64a1u[943] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -33927,7 +33927,7 @@ const Register_file_t rgftab_atxmega64a1u[943] = { // I/O memory [0, 4095] }; // ATxmega64B1 ATxmega128B1 -const Register_file_t rgftab_atxmega64b1[574] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega64b1[574] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -34505,7 +34505,7 @@ const Register_file_t rgftab_atxmega64b1[574] = { // I/O memory [0, 4095] }; // ATxmega64B3 ATxmega128B3 -const Register_file_t rgftab_atxmega64b3[458] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega64b3[458] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -34967,7 +34967,7 @@ const Register_file_t rgftab_atxmega64b3[458] = { // I/O memory [0, 4095] }; // ATxmega64A4U ATxmega128A4U -const Register_file_t rgftab_atxmega64a4u[632] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega64a4u[632] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -35603,7 +35603,7 @@ const Register_file_t rgftab_atxmega64a4u[632] = { // I/O memory [0, 4095] }; // ATxmega64D4 ATxmega128D4 -const Register_file_t rgftab_atxmega64d4[460] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega64d4[460] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -36067,7 +36067,7 @@ const Register_file_t rgftab_atxmega64d4[460] = { // I/O memory [0, 4095] }; // ATxmega256A3B -const Register_file_t rgftab_atxmega256a3b[665] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega256a3b[665] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -36736,7 +36736,7 @@ const Register_file_t rgftab_atxmega256a3b[665] = { // I/O memory [0, 4095] }; // ATxmega256A3BU -const Register_file_t rgftab_atxmega256a3bu[780] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega256a3bu[780] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -37520,7 +37520,7 @@ const Register_file_t rgftab_atxmega256a3bu[780] = { // I/O memory [0, 4095] }; // ATxmega384C3 -const Register_file_t rgftab_atxmega384c3[603] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega384c3[603] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -38127,7 +38127,7 @@ const Register_file_t rgftab_atxmega384c3[603] = { // I/O memory [0, 4095] }; // ATxmega384D3 -const Register_file_t rgftab_atxmega384d3[560] = { // I/O memory [0, 4095] +const Register_file rgftab_atxmega384d3[560] = { // I/O memory [0, 4095] {"gpio.gpior0", 0x000, 1, -1, -1, "general purpose I/O register 0"}, {"gpio.gpior1", 0x001, 1, -1, -1, "general purpose I/O register 1"}, {"gpio.gpior2", 0x002, 1, -1, -1, "general purpose I/O register 2"}, @@ -38691,7 +38691,7 @@ const Register_file_t rgftab_atxmega384d3[560] = { // I/O memory [0, 4095] }; // ATtiny202 ATtiny402 -const Register_file_t rgftab_attiny202[217] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny202[217] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -38912,7 +38912,7 @@ const Register_file_t rgftab_attiny202[217] = { // I/O memory [0, 4351] }; // ATtiny212 ATtiny412 -const Register_file_t rgftab_attiny212[247] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny212[247] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -39163,7 +39163,7 @@ const Register_file_t rgftab_attiny212[247] = { // I/O memory [0, 4351] }; // ATtiny214 ATtiny414 -const Register_file_t rgftab_attiny214[265] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny214[265] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -39432,7 +39432,7 @@ const Register_file_t rgftab_attiny214[265] = { // I/O memory [0, 4351] }; // ATtiny406 -const Register_file_t rgftab_attiny406[253] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny406[253] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -39689,7 +39689,7 @@ const Register_file_t rgftab_attiny406[253] = { // I/O memory [0, 4351] }; // ATtiny416 -const Register_file_t rgftab_attiny416[283] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny416[283] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -39976,7 +39976,7 @@ const Register_file_t rgftab_attiny416[283] = { // I/O memory [0, 4351] }; // ATtiny416auto -const Register_file_t rgftab_attiny416auto[283] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny416auto[283] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -40263,7 +40263,7 @@ const Register_file_t rgftab_attiny416auto[283] = { // I/O memory [0, 4351] }; // ATtiny417 ATtiny816 ATtiny817 -const Register_file_t rgftab_attiny417[283] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny417[283] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -40550,7 +40550,7 @@ const Register_file_t rgftab_attiny417[283] = { // I/O memory [0, 4351] }; // ATtiny426 ATtiny427 ATtiny826 ATtiny827 ATtiny1626 ATtiny1627 ATtiny3226 ATtiny3227 -const Register_file_t rgftab_attiny426[308] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny426[308] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -40862,7 +40862,7 @@ const Register_file_t rgftab_attiny426[308] = { // I/O memory [0, 4351] }; // ATtiny804 ATtiny806 ATtiny807 ATtiny1604 ATtiny1606 ATtiny1607 -const Register_file_t rgftab_attiny804[255] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny804[255] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -41121,7 +41121,7 @@ const Register_file_t rgftab_attiny804[255] = { // I/O memory [0, 4351] }; // ATtiny814 -const Register_file_t rgftab_attiny814[265] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny814[265] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -41390,7 +41390,7 @@ const Register_file_t rgftab_attiny814[265] = { // I/O memory [0, 4351] }; // ATtiny1614 -const Register_file_t rgftab_attiny1614[308] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny1614[308] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -41702,7 +41702,7 @@ const Register_file_t rgftab_attiny1614[308] = { // I/O memory [0, 4351] }; // ATtiny1616 ATtiny1617 -const Register_file_t rgftab_attiny1616[326] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny1616[326] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -42032,7 +42032,7 @@ const Register_file_t rgftab_attiny1616[326] = { // I/O memory [0, 4351] }; // ATtiny3216 ATtiny3217 -const Register_file_t rgftab_attiny3216[326] = { // I/O memory [0, 4351] +const Register_file rgftab_attiny3216[326] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -42362,7 +42362,7 @@ const Register_file_t rgftab_attiny3216[326] = { // I/O memory [0, 4351] }; // ATmega808 ATmega1608 -const Register_file_t rgftab_atmega808[406] = { // I/O memory [0, 4351] +const Register_file rgftab_atmega808[406] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -42772,7 +42772,7 @@ const Register_file_t rgftab_atmega808[406] = { // I/O memory [0, 4351] }; // ATmega809 ATmega1609 -const Register_file_t rgftab_atmega809[432] = { // I/O memory [0, 4351] +const Register_file rgftab_atmega809[432] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -43208,7 +43208,7 @@ const Register_file_t rgftab_atmega809[432] = { // I/O memory [0, 4351] }; // ATmega3208 ATmega4808 -const Register_file_t rgftab_atmega3208[406] = { // I/O memory [0, 4351] +const Register_file rgftab_atmega3208[406] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -43618,7 +43618,7 @@ const Register_file_t rgftab_atmega3208[406] = { // I/O memory [0, 4351] }; // ATmega3209 ATmega4809 -const Register_file_t rgftab_atmega3209[432] = { // I/O memory [0, 4351] +const Register_file rgftab_atmega3209[432] = { // I/O memory [0, 4351] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -44054,7 +44054,7 @@ const Register_file_t rgftab_atmega3209[432] = { // I/O memory [0, 4351] }; // AVR16DU14 AVR32DU14 -const Register_file_t rgftab_avr16du14[371] = { // I/O memory [0, 4159] +const Register_file rgftab_avr16du14[371] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -44429,7 +44429,7 @@ const Register_file_t rgftab_avr16du14[371] = { // I/O memory [0, 4159] }; // AVR16EB14 -const Register_file_t rgftab_avr16eb14[391] = { // I/O memory [0, 4159] +const Register_file rgftab_avr16eb14[391] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -44824,7 +44824,7 @@ const Register_file_t rgftab_avr16eb14[391] = { // I/O memory [0, 4159] }; // AVR16DU20 AVR16DU28 AVR16DU32 AVR32DU20 AVR32DU28 AVR32DU32 AVR64DU28 AVR64DU32 -const Register_file_t rgftab_avr16du20[372] = { // I/O memory [0, 4159] +const Register_file rgftab_avr16du20[372] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -45200,7 +45200,7 @@ const Register_file_t rgftab_avr16du20[372] = { // I/O memory [0, 4159] }; // AVR16EB20 AVR16EB28 AVR16EB32 -const Register_file_t rgftab_avr16eb20[393] = { // I/O memory [0, 4159] +const Register_file rgftab_avr16eb20[393] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -45597,7 +45597,7 @@ const Register_file_t rgftab_avr16eb20[393] = { // I/O memory [0, 4159] }; // AVR16EA28 AVR16EA32 AVR32EA28 AVR32EA32 AVR64EA28 AVR64EA32 -const Register_file_t rgftab_avr16ea28[402] = { // I/O memory [0, 4159] +const Register_file rgftab_avr16ea28[402] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -46003,7 +46003,7 @@ const Register_file_t rgftab_avr16ea28[402] = { // I/O memory [0, 4159] }; // AVR32DA28 -const Register_file_t rgftab_avr32da28[432] = { // I/O memory [0, 4159] +const Register_file rgftab_avr32da28[432] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -46439,7 +46439,7 @@ const Register_file_t rgftab_avr32da28[432] = { // I/O memory [0, 4159] }; // AVR32DB28 AVR64DB28 AVR128DB28 -const Register_file_t rgftab_avr32db28[462] = { // I/O memory [0, 4159] +const Register_file rgftab_avr32db28[462] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -46905,7 +46905,7 @@ const Register_file_t rgftab_avr32db28[462] = { // I/O memory [0, 4159] }; // AVR32DA32 -const Register_file_t rgftab_avr32da32[447] = { // I/O memory [0, 4159] +const Register_file rgftab_avr32da32[447] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -47356,7 +47356,7 @@ const Register_file_t rgftab_avr32da32[447] = { // I/O memory [0, 4159] }; // AVR32DB32 AVR64DB32 AVR128DB32 -const Register_file_t rgftab_avr32db32[477] = { // I/O memory [0, 4159] +const Register_file rgftab_avr32db32[477] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -47837,7 +47837,7 @@ const Register_file_t rgftab_avr32db32[477] = { // I/O memory [0, 4159] }; // AVR32DA48 -const Register_file_t rgftab_avr32da48[600] = { // I/O memory [0, 4159] +const Register_file rgftab_avr32da48[600] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -48441,7 +48441,7 @@ const Register_file_t rgftab_avr32da48[600] = { // I/O memory [0, 4159] }; // AVR32DB48 AVR64DB48 AVR128DB48 -const Register_file_t rgftab_avr32db48[643] = { // I/O memory [0, 4159] +const Register_file rgftab_avr32db48[643] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, @@ -49088,7 +49088,7 @@ const Register_file_t rgftab_avr32db48[643] = { // I/O memory [0, 4159] }; // AVR64DA28 AVR128DA28 -const Register_file_t rgftab_avr64da28[433] = { // I/O memory [0, 4159] +const Register_file rgftab_avr64da28[433] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -49525,7 +49525,7 @@ const Register_file_t rgftab_avr64da28[433] = { // I/O memory [0, 4159] }; // AVR64DA32 AVR128DA32 -const Register_file_t rgftab_avr64da32[448] = { // I/O memory [0, 4159] +const Register_file rgftab_avr64da32[448] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -49977,7 +49977,7 @@ const Register_file_t rgftab_avr64da32[448] = { // I/O memory [0, 4159] }; // AVR64DA48 AVR128DA48 -const Register_file_t rgftab_avr64da48[601] = { // I/O memory [0, 4159] +const Register_file rgftab_avr64da48[601] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -50582,7 +50582,7 @@ const Register_file_t rgftab_avr64da48[601] = { // I/O memory [0, 4159] }; // AVR64DA64 AVR128DA64 -const Register_file_t rgftab_avr64da64[659] = { // I/O memory [0, 4159] +const Register_file rgftab_avr64da64[659] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, 0x00, "data direction register"}, {"vporta.out", 0x0001, 1, -1, 0x00, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, 0x00, "I/O port input register"}, @@ -51245,7 +51245,7 @@ const Register_file_t rgftab_avr64da64[659] = { // I/O memory [0, 4159] }; // AVR64DB64 AVR128DB64 -const Register_file_t rgftab_avr64db64[698] = { // I/O memory [0, 4159] +const Register_file rgftab_avr64db64[698] = { // I/O memory [0, 4159] {"vporta.dir", 0x0000, 1, -1, -1, "data direction register"}, {"vporta.out", 0x0001, 1, -1, -1, "I/O port output register"}, {"vporta.in", 0x0002, 1, -1, -1, "I/O port input register"}, diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index fbfb56f2..4eee1061 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -12,7 +12,7 @@ * Meta-author Stefan Rueger * * v 1.3 - * 08.05.2024 + * 20.05.2024 * */ @@ -27,19 +27,19 @@ typedef struct { int value; // Value (to be shifted into mask position) const char *label; // Symbolic label for this config item const char *vcomment; // Expanded semantic comment -} Valueitem_t; +} Configvalue; typedef struct { const char *name; // Name of this configuration item int nvalues; // Number of (symbolic) values - const Valueitem_t *vlist; // Pointer to nvalues value items + const Configvalue *vlist; // Pointer to nvalues value items const char *memstr; // Fuse/Lock memory for this configuration int memoffset; // Byte offset within fuses (always 0 for lock) int mask; // Bit mask of fuse/lock memory int lsh; // Values need shifting left by lsh to be in mask int initval; // Factory default, to be shifted into mask position const char *ccomment; // Expanded semantic name for this configuration item -} Configitem_t; +} Configitem; typedef struct { const char *reg; // Name of I/O register @@ -48,7 +48,7 @@ typedef struct { int mask; // Bit mask for register, if any (-1 means none/unknown) int initval; // Reset value, if any (-1 means none/unknown) const char *caption; // Expanded semantic name -} Register_file_t; +} Register_file; typedef struct { // Value of -1 typically means unknown const char *name; // Name of part @@ -70,10 +70,10 @@ typedef struct { // Value of -1 typically means unknown uint8_t ninterrupts; // Number of vectors in interrupt vector table const char * const *isrtable; // Interrupt vector table vector names uint8_t nconfigs; // Number of configuration bitfields in fuses/locks - const Configitem_t *cfgtable; // Configuration bitfield table + const Configitem *cfgtable; // Configuration bitfield table uint16_t nregisters; // Number of I/O registers - const Register_file_t *regf; // Register file -} uPcore_t; + const Register_file *regf; // Register file +} Avrintel; #define F_AVR8L 1 // TPI programming, ATtiny(4|5|9|10|20|40|102|104) #define F_AVR8 2 // ISP programming with SPI, "classic" AVRs @@ -82,7 +82,7 @@ typedef struct { // Value of -1 typically means unknown #define UB_N_MCU 2040 // mcuid is in 0..2039 -extern const uPcore_t uP_table[394]; +extern const Avrintel uP_table[394]; // MCU id: running number in arbitrary order; once assigned never change for backward compatibility @@ -1745,54 +1745,54 @@ extern const char * const vtab_avr128db64[65]; // Configuration table names -extern const Configitem_t cfgtab_atmega328[14]; +extern const Configitem cfgtab_atmega328[14]; #define cfgtab_atmega328p cfgtab_atmega328 #define cfgtab_ata6614q cfgtab_atmega328 -extern const Configitem_t cfgtab_atmega16m1[17]; +extern const Configitem cfgtab_atmega16m1[17]; -extern const Configitem_t cfgtab_atmega16hva2[9]; +extern const Configitem cfgtab_atmega16hva2[9]; -extern const Configitem_t cfgtab_atmega32hvbrevb[12]; +extern const Configitem cfgtab_atmega32hvbrevb[12]; -extern const Configitem_t cfgtab_atmega64hve[13]; +extern const Configitem cfgtab_atmega64hve[13]; -extern const Configitem_t cfgtab_atmega328pb[15]; +extern const Configitem cfgtab_atmega328pb[15]; -extern const Configitem_t cfgtab_atmega8515[13]; +extern const Configitem cfgtab_atmega8515[13]; -extern const Configitem_t cfgtab_attiny102[5]; +extern const Configitem cfgtab_attiny102[5]; #define cfgtab_attiny104 cfgtab_attiny102 -extern const Configitem_t cfgtab_attiny28[3]; +extern const Configitem cfgtab_attiny28[3]; -extern const Configitem_t cfgtab_attiny441[14]; +extern const Configitem cfgtab_attiny441[14]; #define cfgtab_attiny841 cfgtab_attiny441 -extern const Configitem_t cfgtab_at90pwm2[18]; +extern const Configitem cfgtab_at90pwm2[18]; #define cfgtab_at90pwm3 cfgtab_at90pwm2 -extern const Configitem_t cfgtab_at90pwm81[19]; +extern const Configitem cfgtab_at90pwm81[19]; #define cfgtab_at90pwm161 cfgtab_at90pwm81 -extern const Configitem_t cfgtab_at90can128[15]; +extern const Configitem cfgtab_at90can128[15]; -extern const Configitem_t cfgtab_at90usb162[15]; +extern const Configitem cfgtab_at90usb162[15]; #define cfgtab_atmega16u2 cfgtab_at90usb162 #define cfgtab_at90usb82 cfgtab_at90usb162 -extern const Configitem_t cfgtab_at90s1200[3]; +extern const Configitem cfgtab_at90s1200[3]; -extern const Configitem_t cfgtab_at90s2313[3]; +extern const Configitem cfgtab_at90s2313[3]; #define cfgtab_at90s4414 cfgtab_at90s2313 #define cfgtab_at90s4434 cfgtab_at90s2313 #define cfgtab_at90s8515 cfgtab_at90s2313 #define cfgtab_at90s8535 cfgtab_at90s2313 -extern const Configitem_t cfgtab_ata5700m322[9]; +extern const Configitem cfgtab_ata5700m322[9]; #define cfgtab_ata5702m322 cfgtab_ata5700m322 -extern const Configitem_t cfgtab_ata5781[11]; +extern const Configitem cfgtab_ata5781[11]; #define cfgtab_ata5782 cfgtab_ata5781 #define cfgtab_ata5783 cfgtab_ata5781 #define cfgtab_ata5831 cfgtab_ata5781 @@ -1803,17 +1803,17 @@ extern const Configitem_t cfgtab_ata5781[11]; #define cfgtab_ata8510 cfgtab_ata5781 #define cfgtab_ata8515 cfgtab_ata5781 -extern const Configitem_t cfgtab_ata5790[11]; +extern const Configitem cfgtab_ata5790[11]; #define cfgtab_ata5791 cfgtab_ata5790 -extern const Configitem_t cfgtab_ata6285[17]; +extern const Configitem cfgtab_ata6285[17]; #define cfgtab_ata6286 cfgtab_ata6285 -extern const Configitem_t cfgtab_atxmega16e5[17]; +extern const Configitem cfgtab_atxmega16e5[17]; #define cfgtab_atxmega8e5 cfgtab_atxmega16e5 #define cfgtab_atxmega32e5 cfgtab_atxmega16e5 -extern const Configitem_t cfgtab_atxmega128a3[16]; +extern const Configitem cfgtab_atxmega128a3[16]; #define cfgtab_atxmega64a1 cfgtab_atxmega128a3 #define cfgtab_atxmega64a3 cfgtab_atxmega128a3 #define cfgtab_atxmega128a1 cfgtab_atxmega128a3 @@ -1822,7 +1822,7 @@ extern const Configitem_t cfgtab_atxmega128a3[16]; #define cfgtab_atxmega256a3 cfgtab_atxmega128a3 #define cfgtab_atxmega256a3b cfgtab_atxmega128a3 -extern const Configitem_t cfgtab_atxmega128a3u[17]; +extern const Configitem cfgtab_atxmega128a3u[17]; #define cfgtab_atxmega16a4u cfgtab_atxmega128a3u #define cfgtab_atxmega32a4u cfgtab_atxmega128a3u #define cfgtab_atxmega64a1u cfgtab_atxmega128a3u @@ -1834,7 +1834,7 @@ extern const Configitem_t cfgtab_atxmega128a3u[17]; #define cfgtab_atxmega256a3bu cfgtab_atxmega128a3u #define cfgtab_atxmega256a3u cfgtab_atxmega128a3u -extern const Configitem_t cfgtab_attiny204[23]; +extern const Configitem cfgtab_attiny204[23]; #define cfgtab_attiny202 cfgtab_attiny204 #define cfgtab_attiny212 cfgtab_attiny204 #define cfgtab_attiny214 cfgtab_attiny204 @@ -1854,7 +1854,7 @@ extern const Configitem_t cfgtab_attiny204[23]; #define cfgtab_attiny3216 cfgtab_attiny204 #define cfgtab_attiny3217 cfgtab_attiny204 -extern const Configitem_t cfgtab_attiny1624[16]; +extern const Configitem cfgtab_attiny1624[16]; #define cfgtab_attiny424 cfgtab_attiny1624 #define cfgtab_attiny426 cfgtab_attiny1624 #define cfgtab_attiny427 cfgtab_attiny1624 @@ -1867,7 +1867,7 @@ extern const Configitem_t cfgtab_attiny1624[16]; #define cfgtab_attiny3226 cfgtab_attiny1624 #define cfgtab_attiny3227 cfgtab_attiny1624 -extern const Configitem_t cfgtab_avr32dd14[17]; +extern const Configitem cfgtab_avr32dd14[17]; #define cfgtab_avr16dd14 cfgtab_avr32dd14 #define cfgtab_avr16dd20 cfgtab_avr32dd14 #define cfgtab_avr16dd28 cfgtab_avr32dd14 @@ -1880,7 +1880,7 @@ extern const Configitem_t cfgtab_avr32dd14[17]; #define cfgtab_avr64dd28 cfgtab_avr32dd14 #define cfgtab_avr64dd32 cfgtab_avr32dd14 -extern const Configitem_t cfgtab_avr64ea48[16]; +extern const Configitem cfgtab_avr64ea48[16]; #define cfgtab_avr16ea28 cfgtab_avr64ea48 #define cfgtab_avr16ea32 cfgtab_avr64ea48 #define cfgtab_avr16ea48 cfgtab_avr64ea48 @@ -1890,48 +1890,48 @@ extern const Configitem_t cfgtab_avr64ea48[16]; #define cfgtab_avr64ea28 cfgtab_avr64ea48 #define cfgtab_avr64ea32 cfgtab_avr64ea48 -extern const Configitem_t cfgtab_atmega103comp[15]; +extern const Configitem cfgtab_atmega103comp[15]; -extern const Configitem_t cfgtab_at90scr100h[13]; +extern const Configitem cfgtab_at90scr100h[13]; #define cfgtab_at90scr100 cfgtab_at90scr100h -extern const Configitem_t cfgtab_atmega161comp[15]; +extern const Configitem cfgtab_atmega161comp[15]; -extern const Configitem_t cfgtab_at90s8535comp[13]; +extern const Configitem cfgtab_at90s8535comp[13]; -extern const Configitem_t cfgtab_attiny4[4]; +extern const Configitem cfgtab_attiny4[4]; #define cfgtab_attiny5 cfgtab_attiny4 #define cfgtab_attiny9 cfgtab_attiny4 #define cfgtab_attiny10 cfgtab_attiny4 -extern const Configitem_t cfgtab_attiny20[5]; +extern const Configitem cfgtab_attiny20[5]; #define cfgtab_attiny40 cfgtab_attiny20 -extern const Configitem_t cfgtab_attiny11[4]; +extern const Configitem cfgtab_attiny11[4]; -extern const Configitem_t cfgtab_attiny12[6]; +extern const Configitem cfgtab_attiny12[6]; -extern const Configitem_t cfgtab_attiny13[10]; +extern const Configitem cfgtab_attiny13[10]; #define cfgtab_attiny13a cfgtab_attiny13 -extern const Configitem_t cfgtab_attiny15[6]; +extern const Configitem cfgtab_attiny15[6]; -extern const Configitem_t cfgtab_attiny22[3]; +extern const Configitem cfgtab_attiny22[3]; -extern const Configitem_t cfgtab_attiny24[11]; +extern const Configitem cfgtab_attiny24[11]; #define cfgtab_attiny24a cfgtab_attiny24 #define cfgtab_attiny44 cfgtab_attiny24 #define cfgtab_attiny44a cfgtab_attiny24 #define cfgtab_attiny84 cfgtab_attiny24 #define cfgtab_attiny84a cfgtab_attiny24 -extern const Configitem_t cfgtab_attiny25[11]; +extern const Configitem cfgtab_attiny25[11]; #define cfgtab_attiny45 cfgtab_attiny25 #define cfgtab_attiny85 cfgtab_attiny25 -extern const Configitem_t cfgtab_attiny26[8]; +extern const Configitem cfgtab_attiny26[8]; -extern const Configitem_t cfgtab_attiny43u[11]; +extern const Configitem cfgtab_attiny43u[11]; #define cfgtab_attiny261 cfgtab_attiny43u #define cfgtab_attiny261a cfgtab_attiny43u #define cfgtab_attiny461 cfgtab_attiny43u @@ -1939,10 +1939,10 @@ extern const Configitem_t cfgtab_attiny43u[11]; #define cfgtab_attiny861 cfgtab_attiny43u #define cfgtab_attiny861a cfgtab_attiny43u -extern const Configitem_t cfgtab_attiny48[11]; +extern const Configitem cfgtab_attiny48[11]; #define cfgtab_attiny88 cfgtab_attiny48 -extern const Configitem_t cfgtab_attiny87[11]; +extern const Configitem cfgtab_attiny87[11]; #define cfgtab_attiny167 cfgtab_attiny87 #define cfgtab_ata5272 cfgtab_attiny87 #define cfgtab_ata5505 cfgtab_attiny87 @@ -1950,96 +1950,96 @@ extern const Configitem_t cfgtab_attiny87[11]; #define cfgtab_ata6617c cfgtab_attiny87 #define cfgtab_ata664251 cfgtab_attiny87 -extern const Configitem_t cfgtab_attiny828[16]; +extern const Configitem cfgtab_attiny828[16]; #define cfgtab_attiny828r cfgtab_attiny828 -extern const Configitem_t cfgtab_attiny1634[13]; +extern const Configitem cfgtab_attiny1634[13]; #define cfgtab_attiny1634r cfgtab_attiny1634 -extern const Configitem_t cfgtab_attiny2313[11]; +extern const Configitem cfgtab_attiny2313[11]; -extern const Configitem_t cfgtab_attiny2313a[11]; +extern const Configitem cfgtab_attiny2313a[11]; #define cfgtab_attiny4313 cfgtab_attiny2313a -extern const Configitem_t cfgtab_atmega8[13]; +extern const Configitem cfgtab_atmega8[13]; #define cfgtab_atmega8a cfgtab_atmega8 -extern const Configitem_t cfgtab_atmega8hva[7]; +extern const Configitem cfgtab_atmega8hva[7]; #define cfgtab_atmega16hva cfgtab_atmega8hva -extern const Configitem_t cfgtab_atmega8u2[15]; +extern const Configitem cfgtab_atmega8u2[15]; -extern const Configitem_t cfgtab_atmega16[13]; +extern const Configitem cfgtab_atmega16[13]; #define cfgtab_atmega16a cfgtab_atmega16 -extern const Configitem_t cfgtab_atmega16hvb[12]; +extern const Configitem cfgtab_atmega16hvb[12]; -extern const Configitem_t cfgtab_atmega16hvbrevb[12]; +extern const Configitem cfgtab_atmega16hvbrevb[12]; -extern const Configitem_t cfgtab_atmega16u4[15]; +extern const Configitem cfgtab_atmega16u4[15]; -extern const Configitem_t cfgtab_atmega32[13]; +extern const Configitem cfgtab_atmega32[13]; #define cfgtab_atmega32a cfgtab_atmega32 -extern const Configitem_t cfgtab_atmega32hvb[12]; +extern const Configitem cfgtab_atmega32hvb[12]; -extern const Configitem_t cfgtab_atmega32c1[17]; +extern const Configitem cfgtab_atmega32c1[17]; #define cfgtab_atmega32m1 cfgtab_atmega32c1 -extern const Configitem_t cfgtab_atmega32u2[15]; +extern const Configitem cfgtab_atmega32u2[15]; -extern const Configitem_t cfgtab_atmega32u4[15]; +extern const Configitem cfgtab_atmega32u4[15]; -extern const Configitem_t cfgtab_atmega32u6[15]; +extern const Configitem cfgtab_atmega32u6[15]; -extern const Configitem_t cfgtab_atmega48[11]; +extern const Configitem cfgtab_atmega48[11]; #define cfgtab_atmega48a cfgtab_atmega48 #define cfgtab_atmega48p cfgtab_atmega48 #define cfgtab_atmega48pa cfgtab_atmega48 -extern const Configitem_t cfgtab_atmega48pb[11]; +extern const Configitem cfgtab_atmega48pb[11]; -extern const Configitem_t cfgtab_atmega64[15]; +extern const Configitem cfgtab_atmega64[15]; #define cfgtab_atmega64a cfgtab_atmega64 -extern const Configitem_t cfgtab_atmega64c1[17]; +extern const Configitem cfgtab_atmega64c1[17]; #define cfgtab_atmega64m1 cfgtab_atmega64c1 -extern const Configitem_t cfgtab_atmega64hve2[13]; +extern const Configitem cfgtab_atmega64hve2[13]; #define cfgtab_atmega32hve2 cfgtab_atmega64hve2 -extern const Configitem_t cfgtab_atmega64rfr2[14]; +extern const Configitem cfgtab_atmega64rfr2[14]; #define cfgtab_atmega644rfr2 cfgtab_atmega64rfr2 -extern const Configitem_t cfgtab_atmega88[14]; +extern const Configitem cfgtab_atmega88[14]; #define cfgtab_atmega88a cfgtab_atmega88 #define cfgtab_atmega88p cfgtab_atmega88 #define cfgtab_atmega88pa cfgtab_atmega88 #define cfgtab_ata6612c cfgtab_atmega88 -extern const Configitem_t cfgtab_atmega88pb[14]; +extern const Configitem cfgtab_atmega88pb[14]; -extern const Configitem_t cfgtab_atmega103[4]; +extern const Configitem cfgtab_atmega103[4]; -extern const Configitem_t cfgtab_atmega128[15]; +extern const Configitem cfgtab_atmega128[15]; #define cfgtab_atmega128a cfgtab_atmega128 -extern const Configitem_t cfgtab_atmega128rfa1[14]; +extern const Configitem cfgtab_atmega128rfa1[14]; -extern const Configitem_t cfgtab_atmega128rfr2[14]; +extern const Configitem cfgtab_atmega128rfr2[14]; #define cfgtab_atmega1284rfr2 cfgtab_atmega128rfr2 -extern const Configitem_t cfgtab_atmega161[7]; +extern const Configitem cfgtab_atmega161[7]; -extern const Configitem_t cfgtab_atmega162[15]; +extern const Configitem cfgtab_atmega162[15]; -extern const Configitem_t cfgtab_atmega163[9]; +extern const Configitem cfgtab_atmega163[9]; -extern const Configitem_t cfgtab_atmega164a[14]; +extern const Configitem cfgtab_atmega164a[14]; #define cfgtab_atmega164p cfgtab_atmega164a #define cfgtab_atmega164pa cfgtab_atmega164a -extern const Configitem_t cfgtab_atmega165[15]; +extern const Configitem cfgtab_atmega165[15]; #define cfgtab_atmega165a cfgtab_atmega165 #define cfgtab_atmega165p cfgtab_atmega165 #define cfgtab_atmega165pa cfgtab_atmega165 @@ -2048,26 +2048,26 @@ extern const Configitem_t cfgtab_atmega165[15]; #define cfgtab_atmega169p cfgtab_atmega165 #define cfgtab_atmega169pa cfgtab_atmega165 -extern const Configitem_t cfgtab_atmega168[14]; +extern const Configitem cfgtab_atmega168[14]; #define cfgtab_atmega168a cfgtab_atmega168 #define cfgtab_atmega168p cfgtab_atmega168 #define cfgtab_atmega168pa cfgtab_atmega168 #define cfgtab_ata6613c cfgtab_atmega168 -extern const Configitem_t cfgtab_atmega168pb[14]; +extern const Configitem cfgtab_atmega168pb[14]; -extern const Configitem_t cfgtab_atmega256rfr2[14]; +extern const Configitem cfgtab_atmega256rfr2[14]; #define cfgtab_atmega2564rfr2 cfgtab_atmega256rfr2 -extern const Configitem_t cfgtab_atmega323[12]; +extern const Configitem cfgtab_atmega323[12]; -extern const Configitem_t cfgtab_atmega324a[14]; +extern const Configitem cfgtab_atmega324a[14]; #define cfgtab_atmega324p cfgtab_atmega324a #define cfgtab_atmega324pa cfgtab_atmega324a -extern const Configitem_t cfgtab_atmega324pb[15]; +extern const Configitem cfgtab_atmega324pb[15]; -extern const Configitem_t cfgtab_atmega325[15]; +extern const Configitem cfgtab_atmega325[15]; #define cfgtab_atmega325a cfgtab_atmega325 #define cfgtab_atmega325p cfgtab_atmega325 #define cfgtab_atmega325pa cfgtab_atmega325 @@ -2084,16 +2084,16 @@ extern const Configitem_t cfgtab_atmega325[15]; #define cfgtab_atmega3290p cfgtab_atmega325 #define cfgtab_atmega3290pa cfgtab_atmega325 -extern const Configitem_t cfgtab_atmega406[10]; +extern const Configitem cfgtab_atmega406[10]; -extern const Configitem_t cfgtab_atmega640[14]; +extern const Configitem cfgtab_atmega640[14]; -extern const Configitem_t cfgtab_atmega644[14]; +extern const Configitem cfgtab_atmega644[14]; #define cfgtab_atmega644a cfgtab_atmega644 #define cfgtab_atmega644p cfgtab_atmega644 #define cfgtab_atmega644pa cfgtab_atmega644 -extern const Configitem_t cfgtab_atmega645[15]; +extern const Configitem cfgtab_atmega645[15]; #define cfgtab_atmega645a cfgtab_atmega645 #define cfgtab_atmega645p cfgtab_atmega645 #define cfgtab_atmega649 cfgtab_atmega645 @@ -2106,58 +2106,58 @@ extern const Configitem_t cfgtab_atmega645[15]; #define cfgtab_atmega6490a cfgtab_atmega645 #define cfgtab_atmega6490p cfgtab_atmega645 -extern const Configitem_t cfgtab_atmega1280[14]; +extern const Configitem cfgtab_atmega1280[14]; #define cfgtab_atmega1281 cfgtab_atmega1280 -extern const Configitem_t cfgtab_atmega1284[14]; +extern const Configitem cfgtab_atmega1284[14]; #define cfgtab_atmega1284p cfgtab_atmega1284 -extern const Configitem_t cfgtab_atmega2560[14]; +extern const Configitem cfgtab_atmega2560[14]; #define cfgtab_atmega2561 cfgtab_atmega2560 -extern const Configitem_t cfgtab_atmega8535[13]; +extern const Configitem cfgtab_atmega8535[13]; -extern const Configitem_t cfgtab_at90pwm1[17]; +extern const Configitem cfgtab_at90pwm1[17]; -extern const Configitem_t cfgtab_at90pwm2b[18]; +extern const Configitem cfgtab_at90pwm2b[18]; #define cfgtab_at90pwm3b cfgtab_at90pwm2b -extern const Configitem_t cfgtab_at90can32[15]; +extern const Configitem cfgtab_at90can32[15]; -extern const Configitem_t cfgtab_at90can64[15]; +extern const Configitem cfgtab_at90can64[15]; -extern const Configitem_t cfgtab_at90pwm216[18]; +extern const Configitem cfgtab_at90pwm216[18]; -extern const Configitem_t cfgtab_at90pwm316[18]; +extern const Configitem cfgtab_at90pwm316[18]; -extern const Configitem_t cfgtab_at90usb646[15]; +extern const Configitem cfgtab_at90usb646[15]; #define cfgtab_at90usb647 cfgtab_at90usb646 -extern const Configitem_t cfgtab_at90usb1286[15]; +extern const Configitem cfgtab_at90usb1286[15]; #define cfgtab_at90usb1287 cfgtab_at90usb1286 -extern const Configitem_t cfgtab_at90s2323[3]; +extern const Configitem cfgtab_at90s2323[3]; -extern const Configitem_t cfgtab_at90s2333[5]; +extern const Configitem cfgtab_at90s2333[5]; -extern const Configitem_t cfgtab_at90s2343[3]; +extern const Configitem cfgtab_at90s2343[3]; -extern const Configitem_t cfgtab_at90s4433[5]; +extern const Configitem cfgtab_at90s4433[5]; -extern const Configitem_t cfgtab_at90s8515comp[13]; +extern const Configitem cfgtab_at90s8515comp[13]; -extern const Configitem_t cfgtab_ata5787[11]; +extern const Configitem cfgtab_ata5787[11]; #define cfgtab_ata5835 cfgtab_ata5787 -extern const Configitem_t cfgtab_ata5790n[10]; +extern const Configitem cfgtab_ata5790n[10]; #define cfgtab_ata5795 cfgtab_ata5790n -extern const Configitem_t cfgtab_ata6289[17]; +extern const Configitem cfgtab_ata6289[17]; -extern const Configitem_t cfgtab_atxmega16a4[16]; +extern const Configitem cfgtab_atxmega16a4[16]; #define cfgtab_atxmega32a4 cfgtab_atxmega16a4 -extern const Configitem_t cfgtab_atxmega16c4[15]; +extern const Configitem cfgtab_atxmega16c4[15]; #define cfgtab_atxmega16d4 cfgtab_atxmega16c4 #define cfgtab_atxmega32c3 cfgtab_atxmega16c4 #define cfgtab_atxmega32d3 cfgtab_atxmega16c4 @@ -2176,21 +2176,21 @@ extern const Configitem_t cfgtab_atxmega16c4[15]; #define cfgtab_atxmega384c3 cfgtab_atxmega16c4 #define cfgtab_atxmega384d3 cfgtab_atxmega16c4 -extern const Configitem_t cfgtab_atxmega64b1[17]; +extern const Configitem cfgtab_atxmega64b1[17]; #define cfgtab_atxmega64b3 cfgtab_atxmega64b1 #define cfgtab_atxmega128b1 cfgtab_atxmega64b1 #define cfgtab_atxmega128b3 cfgtab_atxmega64b1 -extern const Configitem_t cfgtab_attiny416auto[23]; +extern const Configitem cfgtab_attiny416auto[23]; -extern const Configitem_t cfgtab_attiny804[15]; +extern const Configitem cfgtab_attiny804[15]; #define cfgtab_attiny806 cfgtab_attiny804 #define cfgtab_attiny807 cfgtab_attiny804 #define cfgtab_attiny1604 cfgtab_attiny804 #define cfgtab_attiny1606 cfgtab_attiny804 #define cfgtab_attiny1607 cfgtab_attiny804 -extern const Configitem_t cfgtab_atmega808[15]; +extern const Configitem cfgtab_atmega808[15]; #define cfgtab_atmega809 cfgtab_atmega808 #define cfgtab_atmega1608 cfgtab_atmega808 #define cfgtab_atmega1609 cfgtab_atmega808 @@ -2199,7 +2199,7 @@ extern const Configitem_t cfgtab_atmega808[15]; #define cfgtab_atmega4808 cfgtab_atmega808 #define cfgtab_atmega4809 cfgtab_atmega808 -extern const Configitem_t cfgtab_avr16du14[20]; +extern const Configitem cfgtab_avr16du14[20]; #define cfgtab_avr16du20 cfgtab_avr16du14 #define cfgtab_avr16du28 cfgtab_avr16du14 #define cfgtab_avr16du32 cfgtab_avr16du14 @@ -2210,12 +2210,12 @@ extern const Configitem_t cfgtab_avr16du14[20]; #define cfgtab_avr64du28 cfgtab_avr16du14 #define cfgtab_avr64du32 cfgtab_avr16du14 -extern const Configitem_t cfgtab_avr16eb14[18]; +extern const Configitem cfgtab_avr16eb14[18]; #define cfgtab_avr16eb20 cfgtab_avr16eb14 #define cfgtab_avr16eb28 cfgtab_avr16eb14 #define cfgtab_avr16eb32 cfgtab_avr16eb14 -extern const Configitem_t cfgtab_avr32da28[15]; +extern const Configitem cfgtab_avr32da28[15]; #define cfgtab_avr32da32 cfgtab_avr32da28 #define cfgtab_avr32da48 cfgtab_avr32da28 #define cfgtab_avr64da28 cfgtab_avr32da28 @@ -2227,7 +2227,7 @@ extern const Configitem_t cfgtab_avr32da28[15]; #define cfgtab_avr128da48 cfgtab_avr32da28 #define cfgtab_avr128da64 cfgtab_avr32da28 -extern const Configitem_t cfgtab_avr32db28[16]; +extern const Configitem cfgtab_avr32db28[16]; #define cfgtab_avr32db32 cfgtab_avr32db28 #define cfgtab_avr32db48 cfgtab_avr32db28 #define cfgtab_avr64db28 cfgtab_avr32db28 @@ -2241,74 +2241,74 @@ extern const Configitem_t cfgtab_avr32db28[16]; // I/O Register files -extern const Register_file_t rgftab_atmega328[81]; +extern const Register_file rgftab_atmega328[81]; #define rgftab_atmega328p rgftab_atmega328 -extern const Register_file_t rgftab_atmega16m1[136]; +extern const Register_file rgftab_atmega16m1[136]; #define rgftab_atmega32m1 rgftab_atmega16m1 -extern const Register_file_t rgftab_atmega32hvbrevb[91]; +extern const Register_file rgftab_atmega32hvbrevb[91]; #define rgftab_atmega16hvb rgftab_atmega32hvbrevb #define rgftab_atmega16hvbrevb rgftab_atmega32hvbrevb #define rgftab_atmega32hvb rgftab_atmega32hvbrevb -extern const Register_file_t rgftab_atmega328pb[123]; +extern const Register_file rgftab_atmega328pb[123]; -extern const Register_file_t rgftab_atmega8515[52]; +extern const Register_file rgftab_atmega8515[52]; -extern const Register_file_t rgftab_attiny102[55]; +extern const Register_file rgftab_attiny102[55]; #define rgftab_attiny104 rgftab_attiny102 -extern const Register_file_t rgftab_attiny28[20]; +extern const Register_file rgftab_attiny28[20]; -extern const Register_file_t rgftab_attiny441[101]; +extern const Register_file rgftab_attiny441[101]; #define rgftab_attiny841 rgftab_attiny441 -extern const Register_file_t rgftab_at90pwm81[84]; +extern const Register_file rgftab_at90pwm81[84]; -extern const Register_file_t rgftab_at90can128[137]; +extern const Register_file rgftab_at90can128[137]; #define rgftab_at90can32 rgftab_at90can128 #define rgftab_at90can64 rgftab_at90can128 -extern const Register_file_t rgftab_at90usb162[92]; +extern const Register_file rgftab_at90usb162[92]; #define rgftab_at90usb82 rgftab_at90usb162 -extern const Register_file_t rgftab_ata5700m322[337]; +extern const Register_file rgftab_ata5700m322[337]; -extern const Register_file_t rgftab_ata5781[262]; +extern const Register_file rgftab_ata5781[262]; #define rgftab_ata5782 rgftab_ata5781 #define rgftab_ata5783 rgftab_ata5781 #define rgftab_ata8210 rgftab_ata5781 #define rgftab_ata8215 rgftab_ata5781 -extern const Register_file_t rgftab_ata5790[112]; +extern const Register_file rgftab_ata5790[112]; -extern const Register_file_t rgftab_ata6285[79]; +extern const Register_file rgftab_ata6285[79]; #define rgftab_ata6286 rgftab_ata6285 -extern const Register_file_t rgftab_atxmega16e5[438]; +extern const Register_file rgftab_atxmega16e5[438]; #define rgftab_atxmega8e5 rgftab_atxmega16e5 #define rgftab_atxmega32e5 rgftab_atxmega16e5 -extern const Register_file_t rgftab_atxmega128a3[680]; +extern const Register_file rgftab_atxmega128a3[680]; #define rgftab_atxmega64a3 rgftab_atxmega128a3 #define rgftab_atxmega192a3 rgftab_atxmega128a3 #define rgftab_atxmega256a3 rgftab_atxmega128a3 -extern const Register_file_t rgftab_atxmega128a3u[792]; +extern const Register_file rgftab_atxmega128a3u[792]; #define rgftab_atxmega64a3u rgftab_atxmega128a3u #define rgftab_atxmega192a3u rgftab_atxmega128a3u #define rgftab_atxmega256a3u rgftab_atxmega128a3u -extern const Register_file_t rgftab_attiny204[235]; +extern const Register_file rgftab_attiny204[235]; #define rgftab_attiny404 rgftab_attiny204 -extern const Register_file_t rgftab_attiny1624[307]; +extern const Register_file rgftab_attiny1624[307]; #define rgftab_attiny424 rgftab_attiny1624 #define rgftab_attiny824 rgftab_attiny1624 #define rgftab_attiny3224 rgftab_attiny1624 -extern const Register_file_t rgftab_avr32dd14[401]; +extern const Register_file rgftab_avr32dd14[401]; #define rgftab_avr16dd14 rgftab_avr32dd14 #define rgftab_avr16dd20 rgftab_avr32dd14 #define rgftab_avr16dd28 rgftab_avr32dd14 @@ -2321,118 +2321,118 @@ extern const Register_file_t rgftab_avr32dd14[401]; #define rgftab_avr64dd28 rgftab_avr32dd14 #define rgftab_avr64dd32 rgftab_avr32dd14 -extern const Register_file_t rgftab_avr64ea48[502]; +extern const Register_file rgftab_avr64ea48[502]; #define rgftab_avr16ea48 rgftab_avr64ea48 #define rgftab_avr32ea48 rgftab_avr64ea48 -extern const Register_file_t rgftab_attiny4[36]; +extern const Register_file rgftab_attiny4[36]; #define rgftab_attiny9 rgftab_attiny4 -extern const Register_file_t rgftab_attiny5[41]; +extern const Register_file rgftab_attiny5[41]; #define rgftab_attiny10 rgftab_attiny5 -extern const Register_file_t rgftab_attiny20[61]; +extern const Register_file rgftab_attiny20[61]; -extern const Register_file_t rgftab_attiny40[63]; +extern const Register_file rgftab_attiny40[63]; -extern const Register_file_t rgftab_attiny11[14]; +extern const Register_file rgftab_attiny11[14]; -extern const Register_file_t rgftab_attiny12[18]; +extern const Register_file rgftab_attiny12[18]; -extern const Register_file_t rgftab_attiny13[35]; +extern const Register_file rgftab_attiny13[35]; -extern const Register_file_t rgftab_attiny13a[37]; +extern const Register_file rgftab_attiny13a[37]; -extern const Register_file_t rgftab_attiny15[28]; +extern const Register_file rgftab_attiny15[28]; -extern const Register_file_t rgftab_attiny24[55]; +extern const Register_file rgftab_attiny24[55]; #define rgftab_attiny24a rgftab_attiny24 -extern const Register_file_t rgftab_attiny25[55]; +extern const Register_file rgftab_attiny25[55]; -extern const Register_file_t rgftab_attiny26[37]; +extern const Register_file rgftab_attiny26[37]; -extern const Register_file_t rgftab_attiny43u[54]; +extern const Register_file rgftab_attiny43u[54]; -extern const Register_file_t rgftab_attiny44[55]; +extern const Register_file rgftab_attiny44[55]; #define rgftab_attiny44a rgftab_attiny44 -extern const Register_file_t rgftab_attiny45[55]; +extern const Register_file rgftab_attiny45[55]; #define rgftab_attiny85 rgftab_attiny45 -extern const Register_file_t rgftab_attiny48[74]; +extern const Register_file rgftab_attiny48[74]; -extern const Register_file_t rgftab_attiny84[55]; +extern const Register_file rgftab_attiny84[55]; #define rgftab_attiny84a rgftab_attiny84 -extern const Register_file_t rgftab_attiny87[80]; +extern const Register_file rgftab_attiny87[80]; #define rgftab_attiny167 rgftab_attiny87 -extern const Register_file_t rgftab_attiny88[74]; +extern const Register_file rgftab_attiny88[74]; -extern const Register_file_t rgftab_attiny261[63]; +extern const Register_file rgftab_attiny261[63]; #define rgftab_attiny261a rgftab_attiny261 -extern const Register_file_t rgftab_attiny461[63]; +extern const Register_file rgftab_attiny461[63]; #define rgftab_attiny461a rgftab_attiny461 -extern const Register_file_t rgftab_attiny828[94]; +extern const Register_file rgftab_attiny828[94]; -extern const Register_file_t rgftab_attiny861[63]; +extern const Register_file rgftab_attiny861[63]; #define rgftab_attiny861a rgftab_attiny861 -extern const Register_file_t rgftab_attiny1634[89]; +extern const Register_file rgftab_attiny1634[89]; -extern const Register_file_t rgftab_attiny2313[54]; +extern const Register_file rgftab_attiny2313[54]; -extern const Register_file_t rgftab_attiny2313a[58]; +extern const Register_file rgftab_attiny2313a[58]; -extern const Register_file_t rgftab_attiny4313[58]; +extern const Register_file rgftab_attiny4313[58]; -extern const Register_file_t rgftab_atmega8[61]; +extern const Register_file rgftab_atmega8[61]; #define rgftab_atmega8a rgftab_atmega8 -extern const Register_file_t rgftab_atmega8hva[74]; +extern const Register_file rgftab_atmega8hva[74]; #define rgftab_atmega16hva rgftab_atmega8hva -extern const Register_file_t rgftab_atmega8u2[92]; +extern const Register_file rgftab_atmega8u2[92]; #define rgftab_atmega16u2 rgftab_atmega8u2 #define rgftab_atmega32u2 rgftab_atmega8u2 -extern const Register_file_t rgftab_atmega16[70]; +extern const Register_file rgftab_atmega16[70]; -extern const Register_file_t rgftab_atmega16a[70]; +extern const Register_file rgftab_atmega16a[70]; -extern const Register_file_t rgftab_atmega16u4[139]; +extern const Register_file rgftab_atmega16u4[139]; #define rgftab_atmega32u4 rgftab_atmega16u4 -extern const Register_file_t rgftab_atmega32[68]; +extern const Register_file rgftab_atmega32[68]; -extern const Register_file_t rgftab_atmega32a[66]; +extern const Register_file rgftab_atmega32a[66]; -extern const Register_file_t rgftab_atmega32c1[117]; +extern const Register_file rgftab_atmega32c1[117]; -extern const Register_file_t rgftab_atmega48[81]; +extern const Register_file rgftab_atmega48[81]; #define rgftab_atmega48p rgftab_atmega48 -extern const Register_file_t rgftab_atmega48a[82]; +extern const Register_file rgftab_atmega48a[82]; #define rgftab_atmega48pa rgftab_atmega48a -extern const Register_file_t rgftab_atmega48pb[95]; +extern const Register_file rgftab_atmega48pb[95]; -extern const Register_file_t rgftab_atmega64[103]; +extern const Register_file rgftab_atmega64[103]; #define rgftab_atmega64a rgftab_atmega64 -extern const Register_file_t rgftab_atmega64c1[122]; +extern const Register_file rgftab_atmega64c1[122]; -extern const Register_file_t rgftab_atmega64m1[136]; +extern const Register_file rgftab_atmega64m1[136]; -extern const Register_file_t rgftab_atmega64hve2[89]; +extern const Register_file rgftab_atmega64hve2[89]; -extern const Register_file_t rgftab_atmega64rfr2[269]; +extern const Register_file rgftab_atmega64rfr2[269]; #define rgftab_atmega644rfr2 rgftab_atmega64rfr2 -extern const Register_file_t rgftab_atmega88[81]; +extern const Register_file rgftab_atmega88[81]; #define rgftab_atmega88a rgftab_atmega88 #define rgftab_atmega88p rgftab_atmega88 #define rgftab_atmega88pa rgftab_atmega88 @@ -2441,222 +2441,222 @@ extern const Register_file_t rgftab_atmega88[81]; #define rgftab_atmega168p rgftab_atmega88 #define rgftab_atmega168pa rgftab_atmega88 -extern const Register_file_t rgftab_atmega88pb[95]; +extern const Register_file rgftab_atmega88pb[95]; #define rgftab_atmega168pb rgftab_atmega88pb -extern const Register_file_t rgftab_atmega128[103]; +extern const Register_file rgftab_atmega128[103]; -extern const Register_file_t rgftab_atmega128a[103]; +extern const Register_file rgftab_atmega128a[103]; -extern const Register_file_t rgftab_atmega128rfa1[237]; +extern const Register_file rgftab_atmega128rfa1[237]; -extern const Register_file_t rgftab_atmega128rfr2[270]; +extern const Register_file rgftab_atmega128rfr2[270]; #define rgftab_atmega1284rfr2 rgftab_atmega128rfr2 -extern const Register_file_t rgftab_atmega162[79]; +extern const Register_file rgftab_atmega162[79]; -extern const Register_file_t rgftab_atmega164a[96]; +extern const Register_file rgftab_atmega164a[96]; #define rgftab_atmega164p rgftab_atmega164a #define rgftab_atmega164pa rgftab_atmega164a #define rgftab_atmega324a rgftab_atmega164a #define rgftab_atmega324p rgftab_atmega164a #define rgftab_atmega324pa rgftab_atmega164a -extern const Register_file_t rgftab_atmega165a[86]; +extern const Register_file rgftab_atmega165a[86]; #define rgftab_atmega165p rgftab_atmega165a #define rgftab_atmega165pa rgftab_atmega165a -extern const Register_file_t rgftab_atmega169a[106]; +extern const Register_file rgftab_atmega169a[106]; #define rgftab_atmega169p rgftab_atmega169a #define rgftab_atmega169pa rgftab_atmega169a -extern const Register_file_t rgftab_atmega256rfr2[271]; +extern const Register_file rgftab_atmega256rfr2[271]; -extern const Register_file_t rgftab_atmega324pb[134]; +extern const Register_file rgftab_atmega324pb[134]; -extern const Register_file_t rgftab_atmega325[86]; +extern const Register_file rgftab_atmega325[86]; #define rgftab_atmega325a rgftab_atmega325 #define rgftab_atmega325p rgftab_atmega325 #define rgftab_atmega325pa rgftab_atmega325 -extern const Register_file_t rgftab_atmega329[106]; +extern const Register_file rgftab_atmega329[106]; -extern const Register_file_t rgftab_atmega329a[106]; +extern const Register_file rgftab_atmega329a[106]; #define rgftab_atmega329pa rgftab_atmega329a -extern const Register_file_t rgftab_atmega329p[106]; +extern const Register_file rgftab_atmega329p[106]; -extern const Register_file_t rgftab_atmega406[79]; +extern const Register_file rgftab_atmega406[79]; -extern const Register_file_t rgftab_atmega640[160]; +extern const Register_file rgftab_atmega640[160]; -extern const Register_file_t rgftab_atmega644[88]; +extern const Register_file rgftab_atmega644[88]; -extern const Register_file_t rgftab_atmega644a[93]; +extern const Register_file rgftab_atmega644a[93]; #define rgftab_atmega644p rgftab_atmega644a #define rgftab_atmega644pa rgftab_atmega644a -extern const Register_file_t rgftab_atmega645[86]; +extern const Register_file rgftab_atmega645[86]; #define rgftab_atmega645a rgftab_atmega645 #define rgftab_atmega645p rgftab_atmega645 -extern const Register_file_t rgftab_atmega649[106]; +extern const Register_file rgftab_atmega649[106]; #define rgftab_atmega649a rgftab_atmega649 #define rgftab_atmega649p rgftab_atmega649 -extern const Register_file_t rgftab_atmega1280[161]; +extern const Register_file rgftab_atmega1280[161]; #define rgftab_atmega2560 rgftab_atmega1280 -extern const Register_file_t rgftab_atmega1281[138]; +extern const Register_file rgftab_atmega1281[138]; -extern const Register_file_t rgftab_atmega1284[104]; +extern const Register_file rgftab_atmega1284[104]; #define rgftab_atmega1284p rgftab_atmega1284 -extern const Register_file_t rgftab_atmega2561[139]; +extern const Register_file rgftab_atmega2561[139]; -extern const Register_file_t rgftab_atmega2564rfr2[271]; +extern const Register_file rgftab_atmega2564rfr2[271]; -extern const Register_file_t rgftab_atmega3250[94]; +extern const Register_file rgftab_atmega3250[94]; #define rgftab_atmega3250a rgftab_atmega3250 #define rgftab_atmega3250p rgftab_atmega3250 #define rgftab_atmega3250pa rgftab_atmega3250 -extern const Register_file_t rgftab_atmega3290[118]; +extern const Register_file rgftab_atmega3290[118]; #define rgftab_atmega3290a rgftab_atmega3290 -extern const Register_file_t rgftab_atmega3290p[118]; +extern const Register_file rgftab_atmega3290p[118]; -extern const Register_file_t rgftab_atmega3290pa[118]; +extern const Register_file rgftab_atmega3290pa[118]; -extern const Register_file_t rgftab_atmega6450[94]; +extern const Register_file rgftab_atmega6450[94]; #define rgftab_atmega6450a rgftab_atmega6450 #define rgftab_atmega6450p rgftab_atmega6450 -extern const Register_file_t rgftab_atmega6490[118]; +extern const Register_file rgftab_atmega6490[118]; #define rgftab_atmega6490a rgftab_atmega6490 #define rgftab_atmega6490p rgftab_atmega6490 -extern const Register_file_t rgftab_atmega8535[67]; +extern const Register_file rgftab_atmega8535[67]; -extern const Register_file_t rgftab_at90pwm1[92]; +extern const Register_file rgftab_at90pwm1[92]; -extern const Register_file_t rgftab_at90pwm2b[100]; +extern const Register_file rgftab_at90pwm2b[100]; -extern const Register_file_t rgftab_at90pwm3[115]; +extern const Register_file rgftab_at90pwm3[115]; -extern const Register_file_t rgftab_at90pwm3b[115]; +extern const Register_file rgftab_at90pwm3b[115]; -extern const Register_file_t rgftab_at90pwm161[86]; +extern const Register_file rgftab_at90pwm161[86]; -extern const Register_file_t rgftab_at90pwm216[102]; +extern const Register_file rgftab_at90pwm216[102]; -extern const Register_file_t rgftab_at90pwm316[117]; +extern const Register_file rgftab_at90pwm316[117]; -extern const Register_file_t rgftab_at90usb646[157]; +extern const Register_file rgftab_at90usb646[157]; #define rgftab_at90usb647 rgftab_at90usb646 #define rgftab_at90usb1287 rgftab_at90usb646 -extern const Register_file_t rgftab_at90usb1286[132]; +extern const Register_file rgftab_at90usb1286[132]; -extern const Register_file_t rgftab_ata5272[80]; +extern const Register_file rgftab_ata5272[80]; #define rgftab_ata5505 rgftab_ata5272 -extern const Register_file_t rgftab_ata5702m322[378]; +extern const Register_file rgftab_ata5702m322[378]; -extern const Register_file_t rgftab_ata5787[292]; +extern const Register_file rgftab_ata5787[292]; -extern const Register_file_t rgftab_ata5790n[117]; +extern const Register_file rgftab_ata5790n[117]; #define rgftab_ata5791 rgftab_ata5790n -extern const Register_file_t rgftab_ata5795[84]; +extern const Register_file rgftab_ata5795[84]; -extern const Register_file_t rgftab_ata5831[279]; +extern const Register_file rgftab_ata5831[279]; #define rgftab_ata5832 rgftab_ata5831 #define rgftab_ata5833 rgftab_ata5831 #define rgftab_ata8510 rgftab_ata5831 #define rgftab_ata8515 rgftab_ata5831 -extern const Register_file_t rgftab_ata5835[307]; +extern const Register_file rgftab_ata5835[307]; -extern const Register_file_t rgftab_ata6612c[81]; +extern const Register_file rgftab_ata6612c[81]; #define rgftab_ata6613c rgftab_ata6612c -extern const Register_file_t rgftab_ata6614q[81]; +extern const Register_file rgftab_ata6614q[81]; -extern const Register_file_t rgftab_ata6616c[81]; +extern const Register_file rgftab_ata6616c[81]; #define rgftab_ata6617c rgftab_ata6616c #define rgftab_ata664251 rgftab_ata6616c -extern const Register_file_t rgftab_atxmega16a4[553]; +extern const Register_file rgftab_atxmega16a4[553]; #define rgftab_atxmega32a4 rgftab_atxmega16a4 -extern const Register_file_t rgftab_atxmega16a4u[630]; +extern const Register_file rgftab_atxmega16a4u[630]; #define rgftab_atxmega32a4u rgftab_atxmega16a4u -extern const Register_file_t rgftab_atxmega16c4[482]; +extern const Register_file rgftab_atxmega16c4[482]; #define rgftab_atxmega32c4 rgftab_atxmega16c4 -extern const Register_file_t rgftab_atxmega16d4[460]; +extern const Register_file rgftab_atxmega16d4[460]; #define rgftab_atxmega32d4 rgftab_atxmega16d4 -extern const Register_file_t rgftab_atxmega32c3[569]; +extern const Register_file rgftab_atxmega32c3[569]; #define rgftab_atxmega64c3 rgftab_atxmega32c3 #define rgftab_atxmega128c3 rgftab_atxmega32c3 #define rgftab_atxmega192c3 rgftab_atxmega32c3 #define rgftab_atxmega256c3 rgftab_atxmega32c3 -extern const Register_file_t rgftab_atxmega32d3[567]; +extern const Register_file rgftab_atxmega32d3[567]; #define rgftab_atxmega64d3 rgftab_atxmega32d3 #define rgftab_atxmega128d3 rgftab_atxmega32d3 #define rgftab_atxmega192d3 rgftab_atxmega32d3 #define rgftab_atxmega256d3 rgftab_atxmega32d3 -extern const Register_file_t rgftab_atxmega64a1[814]; +extern const Register_file rgftab_atxmega64a1[814]; #define rgftab_atxmega128a1 rgftab_atxmega64a1 -extern const Register_file_t rgftab_atxmega64a1u[943]; +extern const Register_file rgftab_atxmega64a1u[943]; #define rgftab_atxmega128a1u rgftab_atxmega64a1u -extern const Register_file_t rgftab_atxmega64b1[574]; +extern const Register_file rgftab_atxmega64b1[574]; #define rgftab_atxmega128b1 rgftab_atxmega64b1 -extern const Register_file_t rgftab_atxmega64b3[458]; +extern const Register_file rgftab_atxmega64b3[458]; #define rgftab_atxmega128b3 rgftab_atxmega64b3 -extern const Register_file_t rgftab_atxmega64a4u[632]; +extern const Register_file rgftab_atxmega64a4u[632]; #define rgftab_atxmega128a4u rgftab_atxmega64a4u -extern const Register_file_t rgftab_atxmega64d4[460]; +extern const Register_file rgftab_atxmega64d4[460]; #define rgftab_atxmega128d4 rgftab_atxmega64d4 -extern const Register_file_t rgftab_atxmega256a3b[665]; +extern const Register_file rgftab_atxmega256a3b[665]; -extern const Register_file_t rgftab_atxmega256a3bu[780]; +extern const Register_file rgftab_atxmega256a3bu[780]; -extern const Register_file_t rgftab_atxmega384c3[603]; +extern const Register_file rgftab_atxmega384c3[603]; -extern const Register_file_t rgftab_atxmega384d3[560]; +extern const Register_file rgftab_atxmega384d3[560]; -extern const Register_file_t rgftab_attiny202[217]; +extern const Register_file rgftab_attiny202[217]; #define rgftab_attiny402 rgftab_attiny202 -extern const Register_file_t rgftab_attiny212[247]; +extern const Register_file rgftab_attiny212[247]; #define rgftab_attiny412 rgftab_attiny212 -extern const Register_file_t rgftab_attiny214[265]; +extern const Register_file rgftab_attiny214[265]; #define rgftab_attiny414 rgftab_attiny214 -extern const Register_file_t rgftab_attiny406[253]; +extern const Register_file rgftab_attiny406[253]; -extern const Register_file_t rgftab_attiny416[283]; +extern const Register_file rgftab_attiny416[283]; -extern const Register_file_t rgftab_attiny416auto[283]; +extern const Register_file rgftab_attiny416auto[283]; -extern const Register_file_t rgftab_attiny417[283]; +extern const Register_file rgftab_attiny417[283]; #define rgftab_attiny816 rgftab_attiny417 #define rgftab_attiny817 rgftab_attiny417 -extern const Register_file_t rgftab_attiny426[308]; +extern const Register_file rgftab_attiny426[308]; #define rgftab_attiny427 rgftab_attiny426 #define rgftab_attiny826 rgftab_attiny426 #define rgftab_attiny827 rgftab_attiny426 @@ -2665,41 +2665,41 @@ extern const Register_file_t rgftab_attiny426[308]; #define rgftab_attiny3226 rgftab_attiny426 #define rgftab_attiny3227 rgftab_attiny426 -extern const Register_file_t rgftab_attiny804[255]; +extern const Register_file rgftab_attiny804[255]; #define rgftab_attiny806 rgftab_attiny804 #define rgftab_attiny807 rgftab_attiny804 #define rgftab_attiny1604 rgftab_attiny804 #define rgftab_attiny1606 rgftab_attiny804 #define rgftab_attiny1607 rgftab_attiny804 -extern const Register_file_t rgftab_attiny814[265]; +extern const Register_file rgftab_attiny814[265]; -extern const Register_file_t rgftab_attiny1614[308]; +extern const Register_file rgftab_attiny1614[308]; -extern const Register_file_t rgftab_attiny1616[326]; +extern const Register_file rgftab_attiny1616[326]; #define rgftab_attiny1617 rgftab_attiny1616 -extern const Register_file_t rgftab_attiny3216[326]; +extern const Register_file rgftab_attiny3216[326]; #define rgftab_attiny3217 rgftab_attiny3216 -extern const Register_file_t rgftab_atmega808[406]; +extern const Register_file rgftab_atmega808[406]; #define rgftab_atmega1608 rgftab_atmega808 -extern const Register_file_t rgftab_atmega809[432]; +extern const Register_file rgftab_atmega809[432]; #define rgftab_atmega1609 rgftab_atmega809 -extern const Register_file_t rgftab_atmega3208[406]; +extern const Register_file rgftab_atmega3208[406]; #define rgftab_atmega4808 rgftab_atmega3208 -extern const Register_file_t rgftab_atmega3209[432]; +extern const Register_file rgftab_atmega3209[432]; #define rgftab_atmega4809 rgftab_atmega3209 -extern const Register_file_t rgftab_avr16du14[371]; +extern const Register_file rgftab_avr16du14[371]; #define rgftab_avr32du14 rgftab_avr16du14 -extern const Register_file_t rgftab_avr16eb14[391]; +extern const Register_file rgftab_avr16eb14[391]; -extern const Register_file_t rgftab_avr16du20[372]; +extern const Register_file rgftab_avr16du20[372]; #define rgftab_avr16du28 rgftab_avr16du20 #define rgftab_avr16du32 rgftab_avr16du20 #define rgftab_avr32du20 rgftab_avr16du20 @@ -2708,48 +2708,48 @@ extern const Register_file_t rgftab_avr16du20[372]; #define rgftab_avr64du28 rgftab_avr16du20 #define rgftab_avr64du32 rgftab_avr16du20 -extern const Register_file_t rgftab_avr16eb20[393]; +extern const Register_file rgftab_avr16eb20[393]; #define rgftab_avr16eb28 rgftab_avr16eb20 #define rgftab_avr16eb32 rgftab_avr16eb20 -extern const Register_file_t rgftab_avr16ea28[402]; +extern const Register_file rgftab_avr16ea28[402]; #define rgftab_avr16ea32 rgftab_avr16ea28 #define rgftab_avr32ea28 rgftab_avr16ea28 #define rgftab_avr32ea32 rgftab_avr16ea28 #define rgftab_avr64ea28 rgftab_avr16ea28 #define rgftab_avr64ea32 rgftab_avr16ea28 -extern const Register_file_t rgftab_avr32da28[432]; +extern const Register_file rgftab_avr32da28[432]; -extern const Register_file_t rgftab_avr32db28[462]; +extern const Register_file rgftab_avr32db28[462]; #define rgftab_avr64db28 rgftab_avr32db28 #define rgftab_avr128db28 rgftab_avr32db28 -extern const Register_file_t rgftab_avr32da32[447]; +extern const Register_file rgftab_avr32da32[447]; -extern const Register_file_t rgftab_avr32db32[477]; +extern const Register_file rgftab_avr32db32[477]; #define rgftab_avr64db32 rgftab_avr32db32 #define rgftab_avr128db32 rgftab_avr32db32 -extern const Register_file_t rgftab_avr32da48[600]; +extern const Register_file rgftab_avr32da48[600]; -extern const Register_file_t rgftab_avr32db48[643]; +extern const Register_file rgftab_avr32db48[643]; #define rgftab_avr64db48 rgftab_avr32db48 #define rgftab_avr128db48 rgftab_avr32db48 -extern const Register_file_t rgftab_avr64da28[433]; +extern const Register_file rgftab_avr64da28[433]; #define rgftab_avr128da28 rgftab_avr64da28 -extern const Register_file_t rgftab_avr64da32[448]; +extern const Register_file rgftab_avr64da32[448]; #define rgftab_avr128da32 rgftab_avr64da32 -extern const Register_file_t rgftab_avr64da48[601]; +extern const Register_file rgftab_avr64da48[601]; #define rgftab_avr128da48 rgftab_avr64da48 -extern const Register_file_t rgftab_avr64da64[659]; +extern const Register_file rgftab_avr64da64[659]; #define rgftab_avr128da64 rgftab_avr64da64 -extern const Register_file_t rgftab_avr64db64[698]; +extern const Register_file rgftab_avr64db64[698]; #define rgftab_avr128db64 rgftab_avr64db64 int upidxmcuid(int mcuid); @@ -2757,4 +2757,11 @@ int upidxsig(const uint8_t *sigs); int upidxname(const char *name); int upmatchingsig(uint8_t sigs[3], char *p, size_t n); +#ifndef TO_BE_DEPRECATED_IN_2026 +typedef Configvalue Valueitem_t; +typedef Configitem Configitem_t; +typedef Register_file Register_file_t; +typedef Avrintel uPcore_t; +#endif + #endif From 5b707be3dee5da537604ec32e0a81103822cff7b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 00:53:55 +0100 Subject: [PATCH 102/422] s/\bprogrammer_type_t\b/programmer_type/g --- src/config_gram.y | 2 +- src/libavrdude.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config_gram.y b/src/config_gram.y index 99732fa5..6cb3fd07 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -459,7 +459,7 @@ prog_parm_type: prog_parm_type_id: TKN_STRING { - const struct programmer_type_t * pgm_type = locate_programmer_type($1->value.string); + const PROGRAMMER_TYPE *pgm_type = locate_programmer_type($1->value.string); if (pgm_type == NULL) { yyerror("programmer type %s not found", $1->value.string); free_token($1); diff --git a/src/libavrdude.h b/src/libavrdude.h index 6556cac0..d28f1291 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1311,7 +1311,7 @@ int update_dryrun(const AVRPART *p, UPDATE *upd); /*LISTID programmer_types;*/ -typedef struct programmer_type_t { +typedef struct programmer_type { const char * const id; void (*initpgm)(PROGRAMMER *pgm); const char * const desc; From e926fc1a1c2f9df83faf917cc026df7f8a9bc5fa Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 00:55:16 +0100 Subject: [PATCH 103/422] s/\bctl_stack_t\b/ctl_stack/g --- src/libavrdude.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index d28f1291..e0fd05dd 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -189,7 +189,7 @@ enum { /* these are assigned to reset_disposition of AVRPART */ RESET_IO /* reset pin might be configured as an I/O pin */ }; -enum ctl_stack_t { +enum ctl_stack { CTL_STACK_NONE, /* no control stack defined */ CTL_STACK_PP, /* parallel programming control stack */ CTL_STACK_HVSP /* high voltage serial programming control stack */ @@ -300,7 +300,7 @@ typedef struct avrpart { int postdelay; int pollmethod; - enum ctl_stack_t ctl_stack_type; /* what to use the ctl stack for */ + enum ctl_stack ctl_stack_type; /* what to use the ctl stack for */ unsigned char controlstack[CTL_STACK_SIZE]; /* stk500v2 PP/HVSP ctl stack */ unsigned char flash_instr[FLASH_INSTR_SIZE]; /* flash instructions (debugWire, JTAG) */ unsigned char eeprom_instr[EEPROM_INSTR_SIZE]; /* EEPROM instructions (debugWire, JTAG) */ From 514803840196a799620d75000702f463093b0465 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 00:58:08 +0100 Subject: [PATCH 104/422] s/\bpindef_t\b/pindef/g --- src/avrftdi.c | 12 ++++++------ src/avrftdi_private.h | 6 +++--- src/ft245r.c | 2 +- src/libavrdude.h | 12 ++++++------ src/pindefs.c | 16 ++++++++-------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index e90f2879..9dde9733 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -90,7 +90,7 @@ static int write_flush(Avrftdi_data *); * returns a human-readable name for a pin number. The name should match with * the pin names used in FTDI datasheets. */ -static char *ftdi_pin_name(Avrftdi_data *pdata, struct pindef_t pin) { +static char *ftdi_pin_name(Avrftdi_data *pdata, struct pindef pin) { char *str = pdata->name_str; size_t strsiz = sizeof pdata->name_str; @@ -211,7 +211,7 @@ static int set_pin(const PROGRAMMER *pgm, int pinfunc, int value) { return -1; Avrftdi_data *pdata = to_pdata(pgm); - struct pindef_t pin = pgm->pin[pinfunc]; + struct pindef pin = pgm->pin[pinfunc]; if (pin.mask[0] == 0) { // ignore not defined pins (might be the led or vcc or buff if not needed) @@ -507,7 +507,7 @@ static int avrftdi_check_pins_bb(const PROGRAMMER *pgm, bool output) { int valid_mask = ((1 << pdata->pin_limit) - 1); pmsg_debug("using valid mask bitbanging: 0x%08x\n", valid_mask); - struct pindef_t *valid_pins_p = &pdata->valid_pins; + struct pindef *valid_pins_p = &pdata->valid_pins; valid_pins_p->mask[0] = valid_mask; valid_pins_p->inverse[0] = valid_mask ; @@ -530,7 +530,7 @@ static int avrftdi_check_pins_mpsse(const PROGRAMMER *pgm, bool output) { Avrftdi_data *pdata = to_pdata(pgm); - struct pindef_t *valid_pins = pdata->mpsse_pins; + struct pindef *valid_pins = pdata->mpsse_pins; /* value for 8/12/16 bit wide interface for other pins */ int valid_mask = ((1 << pdata->pin_limit) - 1); @@ -542,7 +542,7 @@ static int avrftdi_check_pins_mpsse(const PROGRAMMER *pgm, bool output) { } pmsg_debug("using valid mask mpsse: 0x%08x\n", valid_mask); - struct pindef_t *valid_pins_others_p = &pdata->other_pins; + struct pindef *valid_pins_others_p = &pdata->other_pins; valid_pins_others_p->mask[0] = valid_mask; valid_pins_others_p->inverse[0] = valid_mask ; @@ -1192,7 +1192,7 @@ static void avrftdi_setup(PROGRAMMER *pgm) { /* SCK/SDO/SDI are fixed and not invertible? */ /* TODO: inverted SCK/SDI/SDO */ - const struct pindef_t valid_mpsse_pins[4] = { + const struct pindef valid_mpsse_pins[4] = { {{0x01}, {0x00}}, {{0x02}, {0x00}}, {{0x04}, {0x00}}, diff --git a/src/avrftdi_private.h b/src/avrftdi_private.h index 72b9ce30..0a23908d 100644 --- a/src/avrftdi_private.h +++ b/src/avrftdi_private.h @@ -95,9 +95,9 @@ typedef struct avrftdi_s { uint8_t lext_byte; char name_str[128]; // Used in ftdi_pin_name() - struct pindef_t valid_pins; // Used in avrftdi_check_pins_bb() - struct pindef_t mpsse_pins[4]; // Used in avrftdi_check_pins_mpsse() - struct pindef_t other_pins; // Used in avrftdi_check_pins_mpsse() + struct pindef valid_pins; // Used in avrftdi_check_pins_bb() + struct pindef mpsse_pins[4]; // Used in avrftdi_check_pins_mpsse() + struct pindef other_pins; // Used in avrftdi_check_pins_mpsse() } Avrftdi_data; #endif /* DO_NOT_BUILD_AVRFDTI */ diff --git a/src/ft245r.c b/src/ft245r.c index 410ef594..baeb08a0 100644 --- a/src/ft245r.c +++ b/src/ft245r.c @@ -804,7 +804,7 @@ static int ft245r_cmd_tpi(const PROGRAMMER *pgm, const unsigned char *cmd, } /* lower 8 pins are accepted, they might be also inverted */ -static const struct pindef_t valid_pins = {{0xff}, {0xff}} ; +static const struct pindef valid_pins = {{0xff}, {0xff}}; static const struct pin_checklist_t pin_checklist[] = { { PIN_AVR_SCK, 1, &valid_pins}, diff --git a/src/libavrdude.h b/src/libavrdude.h index e0fd05dd..6cfb0eaf 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -672,7 +672,7 @@ enum { /** * Data structure to hold used pins by logical function (PIN_AVR_*, ...) */ -struct pindef_t { +struct pindef { pinmask_t mask[PIN_FIELD_SIZE]; ///< bitfield of used pins pinmask_t inverse[PIN_FIELD_SIZE]; ///< bitfield of inverse/normal usage of used pins }; @@ -683,7 +683,7 @@ struct pindef_t { struct pin_checklist_t { int pinname; ///< logical pinname eg. PIN_AVR_SCK int mandatory; ///< is this a mandatory pin - const struct pindef_t* valid_pins; ///< mask defines allowed pins, inverse define is they might be used inverted + const struct pindef *valid_pins; ///< mask defines allowed pins, inverse define is they might be used inverted }; /** @@ -693,14 +693,14 @@ struct pin_checklist_t { * @param[in] pin number of pin [0..PIN_MAX] * @param[in] inverse inverse (true) or normal (false) pin */ -void pin_set_value(struct pindef_t * const pindef, const int pin, const bool inverse); +void pin_set_value(struct pindef * const pindef, const int pin, const bool inverse); /** * Clear all defined pins in pindef. * * @param[out] pindef pin definition to clear */ -void pin_clear_all(struct pindef_t * const pindef); +void pin_clear_all(struct pindef * const pindef); typedef struct programmer PROGRAMMER; // Forward declaration @@ -753,7 +753,7 @@ const char * avr_pin_lcname(int pinname); * @param[in] pindef the pin definition for which we want the string representation * @returns a temporary string that lives in closed-circuit space */ -const char *pins_to_str(const struct pindef_t * const pindef); +const char *pins_to_str(const struct pindef * const pindef); /** * This function returns a string representation of pins in the mask, eg, 1, 3, 5-7, 9, 12 @@ -943,7 +943,7 @@ typedef struct programmer { int prog_modes; // Programming interfaces, see #define PM_... int is_serialadapter; // Programmer is also a serialadapter int extra_features; - struct pindef_t pin[N_PINS]; + struct pindef pin[N_PINS]; conntype_t conntype; int baudrate; int usbvid; diff --git a/src/pindefs.c b/src/pindefs.c index f0384749..cc10ebf3 100644 --- a/src/pindefs.c +++ b/src/pindefs.c @@ -34,7 +34,7 @@ * @param[in] pin number of pin [0..PIN_MAX] * @param[in] inverse inverse (true) or normal (false) pin */ -void pin_set_value(struct pindef_t * const pindef, const int pin, const bool inverse) { +void pin_set_value(struct pindef * const pindef, const int pin, const bool inverse) { pindef->mask[pin / PIN_FIELD_ELEMENT_SIZE] |= 1 << (pin % PIN_FIELD_ELEMENT_SIZE); if(inverse) { @@ -49,8 +49,8 @@ void pin_set_value(struct pindef_t * const pindef, const int pin, const bool inv * * @param[out] pindef pin definition to clear */ -void pin_clear_all(struct pindef_t * const pindef) { - memset(pindef, 0, sizeof(struct pindef_t)); +void pin_clear_all(struct pindef * const pindef) { + memset(pindef, 0, sizeof(struct pindef)); } /** @@ -59,7 +59,7 @@ void pin_clear_all(struct pindef_t * const pindef) { * @param[in] pindef new pin definition structure * @param[out] pinno old pin definition integer */ -static int pin_fill_old_pinno(const struct pindef_t * const pindef, unsigned int * const pinno) { +static int pin_fill_old_pinno(const struct pindef * const pindef, unsigned int * const pinno) { bool found = false; int i; for(i = 0; i <= PIN_MAX; i++) { @@ -84,7 +84,7 @@ static int pin_fill_old_pinno(const struct pindef_t * const pindef, unsigned int * @param[in] pindef new pin definition structure * @param[out] pinno old pin definition integer */ -static int pin_fill_old_pinlist(const struct pindef_t * const pindef, unsigned int * const pinno) { +static int pin_fill_old_pinlist(const struct pindef * const pindef, unsigned int * const pinno) { for(size_t i = 0; i < PIN_FIELD_SIZE; i++) { if(i == 0) { if((pindef->mask[i] & ~PIN_MASK) != 0) { @@ -218,7 +218,7 @@ const char *pinmask_to_str(const pinmask_t * const pinmask) { * @returns 0 if all pin definitions are valid, -1 otherwise */ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const checklist, const int size, const bool output) { - static const struct pindef_t no_valid_pins = {{0}, {0}}; // default value if check list does not contain anything else + static const struct pindef no_valid_pins = {{0}, {0}}; // default value if check list does not contain anything else int rv = 0; // return value int pinname; // loop counter through pinnames pinmask_t already_used_all[PIN_FIELD_SIZE] = {0}; // collect pin definitions of all pin names for check of double use @@ -232,7 +232,7 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const pinmask_t invalid_used[PIN_FIELD_SIZE] = {0}; pinmask_t inverse_used[PIN_FIELD_SIZE] = {0}; pinmask_t already_used[PIN_FIELD_SIZE] = {0}; - const struct pindef_t * valid_pins = &no_valid_pins; + const struct pindef * valid_pins = &no_valid_pins; bool is_mandatory = false; bool is_ok = true; //find corresponding check pattern @@ -314,7 +314,7 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const * @param[in] pindef the pin definition for which we want the string representation * @returns a temporary string that lives in closed-circuit space */ -const char *pins_to_str(const struct pindef_t * const pindef) { +const char *pins_to_str(const struct pindef * const pindef) { char buf[6*(PIN_MAX+1)], *p = buf; *buf = 0; From 8acd181f786432e7be765c1ad28ff717c01f080a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:02:11 +0100 Subject: [PATCH 105/422] s/\bpinmask_t\b/pinmask/g --- src/libavrdude.h | 10 +++++----- src/pindefs.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 6cfb0eaf..a9ccc6a4 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -51,7 +51,7 @@ * compiled from source together with the application. */ -typedef uint32_t pinmask_t; +typedef uint32_t Pinmask; /* * Values returned by library functions. * Some library functions also return a count, i.e. a positive @@ -627,7 +627,7 @@ enum { #endif /** Number of pins in each element of the bitfield */ -#define PIN_FIELD_ELEMENT_SIZE (sizeof(pinmask_t) * 8) +#define PIN_FIELD_ELEMENT_SIZE (sizeof(Pinmask) * 8) /** Numer of elements to store the complete bitfield of all pins */ #define PIN_FIELD_SIZE ((PIN_MAX+1 + PIN_FIELD_ELEMENT_SIZE-1)/PIN_FIELD_ELEMENT_SIZE) @@ -673,8 +673,8 @@ enum { * Data structure to hold used pins by logical function (PIN_AVR_*, ...) */ struct pindef { - pinmask_t mask[PIN_FIELD_SIZE]; ///< bitfield of used pins - pinmask_t inverse[PIN_FIELD_SIZE]; ///< bitfield of inverse/normal usage of used pins + Pinmask mask[PIN_FIELD_SIZE]; ///< bitfield of used pins + Pinmask inverse[PIN_FIELD_SIZE]; ///< bitfield of inverse/normal usage of used pins }; /** @@ -762,7 +762,7 @@ const char *pins_to_str(const struct pindef * const pindef); * @param[in] pinmask the pin mask for which we want the string representation * @returns a temporary string that lives in closed-circuit space */ -const char *pinmask_to_str(const pinmask_t * const pinmask); +const char *pinmask_to_str(const Pinmask * const pinmask); /* formerly serial.h */ diff --git a/src/pindefs.c b/src/pindefs.c index cc10ebf3..2e3c7b8b 100644 --- a/src/pindefs.c +++ b/src/pindefs.c @@ -158,7 +158,7 @@ int pgm_fill_old_pins(PROGRAMMER * const pgm) { * @param[in] pinmask the pin mask for which we want the string representation * @returns a temporary string that lives in closed-circuit space */ -const char *pinmask_to_str(const pinmask_t * const pinmask) { +const char *pinmask_to_str(const Pinmask * const pinmask) { char buf[6 * (PIN_MAX + 1)]; char *p = buf; int n; @@ -221,7 +221,7 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const static const struct pindef no_valid_pins = {{0}, {0}}; // default value if check list does not contain anything else int rv = 0; // return value int pinname; // loop counter through pinnames - pinmask_t already_used_all[PIN_FIELD_SIZE] = {0}; // collect pin definitions of all pin names for check of double use + Pinmask already_used_all[PIN_FIELD_SIZE] = {0}; // collect pin definitions of all pin names for check of double use // loop over all possible pinnames for(pinname = 0; pinname < N_PINS; pinname++) { bool used = false; @@ -229,9 +229,9 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const bool inverse = false; int index; bool mandatory_used = false; - pinmask_t invalid_used[PIN_FIELD_SIZE] = {0}; - pinmask_t inverse_used[PIN_FIELD_SIZE] = {0}; - pinmask_t already_used[PIN_FIELD_SIZE] = {0}; + Pinmask invalid_used[PIN_FIELD_SIZE] = {0}; + Pinmask inverse_used[PIN_FIELD_SIZE] = {0}; + Pinmask already_used[PIN_FIELD_SIZE] = {0}; const struct pindef * valid_pins = &no_valid_pins; bool is_mandatory = false; bool is_ok = true; From 8e0745594104ba15715358c7c49cb24f7d1a926a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:02:39 +0100 Subject: [PATCH 106/422] s/\bupdate_t\b/update/g --- src/libavrdude.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index a9ccc6a4..44685cce 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1261,7 +1261,7 @@ enum updateflags { }; -typedef struct update_t { +typedef struct update { const char *cmdline; // -T line is stored here and takes precedence if it exists char *memstr; // Memory name for -U int op; // Symbolic memory operation DEVICE_... for -U From 1ce7d82d34c84a14f6c0192936367e4fb01106fb Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:03:00 +0100 Subject: [PATCH 107/422] s/\buPcore_t\b/Avrintel/g --- src/libavrdude-avrintel.h | 2 +- src/urclock.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index 4eee1061..6a17efd8 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -2761,7 +2761,7 @@ int upmatchingsig(uint8_t sigs[3], char *p, size_t n); typedef Configvalue Valueitem_t; typedef Configitem Configitem_t; typedef Register_file Register_file_t; -typedef Avrintel uPcore_t; +typedef Avrintel Avrintel; #endif #endif diff --git a/src/urclock.c b/src/urclock.c index 12c34086..3c6bd7ea 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -251,7 +251,7 @@ typedef struct { unsigned char ext_addr_byte; // Ext-addr byte for STK500v1 protocol and MCUs with > 128k - uPcore_t uP; // Info about the connected processor (copied from uP_table) + Avrintel uP; // Info about the connected processor (copied from uP_table) bool initialised; // Is this structure initialised? bool bleepromrw; // Bootloader has EEPROM r/w support From cf9e2919952102fce7a62331d6f5e0532cde5f20 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:03:56 +0100 Subject: [PATCH 108/422] s/\bComponent_t\b/Component/g --- src/config.c | 14 +++++++------- src/config.h | 8 ++++---- src/lexer.l | 2 +- src/libavrdude.h | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/config.c b/src/config.c index d0e7779a..5adef5a7 100644 --- a/src/config.c +++ b/src/config.c @@ -66,7 +66,7 @@ extern char *yytext; #define mem_comp_desc(x, type) { #x, COMP_AVRMEM, offsetof(AVRMEM, x), sizeof(((AVRMEM *) NULL)->x), type } // Component description for config_gram.y, will be sorted appropriately on first use -Component_t avr_comp[] = { +Component avr_comp[] = { // PROGRAMMER pgm_comp_desc(desc, COMP_STRING), pgm_comp_desc(prog_modes, COMP_INT), @@ -822,22 +822,22 @@ char *cfg_escape(const char *s) { static int cmp_comp(const void *v1, const void *v2) { - const Component_t *c1 = v1, *c2 = v2; + const Component *c1 = v1, *c2 = v2; int ret = strcmp(c1->name, c2->name); return ret? ret: c1->strct - c2->strct; } -Component_t *cfg_comp_search(const char *name, int strct) { - Component_t key; +Component *cfg_comp_search(const char *name, int strct) { + Component key; if(!cx->cfg_init_search++) - qsort(avr_comp, sizeof avr_comp/sizeof*avr_comp, sizeof(Component_t), cmp_comp); + qsort(avr_comp, sizeof avr_comp/sizeof*avr_comp, sizeof(Component), cmp_comp); key.name = name; key.strct = strct; - return bsearch(&key, avr_comp, sizeof avr_comp/sizeof*avr_comp, sizeof(Component_t), cmp_comp); + return bsearch(&key, avr_comp, sizeof avr_comp/sizeof*avr_comp, sizeof(Component), cmp_comp); } @@ -881,7 +881,7 @@ const char *cfg_comp_type(int type) { // Used by config_gram.y to assign a component in one of the relevant structures with a value -void cfg_assign(char *sp, int strct, Component_t *cp, VALUE *v) { +void cfg_assign(char *sp, int strct, Component *cp, VALUE *v) { const char *str; int num; diff --git a/src/config.h b/src/config.h index b335cb6c..82583158 100644 --- a/src/config.h +++ b/src/config.h @@ -62,7 +62,7 @@ typedef struct { // Description of a component in a structure const char *name; // Component name int strct; // Structure, eg, COMP_AVRPART int offset, size, type; // Location, size and type within structure -} Component_t; +} Component; enum { // Value types for VALUE struct @@ -79,7 +79,7 @@ typedef struct { int number; double number_real; char *string; - Component_t *comp; + Component *comp; }; } VALUE; @@ -152,13 +152,13 @@ LISTID cfg_move_comments(void); void cfg_pop_comms(void); -Component_t *cfg_comp_search(const char *name, int strct); +Component *cfg_comp_search(const char *name, int strct); const char *cfg_v_type(int type); const char *cfg_strct_name(int strct); -void cfg_assign(char *sp, int strct, Component_t *cp, VALUE *v); +void cfg_assign(char *sp, int strct, Component *cp, VALUE *v); void cfg_update_mcuid(AVRPART *part); diff --git a/src/lexer.l b/src/lexer.l index b11928dd..32f57b3e 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -159,7 +159,7 @@ INF [Ii][Nn][Ff]([Ii][Nn][Ii][Tt][Yy])? paged | size | num_pages | initval | bitmask | n_word_writes | offset | min_write_delay | max_write_delay | pwroff_after_write | readback_p1 | readback_p2 | mode | delay | blocksize | readsize ) { /* struct components for PROGRAMMER, AVRPART and AVRMEM */ - Component_t *cp = cfg_comp_search(yytext, current_strct); + Component *cp = cfg_comp_search(yytext, current_strct); if(!cp) { yyerror("unknown component %s in %s", yytext, cfg_strct_name(current_strct)); return YYERRCODE; diff --git a/src/libavrdude.h b/src/libavrdude.h index 44685cce..51bf9f22 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -257,7 +257,7 @@ typedef struct opcode { /* * Any changes in AVRPART or AVRMEM, please also ensure changes are made in * - lexer.l - * - Either Component_t avr_comp[] of config.c or in config_gram.y + * - Either Component avr_comp[] of config.c or in config_gram.y * - dev_part_strct() in developer_opts.c * - avr_new_part() and/or avr_new_mem() in avrpart.c for * initialisation; note that all const char * must be initialised with "" @@ -929,7 +929,7 @@ typedef struct { /* * Any changes in PROGRAMMER, please also ensure changes are made in * - lexer.l - * - Either Component_t avr_comp[] of config.c or config_gram.y + * - Either Component avr_comp[] of config.c or config_gram.y * - dev_pgm_strct() in developer_opts.c * - pgm_new() in pgm.c for initialisation; note that all const char * must * be initialised with "" From d6a6cea233cbec0dda873541baee0f9960f8a8dc Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:04:14 +0100 Subject: [PATCH 109/422] s/\bValueitem_t\b/Configvalue/g --- src/libavrdude-avrintel.h | 2 +- src/term.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index 6a17efd8..03254f67 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -2758,7 +2758,7 @@ int upidxname(const char *name); int upmatchingsig(uint8_t sigs[3], char *p, size_t n); #ifndef TO_BE_DEPRECATED_IN_2026 -typedef Configvalue Valueitem_t; +typedef Configvalue Configvalue; typedef Configitem Configitem_t; typedef Register_file Register_file_t; typedef Avrintel Avrintel; diff --git a/src/term.c b/src/term.c index 93d8a5f3..f8d92e66 100644 --- a/src/term.c +++ b/src/term.c @@ -1047,7 +1047,7 @@ static int setmatches(const char *str, int n, Cnfg *cc) { return matches; } -static int getvalidx(const char *str, int n, const Valueitem_t *vt) { +static int getvalidx(const char *str, int n, const Configvalue *vt) { int hold, matches = 0; if(!*str) @@ -1098,7 +1098,7 @@ static int gatherval(const PROGRAMMER *pgm, const AVRPART *p, Cnfg *cc, int i, } // Comment printed next to symbolic value -static const char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, int value, Cfg_opts o) { +static const char *valuecomment(const Configitem_t *cti, const Configvalue *vp, int value, Cfg_opts o) { char buf[512], bin[129]; unsigned u = value, m = cti->mask >> cti->lsh; int lsh = cti->lsh; @@ -1137,7 +1137,7 @@ static const char *valuecomment(const Configitem_t *cti, const Valueitem_t *vp, } // How a single property is printed -static void printoneproperty(Cnfg *cc, int ii, const Valueitem_t *vp, int llen, const char *vstr, Cfg_opts o) { +static void printoneproperty(Cnfg *cc, int ii, const Configvalue *vp, int llen, const char *vstr, Cfg_opts o) { int value = vp? vp->value: cc[ii].val; term_out("%s %s=%-*s # %s\n", vp && cc[ii].val != vp->value? "# conf": "config", cc[ii].t->name, llen, vstr, valuecomment(cc[ii].t, vp, value, o)); @@ -1145,7 +1145,7 @@ static void printoneproperty(Cnfg *cc, int ii, const Valueitem_t *vp, int llen, // Prints a list of all possible values (o.allv) or just the one proporty cc[ii] static void printproperty(Cnfg *cc, int ii, Cfg_opts o) { - const Valueitem_t *vt = cc[ii].t->vlist, *vp; + const Configvalue *vt = cc[ii].t->vlist, *vp; int nv = cc[ii].t->nvalues; const char *ccom = cc->t[ii].ccomment, *col = strchr(ccom, ':'); char buf[32]; @@ -1315,7 +1315,7 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c const Configitem_t *ct; // Configuration bitfield table int nc; // Number of config properties, some may not be available Part_FL fusel; // Copy of fuses and lock bits - const Valueitem_t *vt; // Pointer to symbolic labels and associated values + const Configvalue *vt; // Pointer to symbolic labels and associated values int nv; // Number of symbolic labels Cnfg *cc; // Current configuration; cc[] and ct[] are parallel arrays FL_item *fc; // Current fuse and lock bits memories From 97c4f89851b0537d5fe589157f7e501b66dcdfa2 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:04:28 +0100 Subject: [PATCH 110/422] s/\bConfigitem_t\b/Configitem/g --- src/avrpart.c | 22 +++++++++++----------- src/libavrdude-avrintel.h | 2 +- src/libavrdude.h | 6 +++--- src/term.c | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index 3fa0b507..75be4491 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -511,7 +511,7 @@ int avr_locate_upidx(const AVRPART *p) { } // Return pointer to config table for the part and set number of config bitfields -const Configitem_t *avr_locate_configitems(const AVRPART *p, int *ncp) { +const Configitem *avr_locate_configitems(const AVRPART *p, int *ncp) { int idx = avr_locate_upidx(p); if(idx < 0) return NULL; @@ -635,13 +635,13 @@ const Register_file_t **avr_locate_registerlist(const Register_file_t *rgf, int * str_matched_by etc. If name is the full name of a configuration bitfield * then a pointer to that is returned irrespective of the matching function. */ -const Configitem_t *avr_locate_config(const Configitem_t *cfg, int nc, const char *name, +const Configitem *avr_locate_config(const Configitem *cfg, int nc, const char *name, int (*match)(const char *, const char*)) { if(!cfg || nc < 1 || !name || !match) return NULL; - const Configitem_t *ret = NULL; + const Configitem *ret = NULL; int nmatches = 0; for(int i = 0; i < nc; i++) { @@ -663,10 +663,10 @@ const Configitem_t *avr_locate_config(const Configitem_t *cfg, int nc, const cha * returned list is confined to this specific entry irrespective of the * matching function. */ -const Configitem_t **avr_locate_configlist(const Configitem_t *cfg, int nc, const char *name, +const Configitem **avr_locate_configlist(const Configitem *cfg, int nc, const char *name, int (*match)(const char *, const char*)) { - const Configitem_t **ret = mmt_malloc(sizeof cfg*(nc>0? nc+1: 1)), **r = ret; + const Configitem **ret = mmt_malloc(sizeof cfg*(nc>0? nc+1: 1)), **r = ret; if(cfg && name && match) { for(int i = 0; i < nc; i++) @@ -684,19 +684,19 @@ const Configitem_t **avr_locate_configlist(const Configitem_t *cfg, int nc, cons return ret; } -// Return memory associated with config item and fill in pointer to Configitem_t record +// Return memory associated with config item and fill in pointer to Configitem record static AVRMEM *avr_locate_config_mem_c_value(const PROGRAMMER *pgm, const AVRPART *p, - const char *cname, const Configitem_t **cp, int *valp) { + const char *cname, const Configitem **cp, int *valp) { int nc = 0; - const Configitem_t *cfg = avr_locate_configitems(p, &nc); + const Configitem *cfg = avr_locate_configitems(p, &nc); if(!cfg || nc < 1) { pmsg_error("avrintel.c does not hold configuration information for %s\n", p->desc); return NULL; } - const Configitem_t *c = avr_locate_config(cfg, nc, cname, str_contains); + const Configitem *c = avr_locate_config(cfg, nc, cname, str_contains); if(!c) { pmsg_error("%s does not have a unique config item matched by %s\n", p->desc, cname); return NULL; @@ -729,7 +729,7 @@ static AVRMEM *avr_locate_config_mem_c_value(const PROGRAMMER *pgm, const AVRPAR // Initialise *valuep with configuration value of named configuration bitfield int avr_get_config_value(const PROGRAMMER *pgm, const AVRPART *p, const char *cname, int *valuep) { - const Configitem_t *c; + const Configitem *c; int fusel; if(!avr_locate_config_mem_c_value(pgm, p, cname, &c, &fusel)) @@ -742,7 +742,7 @@ int avr_get_config_value(const PROGRAMMER *pgm, const AVRPART *p, const char *cn // Set configuration value of named configuration bitfield to value int avr_set_config_value(const PROGRAMMER *pgm, const AVRPART *p, const char *cname, int value) { AVRMEM *mem; - const Configitem_t *c; + const Configitem *c; int fusel; if(!(mem=avr_locate_config_mem_c_value(pgm, p, cname, &c, &fusel))) diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index 03254f67..b6899763 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -2759,7 +2759,7 @@ int upmatchingsig(uint8_t sigs[3], char *p, size_t n); #ifndef TO_BE_DEPRECATED_IN_2026 typedef Configvalue Configvalue; -typedef Configitem Configitem_t; +typedef Configitem Configitem; typedef Register_file Register_file_t; typedef Avrintel Avrintel; #endif diff --git a/src/libavrdude.h b/src/libavrdude.h index 51bf9f22..77d771a7 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1429,16 +1429,16 @@ extern "C" { #endif int avr_locate_upidx(const AVRPART *p); -const Configitem_t *avr_locate_configitems(const AVRPART *p, int *ncp); +const Configitem *avr_locate_configitems(const AVRPART *p, int *ncp); const char * const *avr_locate_isrtable(const AVRPART *p, int *nip); const Register_file_t *avr_locate_register_file(const AVRPART *p, int *nrp); const Register_file_t *avr_locate_register(const Register_file_t *rgf, int nr, const char *reg, int (*match)(const char *, const char*)); const Register_file_t **avr_locate_registerlist(const Register_file_t *rgf, int nr, const char *reg, int (*match)(const char *, const char*)); -const Configitem_t *avr_locate_config(const Configitem_t *cfg, int nc, const char *name, +const Configitem *avr_locate_config(const Configitem *cfg, int nc, const char *name, int (*match)(const char *, const char*)); -const Configitem_t **avr_locate_configlist(const Configitem_t *cfg, int nc, const char *name, +const Configitem **avr_locate_configlist(const Configitem *cfg, int nc, const char *name, int (*match)(const char *, const char*)); int avr_get_config_value(const PROGRAMMER *pgm, const AVRPART *p, const char *cname, int *valuep); int avr_set_config_value(const PROGRAMMER *pgm, const AVRPART *p, const char *cname, int value); diff --git a/src/term.c b/src/term.c index f8d92e66..17fc901b 100644 --- a/src/term.c +++ b/src/term.c @@ -949,7 +949,7 @@ typedef struct { // Fuses and lock bits } Part_FL; typedef struct { - const Configitem_t *t; // Configuration bitfield table + const Configitem *t; // Configuration bitfield table const char *memstr; // Memory name but could also be "lockbits" const char *alt; // Set when memstr is an alias int match; // Matched by user request @@ -1098,7 +1098,7 @@ static int gatherval(const PROGRAMMER *pgm, const AVRPART *p, Cnfg *cc, int i, } // Comment printed next to symbolic value -static const char *valuecomment(const Configitem_t *cti, const Configvalue *vp, int value, Cfg_opts o) { +static const char *valuecomment(const Configitem *cti, const Configvalue *vp, int value, Cfg_opts o) { char buf[512], bin[129]; unsigned u = value, m = cti->mask >> cti->lsh; int lsh = cti->lsh; @@ -1312,7 +1312,7 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c } int idx = -1; // Index in uP_table[] - const Configitem_t *ct; // Configuration bitfield table + const Configitem *ct; // Configuration bitfield table int nc; // Number of config properties, some may not be available Part_FL fusel; // Copy of fuses and lock bits const Configvalue *vt; // Pointer to symbolic labels and associated values From cd90f3c958b79b900fb5643e00d6118fd17d91e9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:04:43 +0100 Subject: [PATCH 111/422] s/\bRegister_file_t\b/Register_file/g --- src/avrpart.c | 10 +++++----- src/dryrun.c | 2 +- src/libavrdude-avrintel.h | 2 +- src/libavrdude.h | 6 +++--- src/term.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index 75be4491..b75878e8 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -531,7 +531,7 @@ const char * const *avr_locate_isrtable(const AVRPART *p, int *nip) { } // Return pointer to register file for the part and set number of registers -const Register_file_t *avr_locate_register_file(const AVRPART *p, int *nrp) { +const Register_file *avr_locate_register_file(const AVRPART *p, int *nrp) { int idx = avr_locate_upidx(p); if(idx < 0) return NULL; @@ -556,13 +556,13 @@ const Register_file_t *avr_locate_register_file(const AVRPART *p, int *nrp) { * though there are other registers that start with adc, eg, adc.adcsra. */ -const Register_file_t *avr_locate_register(const Register_file_t *rgf, int nr, const char *reg, +const Register_file *avr_locate_register(const Register_file *rgf, int nr, const char *reg, int (*match)(const char *, const char*)) { if(!rgf || nr < 1 || !reg || !match) return NULL; - const Register_file_t *ret = NULL; + const Register_file *ret = NULL; int nmatches = 0, eqmatch = match == str_eq; for(int i = 0; i < nr; i++) { @@ -597,10 +597,10 @@ const Register_file_t *avr_locate_register(const Register_file_t *rgf, int nr, c * behaviour can be suppressed by specifying a pattern for reg, eg, adc* * together with the matching function str_matched_by. */ -const Register_file_t **avr_locate_registerlist(const Register_file_t *rgf, int nr, const char *reg, +const Register_file **avr_locate_registerlist(const Register_file *rgf, int nr, const char *reg, int (*match)(const char *, const char*)) { - const Register_file_t **ret = mmt_malloc(sizeof rgf*(nr>0? nr+1: 1)), **r = ret; + const Register_file **ret = mmt_malloc(sizeof rgf*(nr>0? nr+1: 1)), **r = ret; int eqmatch = match == str_eq; if(rgf && reg && match) diff --git a/src/dryrun.c b/src/dryrun.c index c6714eb8..d24f4838 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -191,7 +191,7 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { } } else if(mem_is_io(m)) { // Initialise reset values (if known) int nr; - const Register_file_t *rf = avr_locate_register_file(p, &nr); + const Register_file *rf = avr_locate_register_file(p, &nr); if(rf) for(int i = 0; i < nr; i++) if(rf[i].initval != -1 && rf[i].size > 0 && rf[i].size < 5) diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index b6899763..cd62f6f1 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -2760,7 +2760,7 @@ int upmatchingsig(uint8_t sigs[3], char *p, size_t n); #ifndef TO_BE_DEPRECATED_IN_2026 typedef Configvalue Configvalue; typedef Configitem Configitem; -typedef Register_file Register_file_t; +typedef Register_file Register_file; typedef Avrintel Avrintel; #endif diff --git a/src/libavrdude.h b/src/libavrdude.h index 77d771a7..8e1fef9b 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1431,10 +1431,10 @@ extern "C" { int avr_locate_upidx(const AVRPART *p); const Configitem *avr_locate_configitems(const AVRPART *p, int *ncp); const char * const *avr_locate_isrtable(const AVRPART *p, int *nip); -const Register_file_t *avr_locate_register_file(const AVRPART *p, int *nrp); -const Register_file_t *avr_locate_register(const Register_file_t *rgf, int nr, const char *reg, +const Register_file *avr_locate_register_file(const AVRPART *p, int *nrp); +const Register_file *avr_locate_register(const Register_file *rgf, int nr, const char *reg, int (*match)(const char *, const char*)); -const Register_file_t **avr_locate_registerlist(const Register_file_t *rgf, int nr, const char *reg, +const Register_file **avr_locate_registerlist(const Register_file *rgf, int nr, const char *reg, int (*match)(const char *, const char*)); const Configitem *avr_locate_config(const Configitem *cfg, int nc, const char *name, int (*match)(const char *, const char*)); diff --git a/src/term.c b/src/term.c index 17fc901b..d11b7e81 100644 --- a/src/term.c +++ b/src/term.c @@ -1727,7 +1727,7 @@ static int cmd_regfile(const PROGRAMMER *pgm, const AVRPART *p, int argc, const int do_read = p->prog_modes & (PM_UPDI | PM_PDI); int nr; - const Register_file_t *rf = avr_locate_register_file(p, &nr); + const Register_file *rf = avr_locate_register_file(p, &nr); if(!rf || nr <= 0) { pmsg_error("(regfile) .atdf file not published for %s: unknown register file\n", p->desc); @@ -1739,7 +1739,7 @@ static int cmd_regfile(const PROGRAMMER *pgm, const AVRPART *p, int argc, const *rhs++ = 0; // Terminate lhs // Create mmt_malloc'd NULL-terminated list of register pointers - const Register_file_t *r, **rl, **rlist; + const Register_file *r, **rl, **rlist; rlist = avr_locate_registerlist(rf, nr, reg, str_is_pattern(reg)? str_matched_by: str_contains); if(rhs) { // Write to single register From 564b95e6f91fcb42fd5010c3f409fdf69ab237d1 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:05:57 +0100 Subject: [PATCH 112/422] s/\bconntype_t\b/Conntype/g --- src/developer_opts.c | 2 +- src/libavrdude.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index 6faf58e3..27fec4cf 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -1175,7 +1175,7 @@ static void dev_pgm_raw(const PROGRAMMER *pgm) { } -static const char *connstr(conntype_t conntype) { +static const char *connstr(Conntype conntype) { switch(conntype) { case CONNTYPE_LINUXGPIO: return "linuxgpio"; case CONNTYPE_PARALLEL: return "parallel"; diff --git a/src/libavrdude.h b/src/libavrdude.h index 8e1fef9b..0da08c39 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -905,7 +905,7 @@ typedef enum { CONNTYPE_USB, CONNTYPE_SPI, CONNTYPE_LINUXGPIO -} conntype_t; +} Conntype; #define LED_N 4 // Max number of LEDs driven by programmers @@ -944,7 +944,7 @@ typedef struct programmer { int is_serialadapter; // Programmer is also a serialadapter int extra_features; struct pindef pin[N_PINS]; - conntype_t conntype; + Conntype conntype; int baudrate; int usbvid; LISTID usbpid; From 9d75341ef87dbd24b1036b8ae03966e433b05ea3 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:06:25 +0100 Subject: [PATCH 113/422] s/\bexit_datahigh_t\b/Exit_datahigh/g --- src/libavrdude.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 0da08c39..d420d486 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -897,7 +897,7 @@ typedef enum { EXIT_DATAHIGH_UNSPEC, EXIT_DATAHIGH_ENABLED, EXIT_DATAHIGH_DISABLED -} exit_datahigh_t; +} Exit_datahigh; typedef enum { CONNTYPE_PARALLEL, @@ -961,7 +961,7 @@ typedef struct programmer { unsigned int pinno[N_PINS]; // TODO to be removed if old pin data no longer needed exit_vcc_t exit_vcc; // Should these be set in avrdude.conf? exit_reset_t exit_reset; - exit_datahigh_t exit_datahigh; + Exit_datahigh exit_datahigh; int ppidata; int ppictrl; int ispdelay; // ISP clock delay From f52bd57584533848fa59afb356f0bca9ecfb2028 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:06:40 +0100 Subject: [PATCH 114/422] s/\bexit_reset_t\b/Exit_reset/g --- src/libavrdude.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index d420d486..71503e13 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -891,7 +891,7 @@ typedef enum { EXIT_RESET_UNSPEC, EXIT_RESET_ENABLED, EXIT_RESET_DISABLED -} exit_reset_t; +} Exit_reset; typedef enum { EXIT_DATAHIGH_UNSPEC, @@ -960,7 +960,7 @@ typedef struct programmer { const char *port; unsigned int pinno[N_PINS]; // TODO to be removed if old pin data no longer needed exit_vcc_t exit_vcc; // Should these be set in avrdude.conf? - exit_reset_t exit_reset; + Exit_reset exit_reset; Exit_datahigh exit_datahigh; int ppidata; int ppictrl; From f4994dceae2c4606ee694df86a3d7d2626169a35 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:06:56 +0100 Subject: [PATCH 115/422] s/\bexit_vcc_t\b/Exit_vcc/g --- src/libavrdude.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 71503e13..e7cb1726 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -885,7 +885,7 @@ typedef enum { EXIT_VCC_UNSPEC, EXIT_VCC_ENABLED, EXIT_VCC_DISABLED -} exit_vcc_t; +} Exit_vcc; typedef enum { EXIT_RESET_UNSPEC, @@ -959,7 +959,7 @@ typedef struct programmer { char type[PGM_TYPELEN]; const char *port; unsigned int pinno[N_PINS]; // TODO to be removed if old pin data no longer needed - exit_vcc_t exit_vcc; // Should these be set in avrdude.conf? + Exit_vcc exit_vcc; // Should these be set in avrdude.conf? Exit_reset exit_reset; Exit_datahigh exit_datahigh; int ppidata; From fe1f0b7e730e823d99508c902da8a938683bb4f3 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:08:43 +0100 Subject: [PATCH 116/422] s/\bleds_t\b/Leds/g --- src/leds.c | 8 ++++---- src/libavrdude.h | 6 +++--- src/pgm.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/leds.c b/src/leds.c index b53e8de7..2f006c96 100644 --- a/src/leds.c +++ b/src/leds.c @@ -59,7 +59,7 @@ #define CHECK 15 // Check LED needs changing // Keep track of LED status and set LED 0 .. LED_N-1 physically on or off -static void led_direct(const PROGRAMMER *pgm, leds_t *ls, int led, int what) { +static void led_direct(const PROGRAMMER *pgm, Leds *ls, int led, int what) { if(what ^ !!(ls->phy & (1<= LED_N) // Sanity return; @@ -125,7 +125,7 @@ static void led_physical(const PROGRAMMER *pgm, leds_t *ls, int led, int what) { // Logical level of setting LEDs, passes on to physical level int led_set(const PROGRAMMER *pgm, int led) { // leds should always be allocated, but if not use dummy - leds_t sanity = { 0, 0, 0, 0, 0, {0, } }, *ls = pgm->leds? pgm->leds: &sanity; + Leds sanity = { 0, 0, 0, 0, 0, {0, } }, *ls = pgm->leds? pgm->leds: &sanity; int what = led >= 0 && led < LED_N && !(ls->now & (1<leds should always be allocated, but if not use dummy - leds_t sanity = { 0, 0, 0, 0, 0, {0, } }, *ls = pgm->leds? pgm->leds: &sanity; + Leds sanity = { 0, 0, 0, 0, 0, {0, } }, *ls = pgm->leds? pgm->leds: &sanity; int what = ls->now & (1<pin[i])); } - pgm->leds = mmt_malloc(sizeof(leds_t)); + pgm->leds = mmt_malloc(sizeof(Leds)); pgm_init_functions(pgm); @@ -218,7 +218,7 @@ PROGRAMMER *pgm_dup(const PROGRAMMER *src) { if(pgm->cp_usersig) mmt_free(pgm->cp_usersig); - leds_t *ls = pgm->leds; + Leds *ls = pgm->leds; memcpy(pgm, src, sizeof(*pgm)); if(ls && src->leds) memcpy(ls, src->leds, sizeof *ls); From 23f87637cb2dbf6cac45160be649524059782cdd Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:09:13 +0100 Subject: [PATCH 117/422] s/\bmemtable_t\b/Memtable/g --- src/avr.c | 2 +- src/libavrdude.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/avr.c b/src/avr.c index d45b70f6..4a3a9fef 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1528,7 +1528,7 @@ char *dev_prog_modes(int pm) { // Symbolic C code of prog_modes // Typical order in which memories show in avrdude.conf, runtime adds unknown ones (if any) -memtable_t avr_mem_order[100] = { +Memtable avr_mem_order[100] = { {"eeprom", MEM_EEPROM}, {"flash", MEM_FLASH | MEM_IN_FLASH}, {"application", MEM_APPLICATION | MEM_IN_FLASH}, diff --git a/src/libavrdude.h b/src/libavrdude.h index 781daf17..a64728bd 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -355,7 +355,7 @@ typedef unsigned int memtype_t; typedef struct { const char *str; memtype_t type; -} memtable_t; +} Memtable; // The least significant 4 bits of type are the offset of a fuse in fuses mem #define MEM_FUSEOFF_MASK 15 // Mask for offset @@ -1082,7 +1082,7 @@ void sort_programmers(LISTID programmers); typedef void (*FP_UpdateProgress)(int percent, double etime, const char *hdr, int finish); extern struct avrpart parts[]; -extern memtable_t avr_mem_order[100]; +extern Memtable avr_mem_order[100]; extern FP_UpdateProgress update_progress; From 10d58084e490f8dd34fec8abf6086cd0657b4342 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:10:47 +0100 Subject: [PATCH 118/422] s/\bmemtype_t\b/Memtype/g --- src/avrpart.c | 6 +++--- src/libavrdude.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index b75878e8..57099d07 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -462,10 +462,10 @@ AVRMEM *avr_locate_fuse_by_offset(const AVRPART *p, unsigned int off) { } // Return the first memory that shares the type incl any fuse identified by offset in fuses -AVRMEM *avr_locate_mem_by_type(const AVRPART *p, memtype_t type) { +AVRMEM *avr_locate_mem_by_type(const AVRPART *p, Memtype type) { AVRMEM *m; - memtype_t off = type & MEM_FUSEOFF_MASK; - type &= ~(memtype_t) MEM_FUSEOFF_MASK; + Memtype off = type & MEM_FUSEOFF_MASK; + type &= ~(Memtype) MEM_FUSEOFF_MASK; if(p && p->mem) for(LNODEID ln=lfirst(p->mem); ln; ln=lnext(ln)) diff --git a/src/libavrdude.h b/src/libavrdude.h index a64728bd..0fa554b5 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -351,10 +351,10 @@ typedef struct avrpart { } AVRPART; -typedef unsigned int memtype_t; +typedef unsigned int Memtype; typedef struct { const char *str; - memtype_t type; + Memtype type; } Memtable; // The least significant 4 bits of type are the offset of a fuse in fuses mem @@ -497,7 +497,7 @@ typedef struct { typedef struct avrmem { const char *desc; /* memory description ("flash", "eeprom", etc) */ - memtype_t type; /* internally used type, cannot be set in conf files */ + Memtype type; /* Internally used type, cannot be set in conf files */ LISTID comments; // Used by developer options -p*/[ASsr...] int paged; /* 16-bit page addressed, e.g., ATmega flash but not EEPROM */ int size; /* total memory size in bytes */ @@ -562,7 +562,7 @@ void avr_free_memalias(AVRMEM_ALIAS * m); AVRMEM * avr_locate_mem(const AVRPART *p, const char *desc); AVRMEM * avr_locate_mem_noalias(const AVRPART *p, const char *desc); AVRMEM * avr_locate_fuse_by_offset(const AVRPART *p, unsigned int off); -AVRMEM * avr_locate_mem_by_type(const AVRPART *p, memtype_t type); +AVRMEM * avr_locate_mem_by_type(const AVRPART *p, Memtype type); unsigned int avr_data_offset(const AVRPART *p); AVRMEM_ALIAS * avr_locate_memalias(const AVRPART *p, const char *desc); AVRMEM_ALIAS * avr_find_memalias(const AVRPART *p, const AVRMEM *m_orig); From 8b748b3c22691964b07882f05f62b3254aeccf48 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:15:25 +0100 Subject: [PATCH 119/422] s/\bpin_checklist_t\b/pin_checklist/g --- src/avrftdi.c | 4 ++-- src/ft245r.c | 2 +- src/libavrdude.h | 6 +++--- src/pindefs.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index 9dde9733..36408334 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -499,7 +499,7 @@ static int avrftdi_check_pins_bb(const PROGRAMMER *pgm, bool output) { int pin; /* pin checklist. */ - struct pin_checklist_t pin_checklist[N_PINS]; + Pin_checklist pin_checklist[N_PINS]; Avrftdi_data *pdata = to_pdata(pgm); @@ -526,7 +526,7 @@ static int avrftdi_check_pins_mpsse(const PROGRAMMER *pgm, bool output) { int pin; /* pin checklist. */ - struct pin_checklist_t pin_checklist[N_PINS]; + Pin_checklist pin_checklist[N_PINS]; Avrftdi_data *pdata = to_pdata(pgm); diff --git a/src/ft245r.c b/src/ft245r.c index baeb08a0..e52ec3d6 100644 --- a/src/ft245r.c +++ b/src/ft245r.c @@ -806,7 +806,7 @@ static int ft245r_cmd_tpi(const PROGRAMMER *pgm, const unsigned char *cmd, /* lower 8 pins are accepted, they might be also inverted */ static const struct pindef valid_pins = {{0xff}, {0xff}}; -static const struct pin_checklist_t pin_checklist[] = { +static const Pin_checklist pin_checklist[] = { { PIN_AVR_SCK, 1, &valid_pins}, { PIN_AVR_SDO, 1, &valid_pins}, { PIN_AVR_SDI, 1, &valid_pins}, diff --git a/src/libavrdude.h b/src/libavrdude.h index 0fa554b5..3b76a6c5 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -680,11 +680,11 @@ struct pindef { /** * Data structure to define a checklist of valid pins for each function. */ -struct pin_checklist_t { +typedef struct pin_checklist { int pinname; ///< logical pinname eg. PIN_AVR_SCK int mandatory; ///< is this a mandatory pin const struct pindef *valid_pins; ///< mask defines allowed pins, inverse define is they might be used inverted -}; +} Pin_checklist; /** * Adds a pin in the pin definition as normal or inverse pin. @@ -729,7 +729,7 @@ int pgm_fill_old_pins(PROGRAMMER * const pgm); * @param[in] output false suppresses error messages to the user * @returns 0 if all pin definitions are valid, -1 otherwise */ -int pins_check(const PROGRAMMER * const pgm, const struct pin_checklist_t * const checklist, const int size, const bool output); +int pins_check(const PROGRAMMER * const pgm, const Pin_checklist * const checklist, const int size, const bool output); /** * Returns the name of the pin as string. diff --git a/src/pindefs.c b/src/pindefs.c index 2e3c7b8b..6aec71ad 100644 --- a/src/pindefs.c +++ b/src/pindefs.c @@ -217,7 +217,7 @@ const char *pinmask_to_str(const Pinmask * const pinmask) { * @param[in] size the number of entries in checklist * @returns 0 if all pin definitions are valid, -1 otherwise */ -int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const checklist, const int size, const bool output) { +int pins_check(const PROGRAMMER *const pgm, const Pin_checklist *const checklist, const int size, const bool output) { static const struct pindef no_valid_pins = {{0}, {0}}; // default value if check list does not contain anything else int rv = 0; // return value int pinname; // loop counter through pinnames From f86ef2e89d96d809121ac1ed3fac2a8db2c5909e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:16:09 +0100 Subject: [PATCH 120/422] s/\bSegment_t\b/Segment/g --- src/fileio.c | 36 ++++++++++++++++++------------------ src/libavrdude.h | 6 +++--- src/term.c | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index f7fb5d45..b0aeb586 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -176,7 +176,7 @@ static void print_ihex_extended_addr(int n_64k, FILE *outf) { * Return the maximum memory address within mem->buf that was read from * plus one. If an error occurs, return -1. */ -static int b2ihex(const unsigned char *buf, const Segment_t *segp, Segorder where, +static int b2ihex(const unsigned char *buf, const Segment *segp, Segorder where, int recsize, int startaddr, const char *outfile_unused, FILE *outf, FILEFMT ffmt) { @@ -339,7 +339,7 @@ static int ihex_readrec(struct ihexsrec *ihex, char * rec) { * plus one. If an error occurs, return -1. */ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, - const Segment_t *segp, unsigned int fileoffset, FILEFMT ffmt) { + const Segment *segp, unsigned int fileoffset, FILEFMT ffmt) { const char *errstr; unsigned int nextaddr, baseaddr, maxaddr; @@ -458,7 +458,7 @@ static unsigned int cksum_srec(const unsigned char *buf, int n, unsigned addr, i // Binary to Motorola S-Record, see https://en.wikipedia.org/wiki/SREC_(file_format) -static int b2srec(const AVRMEM *mem, const Segment_t *segp, Segorder where, +static int b2srec(const AVRMEM *mem, const Segment *segp, Segorder where, int recsize, int startaddr, const char *outfile_unused, FILE *outf) { const unsigned char *buf; @@ -609,7 +609,7 @@ static int srec_readrec(struct ihexsrec *srec, char *rec) { // Motorola S-Record to binary static int srec2b(const char *infile, FILE * inf, - const AVRMEM *mem, const Segment_t *segp, unsigned int fileoffset) { + const AVRMEM *mem, const Segment *segp, unsigned int fileoffset) { const char *errstr; unsigned int nextaddr, maxaddr; @@ -805,7 +805,7 @@ static int elf_mem_limits(const AVRMEM *mem, const AVRPART *p, // ELF format to binary (the memory segment to read into is ignored) static int elf2b(const char *infile, FILE *inf, const AVRMEM *mem, - const AVRPART *p, const Segment_t *segp_unused, unsigned int fileoffset_unused) { + const AVRPART *p, const Segment *segp_unused, unsigned int fileoffset_unused) { Elf *e; int rv = 0, size = 0; @@ -1012,7 +1012,7 @@ done: // Read/write binary files and return highest memory addr set + 1 static int fileio_rbin(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const Segment_t *segp) { + const AVRMEM *mem, const Segment *segp) { int rc; switch (fio->op) { @@ -1040,7 +1040,7 @@ static int fileio_rbin(struct fioparms *fio, const char *filename, FILE *f, static int fileio_imm(struct fioparms *fio, const char *fname, FILE *f_unused, - const AVRMEM *mem, const Segment_t *segp) { + const AVRMEM *mem, const Segment *segp) { char *tok, *p, *line; const char *errstr; @@ -1079,7 +1079,7 @@ static int fileio_imm(struct fioparms *fio, const char *fname, FILE *f_unused, static int fileio_ihex(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const Segment_t *segp, FILEFMT ffmt, Segorder where) { + const AVRMEM *mem, const Segment *segp, FILEFMT ffmt, Segorder where) { int rc; @@ -1102,7 +1102,7 @@ static int fileio_ihex(struct fioparms *fio, const char *filename, FILE *f, static int fileio_srec(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const Segment_t *segp, Segorder where) { + const AVRMEM *mem, const Segment *segp, Segorder where) { int rc; @@ -1126,7 +1126,7 @@ static int fileio_srec(struct fioparms *fio, const char *filename, FILE *f, #ifdef HAVE_LIBELF static int fileio_elf(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const AVRPART *p, const Segment_t *segp) { + const AVRMEM *mem, const AVRPART *p, const Segment *segp) { int rc; @@ -1150,7 +1150,7 @@ static int fileio_elf(struct fioparms *fio, const char *filename, FILE *f, #endif -static int b2num(const char *filename, FILE *f, const AVRMEM *mem, const Segment_t *segp, FILEFMT fmt) { +static int b2num(const char *filename, FILE *f, const AVRMEM *mem, const Segment *segp, FILEFMT fmt) { const char *prefix; int base; @@ -1214,7 +1214,7 @@ static int b2num(const char *filename, FILE *f, const AVRMEM *mem, const Segment } -static int num2b(const char *filename, FILE *f, const AVRMEM *mem, const Segment_t *segp) { +static int num2b(const char *filename, FILE *f, const AVRMEM *mem, const Segment *segp) { const char *geterr = NULL; char *line; int n = segp->addr, end = segp->addr + segp->len; @@ -1250,7 +1250,7 @@ static int num2b(const char *filename, FILE *f, const AVRMEM *mem, const Segment static int fileio_num(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const Segment_t *segp, FILEFMT fmt) { + const AVRMEM *mem, const Segment *segp, FILEFMT fmt) { switch (fio->op) { case FIO_WRITE: @@ -1422,13 +1422,13 @@ int fileio(int op, const char *filename, FILEFMT format, if(size < 0 || op == FIO_READ || op == FIO_READ_FOR_VERIFY) size = mem->size; - const Segment_t seg = {0, size}; + const Segment seg = {0, size}; return fileio_segments(op, filename, format, p, mem, 1, &seg); } // Normalise segment address and length to be non-negative -int segment_normalise(const AVRMEM *mem, Segment_t *segp) { +int segment_normalise(const AVRMEM *mem, Segment *segp) { int addr = segp->addr, len = segp->len, maxsize = mem->size; int digits = maxsize > 0x10000? 5: 4; @@ -1458,7 +1458,7 @@ int segment_normalise(const AVRMEM *mem, Segment_t *segp) { static int fileio_segments_normalise(int oprwv, const char *filename, FILEFMT format, - const AVRPART *p, const AVRMEM *mem, int n, Segment_t *seglist) { + const AVRPART *p, const AVRMEM *mem, int n, Segment *seglist) { int op, rc; FILE * f; @@ -1609,9 +1609,9 @@ static int fileio_segments_normalise(int oprwv, const char *filename, FILEFMT fo } int fileio_segments(int oprwv, const char *filename, FILEFMT format, - const AVRPART *p, const AVRMEM *mem, int n, const Segment_t *list) { + const AVRPART *p, const AVRMEM *mem, int n, const Segment *list) { - Segment_t *seglist = mmt_malloc(n*sizeof*seglist); + Segment *seglist = mmt_malloc(n*sizeof*seglist); memcpy(seglist, list, n*sizeof*seglist); int ret = fileio_segments_normalise(oprwv, filename, format, p, mem, n, seglist); mmt_free(seglist); diff --git a/src/libavrdude.h b/src/libavrdude.h index 3b76a6c5..bde0147b 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1208,7 +1208,7 @@ struct fioparms { typedef struct { int addr, len; -} Segment_t; +} Segment; enum { FIO_READ, @@ -1235,10 +1235,10 @@ int fileio_fmt_autodetect(const char *fname); int fileio(int oprwv, const char *filename, FILEFMT format, const AVRPART *p, const char *memstr, int size); -int segment_normalise(const AVRMEM *mem, Segment_t *segp); +int segment_normalise(const AVRMEM *mem, Segment *segp); int fileio_segments(int oprwv, const char *filename, FILEFMT format, - const AVRPART *p, const AVRMEM *mem, int n, const Segment_t *seglist); + const AVRPART *p, const AVRMEM *mem, int n, const Segment *seglist); #ifdef __cplusplus } diff --git a/src/term.c b/src/term.c index d11b7e81..e02bc094 100644 --- a/src/term.c +++ b/src/term.c @@ -663,7 +663,7 @@ static int cmd_save(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha mem = avr_dup_mem(omem); int n = argc > 3? (argc-3)/2: 1; - Segment_t *seglist = mmt_malloc(n*sizeof*seglist); + Segment *seglist = mmt_malloc(n*sizeof*seglist); int ret = -1; From 184e0c92fec6420860ae18c4217589e670932330 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:23:17 +0100 Subject: [PATCH 121/422] Give notice that some _t types are going to be deprecated --- src/libavrdude.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index bde0147b..162c7ad3 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1624,5 +1624,16 @@ int win_set_path(char *path, int n, const char *file); #endif /* WIN32 */ +#ifndef TO_BE_DEPRECATED_IN_2026 +typedef Pinmask pinmask_t; +typedef Conntype conntype_t; +typedef Exit_datahigh exit_datahigh_t; +typedef Exit_reset exit_reset_t; +typedef Exit_vcc exit_vcc_t; +typedef Leds leds_t; +typedef Memtable memtable_t; +typedef Memtype memtype_t; +typedef Segment Segment_t; +#endif #endif /* libavrdude_h */ From 32fc19bbb44ff43313898bf52666eb4d8762709a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 01:33:03 +0100 Subject: [PATCH 122/422] Give notice to deprecate libavrdude-avrintel.h _t types --- src/libavrdude-avrintel.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index cd62f6f1..4eee1061 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -2758,10 +2758,10 @@ int upidxname(const char *name); int upmatchingsig(uint8_t sigs[3], char *p, size_t n); #ifndef TO_BE_DEPRECATED_IN_2026 -typedef Configvalue Configvalue; -typedef Configitem Configitem; -typedef Register_file Register_file; -typedef Avrintel Avrintel; +typedef Configvalue Valueitem_t; +typedef Configitem Configitem_t; +typedef Register_file Register_file_t; +typedef Avrintel uPcore_t; #endif #endif From 0f3702fc0e729e3faa1c2b837db0e9dd72a43d1b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 12:15:34 +0100 Subject: [PATCH 123/422] Add sed script to comment about deprecated _t names --- src/libavrdude-avrintel.h | 7 ------- src/libavrdude.h | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index 4eee1061..a7732ef1 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -2757,11 +2757,4 @@ int upidxsig(const uint8_t *sigs); int upidxname(const char *name); int upmatchingsig(uint8_t sigs[3], char *p, size_t n); -#ifndef TO_BE_DEPRECATED_IN_2026 -typedef Configvalue Valueitem_t; -typedef Configitem Configitem_t; -typedef Register_file Register_file_t; -typedef Avrintel uPcore_t; -#endif - #endif diff --git a/src/libavrdude.h b/src/libavrdude.h index 162c7ad3..a4eb685e 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1625,6 +1625,49 @@ int win_set_path(char *path, int n, const char *file); #endif /* WIN32 */ #ifndef TO_BE_DEPRECATED_IN_2026 + +/* + * AVRDUDE type names ending in _t have been renamed, as POSIX reserves + * all of these. Below typedefs that give access to some of these _t names + * but will be withdrawn in future. If you want to update your project + * code that uses libavrdude feel free to copy and paste the lines below + * into a file avrdude_t.sed and execute in your code directory + * + * $ sed -i -f avrdude_t.sed *.{c,h,cpp,hpp,l,y} + * + +s/\btypedef struct programmer_t\b/typedef struct programmer/g +s/\bstruct programmer_t\b/PROGRAMMER/g +s/\bprogrammer_t\b/programmer/g +s/\bprogrammer_type_t\b/programmer_type/g +s/\bctl_stack_t\b/ctl_stack/g +s/\bpindef_t\b/pindef/g +s/\bpin_checklist_t\b/Pin_checklist/g +s/\bpinmask_t\b/Pinmask/g +s/\bupdate_t\b/update/g +s/\buPcore_t\b/Avrintel/g +s/\bComponent_t\b/Component/g +s/\bValueitem_t\b/Configvalue/g +s/\bConfigitem_t\b/Configitem/g +s/\bRegister_file_t\b/Register_file/g +s/\bconntype_t\b/Conntype/g +s/\bexit_datahigh_t\b/Exit_datahigh/g +s/\bexit_reset_t\b/Exit_reset/g +s/\bexit_vcc_t\b/Exit_vcc/g +s/\bleds_t\b/Leds/g +s/\bmemtable_t\b/Memtable/g +s/\bmemtype_t\b/Memtype/g +s/\bSegment_t\b/Segment/g + + * + */ + +typedef Configvalue Valueitem_t; +typedef Configitem Configitem_t; +typedef Register_file Register_file_t; +typedef Avrintel uPcore_t; + +typedef Pin_checklist pin_checklist_t; typedef Pinmask pinmask_t; typedef Conntype conntype_t; typedef Exit_datahigh exit_datahigh_t; @@ -1634,6 +1677,7 @@ typedef Leds leds_t; typedef Memtable memtable_t; typedef Memtype memtype_t; typedef Segment Segment_t; + #endif #endif /* libavrdude_h */ From a3e4c8083e38b257915881999c16e2e4438ec6d1 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 20 May 2024 12:28:53 +0100 Subject: [PATCH 124/422] Update NEWS --- NEWS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 69c394c8..c9a3f82a 100644 --- a/NEWS +++ b/NEWS @@ -24,7 +24,7 @@ Changes since version 7.3: - Old avrdude_message() can go away #1719 - avr_{read,write}_mem fail to initialize progress reporting #1718 - avr*timestamp() oddities #1722 - - -F option not honored bug #1740 + - -F option not honoured #1740 - "jtag2 is not a unique start of a programmer name" #1739 - Regression: EEPROM issue with official STK500 V1 FW #1713 - usbasp_write_byte in TPI mode not implemented #1755 @@ -35,6 +35,7 @@ Changes since version 7.3: - 0xff optimization when reading #1732 - Add support for more AVR-DU parts #1742 - Misleading error message: cannot find programmer id #1805 + - Custom programmer broken in v7.3 #1807 * Pull requests: @@ -80,6 +81,8 @@ Changes since version 7.3: - Add new AVRnnDUnn parts #1804 - Differentiate cause when programmer isn't found #1806 - Prepare for next urboot version #1808 + - Rename AVRDUDE symbol names ending in _t #1809 + - Warn when programmer failes to define prog_modes #1810 * Internals: From a98630522914a4eaa109c69c9d6ccdc2570a17fd Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 21 May 2024 23:18:41 +0100 Subject: [PATCH 125/422] Format source code in new AVRDUDE style (and minor changes) --- src/serprog.c | 686 +++++++++++++++++++++++++------------------------- src/serprog.h | 5 +- 2 files changed, 344 insertions(+), 347 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index 90fec7df..240eac90 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -42,111 +42,108 @@ const char serprog_desc[] = "Program via the Serprog protocol from Flashrom"; -/* - * Private data for this programmer. - */ +// Private data for this programmer struct pdata { - unsigned char cmd_bitmap[32]; - unsigned int cs; - uint32_t actual_frequency; + unsigned char cmd_bitmap[32]; + unsigned int cs; + uint32_t actual_frequency; }; #define my (*(struct pdata *)(pgm->cookie)) -// serprog protocol specification +// Serprog protocol specification // According to Serial Flasher Protocol Specification - version 1 #define S_ACK 0x06 #define S_NAK 0x15 -#define S_CMD_NOP 0x00 // No operation -#define S_CMD_Q_IFACE 0x01 // Query interface version -#define S_CMD_Q_CMDMAP 0x02 // Query supported commands bitmap -#define S_CMD_Q_PGMNAME 0x03 // Query programmer name -#define S_CMD_Q_SERBUF 0x04 // Query Serial Buffer Size -#define S_CMD_Q_BUSTYPE 0x05 // Query supported bustypes -#define S_CMD_Q_CHIPSIZE 0x06 // Query supported chipsize (2^n format) -#define S_CMD_Q_OPBUF 0x07 // Query operation buffer size -#define S_CMD_Q_WRNMAXLEN 0x08 // Query Write to opbuf: Write-N maximum length -#define S_CMD_R_BYTE 0x09 // Read a single byte -#define S_CMD_R_NBYTES 0x0A // Read n bytes -#define S_CMD_O_INIT 0x0B // Initialize operation buffer -#define S_CMD_O_WRITEB 0x0C // Write opbuf: Write byte with address -#define S_CMD_O_WRITEN 0x0D // Write to opbuf: Write-N -#define S_CMD_O_DELAY 0x0E // Write opbuf: udelay -#define S_CMD_O_EXEC 0x0F // Execute operation buffer -#define S_CMD_SYNCNOP 0x10 // Special no-operation that returns NAK+ACK -#define S_CMD_Q_RDNMAXLEN 0x11 // Query read-n maximum length -#define S_CMD_S_BUSTYPE 0x12 // Set used bustype(s). -#define S_CMD_O_SPIOP 0x13 // Perform SPI operation. -#define S_CMD_S_SPI_FREQ 0x14 // Set SPI clock frequency -#define S_CMD_S_PIN_STATE 0x15 // Enable/disable output drivers -#define S_CMD_S_SPI_CS 0x16 // Set SPI chip select to use -#define S_CMD_S_SPI_MODE 0x17 // Sets the spi mode used by S_CMD_O_SPIOP -#define S_CMD_S_CS_MODE 0x18 // Sets the way the CS is controlled +#define S_CMD_NOP 0x00 // No operation +#define S_CMD_Q_IFACE 0x01 // Query interface version +#define S_CMD_Q_CMDMAP 0x02 // Query supported commands bitmap +#define S_CMD_Q_PGMNAME 0x03 // Query programmer name +#define S_CMD_Q_SERBUF 0x04 // Query Serial Buffer Size +#define S_CMD_Q_BUSTYPE 0x05 // Query supported bustypes +#define S_CMD_Q_CHIPSIZE 0x06 // Query supported chipsize (2^n format) +#define S_CMD_Q_OPBUF 0x07 // Query operation buffer size +#define S_CMD_Q_WRNMAXLEN 0x08 // Query Write to opbuf: Write-N maximum length +#define S_CMD_R_BYTE 0x09 // Read a single byte +#define S_CMD_R_NBYTES 0x0A // Read n bytes +#define S_CMD_O_INIT 0x0B // Initialize operation buffer +#define S_CMD_O_WRITEB 0x0C // Write opbuf: Write byte with address +#define S_CMD_O_WRITEN 0x0D // Write to opbuf: Write-N +#define S_CMD_O_DELAY 0x0E // Write opbuf: udelay +#define S_CMD_O_EXEC 0x0F // Execute operation buffer +#define S_CMD_SYNCNOP 0x10 // Special no-operation that returns NAK+ACK +#define S_CMD_Q_RDNMAXLEN 0x11 // Query read-n maximum length +#define S_CMD_S_BUSTYPE 0x12 // Set used bustype(s). +#define S_CMD_O_SPIOP 0x13 // Perform SPI operation. +#define S_CMD_S_SPI_FREQ 0x14 // Set SPI clock frequency +#define S_CMD_S_PIN_STATE 0x15 // Enable/disable output drivers +#define S_CMD_S_SPI_CS 0x16 // Set SPI chip select to use +#define S_CMD_S_SPI_MODE 0x17 // Sets the SPI mode used by S_CMD_O_SPIOP +#define S_CMD_S_CS_MODE 0x18 // Sets the way the CS is controlled enum spi_mode { - SPI_MODE_HALF_DUPLEX = 0, - SPI_MODE_FULL_DUPLEX = 1, - SPI_MODE_MAX = SPI_MODE_FULL_DUPLEX, + SPI_MODE_HALF_DUPLEX = 0, + SPI_MODE_FULL_DUPLEX = 1, + SPI_MODE_MAX = SPI_MODE_FULL_DUPLEX, }; enum cs_mode { - CS_MODE_AUTO = 0, - CS_MODE_SELECTED = 1, - CS_MODE_DESELECTED = 2, - CS_MODE_MAX = CS_MODE_DESELECTED, + CS_MODE_AUTO = 0, + CS_MODE_SELECTED = 1, + CS_MODE_DESELECTED = 2, + CS_MODE_MAX = CS_MODE_DESELECTED, }; -// little endian helper functions +// Little endian helper functions static uint16_t read_le16(const unsigned char *buf) { - return buf[0] | (buf[1] << 8); + return buf[0] | (buf[1] << 8); } static uint32_t read_le32(const unsigned char *buf) { - return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); + return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); } static void write_le24(unsigned char *buf, uint32_t val) { - buf[0] = val; - buf[1] = val >> 8; - buf[2] = val >> 16; + buf[0] = val; + buf[1] = val >> 8; + buf[2] = val >> 16; } static void write_le32(unsigned char *buf, uint32_t val) { - buf[0] = val; - buf[1] = val >> 8; - buf[2] = val >> 16; - buf[3] = val >> 24; + buf[0] = val; + buf[1] = val >> 8; + buf[2] = val >> 16; + buf[3] = val >> 24; } -// serprog communication functions +// Serprog communication functions static int perform_serprog_cmd_full(const PROGRAMMER *pgm, uint8_t cmd, - const unsigned char *params, int params_len, - const unsigned char *send_buf, int send_len, - unsigned char *recv_buf, int recv_len) { - unsigned char resp_status_code = 0; + const unsigned char *params, int params_len, + const unsigned char *send_buf, int send_len, unsigned char *recv_buf, int recv_len) { - if(serial_send(&pgm->fd, &cmd, 1) < 0) - return -1; - if (params_len > 0) - if(serial_send(&pgm->fd, params, params_len) < 0) - return -1; - if (send_len > 0) - if(serial_send(&pgm->fd, send_buf, send_len) < 0) - return -1; + unsigned char resp_status_code = 0; - if (serial_recv(&pgm->fd, &resp_status_code, 1) < 0 || serial_recv(&pgm->fd, recv_buf, recv_len) < 0) - return -1; + if(serial_send(&pgm->fd, &cmd, 1) < 0) + return -1; + if(params_len > 0) + if(serial_send(&pgm->fd, params, params_len) < 0) + return -1; + if(send_len > 0) + if(serial_send(&pgm->fd, send_buf, send_len) < 0) + return -1; - return resp_status_code == S_ACK? 0: resp_status_code == S_NAK? 1: -1; + if(serial_recv(&pgm->fd, &resp_status_code, 1) < 0 || serial_recv(&pgm->fd, recv_buf, recv_len) < 0) + return -1; + + return resp_status_code == S_ACK? 0: resp_status_code == S_NAK? 1: -1; } static int perform_serprog_cmd(const PROGRAMMER *pgm, uint8_t cmd, - const unsigned char *params, int params_len, - unsigned char *recv_buf, int recv_len) { - return perform_serprog_cmd_full(pgm, cmd, params, params_len, NULL, 0, recv_buf, recv_len); + const unsigned char *params, int params_len, unsigned char *recv_buf, int recv_len) { + return perform_serprog_cmd_full(pgm, cmd, params, params_len, NULL, 0, recv_buf, recv_len); } /** @@ -154,211 +151,209 @@ static int perform_serprog_cmd(const PROGRAMMER *pgm, uint8_t cmd, * @return -1 on failure, otherwise number of bytes sent/received */ static int serprog_spi_duplex(const PROGRAMMER *pgm, const unsigned char *tx, unsigned char *rx, int len) { - unsigned char params[6]; - write_le24(params, len); - write_le24(params + 3, len); - if (perform_serprog_cmd_full(pgm, S_CMD_O_SPIOP, params, sizeof(params), tx, len, rx, len) != 0) { - return -1; - } + unsigned char params[6]; - return len; + write_le24(params, len); + write_le24(params + 3, len); + if(perform_serprog_cmd_full(pgm, S_CMD_O_SPIOP, params, sizeof params, tx, len, rx, len) != 0) + return -1; + + return len; } static bool is_serprog_cmd_supported(const unsigned char *cmd_bitmap, unsigned char cmd) { - return (cmd_bitmap[cmd / 8] >> (cmd % 8)) & 1; + return (cmd_bitmap[cmd / 8] >> (cmd % 8)) & 1; } -// programmer lifecycle handlers +// Programmer lifecycle handlers static int serprog_open(PROGRAMMER *pgm, const char *port) { - union pinfo pinfo; - pgm->port = port; - pinfo.serialinfo.baud = pgm->baudrate? pgm->baudrate: 115200; - pinfo.serialinfo.cflags = SERIAL_8N1; - if (serial_open(port, pinfo, &pgm->fd)==-1) { - return -1; + union pinfo pinfo; + + pgm->port = port; + pinfo.serialinfo.baud = pgm->baudrate? pgm->baudrate: 115200; + pinfo.serialinfo.cflags = SERIAL_8N1; + if(serial_open(port, pinfo, &pgm->fd) == -1) + return -1; + + unsigned char buf[32]; + + // Sync + memset(buf, 0, sizeof buf); + if(perform_serprog_cmd(pgm, S_CMD_SYNCNOP, NULL, 0, buf, 1) != 1 || buf[0] != S_ACK) { + pmsg_error("cannot sync; is this a serprog programmer?\n"); + return -1; + } + + // Get command bitmap + memset(my.cmd_bitmap, 0, sizeof my.cmd_bitmap); + if(perform_serprog_cmd(pgm, S_CMD_Q_CMDMAP, NULL, 0, my.cmd_bitmap, 32) != 0) { + pmsg_error("cannot get list of supported serprog commands\n"); + return -1; + } + + // Get protocol version + memset(buf, 0, sizeof buf); + if(!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_Q_IFACE) + || perform_serprog_cmd(pgm, S_CMD_Q_IFACE, NULL, 0, buf, 2) != 0) { + pmsg_error("cannot get serprog protocol version\n"); + return -1; + } + if(read_le16(buf) != 0x01) { + pmsg_error("unsupported serprog protocol version: %d\n", read_le16(buf)); + return -1; + } + + pmsg_info("serprog protocol version: %d\n", read_le16(buf)); + + // Get programmer name + if(is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_Q_PGMNAME)) { + memset(buf, 0, sizeof buf); + if(perform_serprog_cmd(pgm, S_CMD_Q_PGMNAME, NULL, 0, buf, 16) != 0) { + pmsg_error("cannot get programmer name\n"); + return -1; } + pmsg_info("programmer name: %s\n", buf); + } - unsigned char buf[32]; + // Check if required commands are supported + if(!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_O_SPIOP)) { + pmsg_error("the %s programmer does not support SPI operations\n", pgmid); + return -1; + } - // sync - memset(buf, 0, sizeof(buf)); - if (perform_serprog_cmd(pgm, S_CMD_SYNCNOP, NULL, 0, buf, 1) != 1 || buf[0] != S_ACK) { - pmsg_error("cannot sync; is this a serprog programmer?\n"); - return -1; - } + if(!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_CS_MODE)) { + pmsg_error("the %s programmer does not support setting the CS mode\n", pgmid); + return -1; + } - // get command bitmap - memset(my.cmd_bitmap, 0, sizeof(my.cmd_bitmap)); - if (perform_serprog_cmd(pgm, S_CMD_Q_CMDMAP, NULL, 0, my.cmd_bitmap, 32) != 0) { - pmsg_error("cannot get list of supported serprog commands\n"); - return -1; - } + if(!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_MODE)) { + pmsg_error("the %s programmer does not support setting the SPI mode\n", pgmid); + return -1; + } - // get protocol version - memset(buf, 0, sizeof(buf)); - if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_Q_IFACE) - || perform_serprog_cmd(pgm, S_CMD_Q_IFACE, NULL, 0, buf, 2) != 0) { - pmsg_error("cannot get serprog protocol version\n"); - return -1; - } - if (read_le16(buf) != 0x01) { - pmsg_error("unsupported serprog protocol version: %d\n", read_le16(buf)); - return -1; - } + if(my.cs > 0 && !is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { + pmsg_error("the %s programmer does not support changing the CS\n", pgmid); + return -1; + } - pmsg_info("serprog protocol version: %d\n", read_le16(buf)); - - // get programmer name - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_Q_PGMNAME)) { - memset(buf, 0, sizeof(buf)); - if (perform_serprog_cmd(pgm, S_CMD_Q_PGMNAME, NULL, 0, buf, 16) != 0) { - pmsg_error("cannot get programmer name\n"); - return -1; - } - pmsg_info("programmer name: %s\n", buf); - } - - // check if required commands are supported - if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_O_SPIOP)) { - pmsg_error("the %s programmer does not support SPI operations\n", pgmid); - return -1; - } - - if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_CS_MODE)) { - pmsg_error("the %s programmer does not support setting the CS mode\n", pgmid); - return -1; - } - - if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_MODE)) { - pmsg_error("the %s programmer does not support setting the SPI mode\n", pgmid); - return -1; - } - - if (my.cs > 0 && !is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { - pmsg_error("the %s programmer does not support changing the CS\n", pgmid); - return -1; - } - - return 0; + return 0; } static void serprog_disable(const PROGRAMMER *pgm) { - unsigned char buf[32]; - // switch cs to auto - const unsigned char cs_mode = CS_MODE_AUTO; - if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { - pmsg_error("cannot reset the CS mode to auto\n"); - } - // disable output - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { - memset(buf, 0, sizeof(buf)); - buf[0] = 0; // Pin state disable - if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot disable pin state\n"); - } - } - // restore half duplex - memset(buf, 0, sizeof(buf)); - buf[0] = SPI_MODE_HALF_DUPLEX; - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot reset SPI half duplex mode\n"); - } - // reset CS to CS_0 - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { - memset(buf, 0, sizeof(buf)); - buf[0] = 0; - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot reset CS to CS_0\n"); - } + unsigned char buf[32]; + + // Switch CS to auto + const unsigned char cs_mode = CS_MODE_AUTO; + + if(perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { + pmsg_error("cannot reset the CS mode to auto\n"); + } + // Disable output + if(is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { + memset(buf, 0, sizeof buf); + buf[0] = 0; // Pin state disable + if(perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { + pmsg_error("cannot disable pin state\n"); } + } + // Restore half duplex + memset(buf, 0, sizeof buf); + buf[0] = SPI_MODE_HALF_DUPLEX; + if(perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) + pmsg_error("cannot reset SPI half duplex mode\n"); + + // Reset CS to CS_0 + if(is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { + memset(buf, 0, sizeof buf); + buf[0] = 0; + if(perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) + pmsg_error("cannot reset CS to CS_0\n"); + } } static void serprog_close(PROGRAMMER *pgm) { - serial_close(&pgm->fd); + serial_close(&pgm->fd); } static int serprog_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned char *res) { - return serprog_spi_duplex(pgm, cmd, res, 4); + return serprog_spi_duplex(pgm, cmd, res, 4); } static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *part) { - if (part->prog_modes & PM_TPI) { - /* We do not support TPI. This is a dedicated SPI thing */ - pmsg_error("the %s programmer does not support TPI\n", pgmid); - return -1; + if(part->prog_modes & PM_TPI) { + // We do not support TPI; this is a dedicated SPI thing + pmsg_error("the %s programmer does not support TPI\n", pgmid); + return -1; + } + + unsigned char buf[32]; + + // Set SPI clock frequency + if(is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { + memset(buf, 0, sizeof buf); + uint32_t frequency = + pgm->bitclock > 0? pgm->bitclock: + part->factory_fcpu > 0? part->factory_fcpu/4: + 250000; + write_le32(buf, frequency); + if(perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { + pmsg_error("cannot set SPI frequency %u Hz\n", (unsigned) frequency); + return -1; } + my.actual_frequency = read_le32(buf); + } - unsigned char buf[32]; - - // set SPI clock frequency - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { - memset(buf, 0, sizeof(buf)); - uint32_t frequency; - if (pgm->bitclock > 0) { - frequency = pgm->bitclock; - } else if (part->factory_fcpu > 0) { - frequency = (part->factory_fcpu / 4); - } else { - frequency = 250000; - } - write_le32(buf, frequency); - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { - pmsg_error("cannot set SPI frequency\n"); - return -1; - } - my.actual_frequency = read_le32(buf); + // Set active chip select + if(is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { + memset(buf, 0, sizeof buf); + buf[0] = my.cs; + if(perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { + pmsg_error("cannot change CS\n"); + return -1; } + } - // set active chip select - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_CS)) { - memset(buf, 0, sizeof(buf)); - buf[0] = my.cs; - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_CS, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot change CS\n"); - return -1; - } + // Set full duplex + memset(buf, 0, sizeof buf); + buf[0] = SPI_MODE_FULL_DUPLEX; + if(perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { + pmsg_error("cannot set SPI full duplex mode\n"); + return -1; + } + + // Set output + if(is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { + memset(buf, 0, sizeof buf); + buf[0] = 1; // Pin state enable + if(perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { + pmsg_error("cannot enable pin state\n"); + return -1; } + } - // set full duplex - memset(buf, 0, sizeof(buf)); - buf[0] = SPI_MODE_FULL_DUPLEX; - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_MODE, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot set SPI full duplex mode\n"); - return -1; - } + // Enable the CS/reset pin + const unsigned char cs_mode = CS_MODE_SELECTED; - // set output - if (is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_PIN_STATE)) { - memset(buf, 0, sizeof(buf)); - buf[0] = 1; // Pin state enable - if (perform_serprog_cmd(pgm, S_CMD_S_PIN_STATE, buf, 1, NULL, 0) != 0) { - pmsg_error("cannot enable pin state\n"); - return -1; - } - } + if(perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { + pmsg_error("cannot enable the reset pin\n"); + return -1; + } - // enable the CS / reset pin - const unsigned char cs_mode = CS_MODE_SELECTED; - if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { - pmsg_error("cannot enable the reset pin\n"); - return -1; - } + int tries, ret; - int tries, ret; + // Enable programming on the part + tries = 0; + do { + ret = pgm->program_enable(pgm, part); + if(ret == 0 || ret == -1) + break; + } while(tries++ < 65); - //enable programming on the part - tries = 0; - do { - ret = pgm->program_enable(pgm, part); - if (ret == 0 || ret == -1) - break; - } while(tries++ < 65); + if(ret) + pmsg_error("AVR device not responding\n"); - if (ret) - pmsg_error("AVR device not responding\n"); - - return ret; + return ret; } /* used linuxspi.c as a template: @@ -366,66 +361,68 @@ static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *part) { * Copyright (C) 2018 Ralf Ramsauer */ static int serprog_program_enable(const PROGRAMMER *pgm, const AVRPART *p) { - unsigned char cmd[4], res[4]; + unsigned char cmd[4], res[4]; - if (!p->op[AVR_OP_PGM_ENABLE]) { - pmsg_error("program enable instruction not defined for part %s\n", p->desc); - return -1; - } + if(!p->op[AVR_OP_PGM_ENABLE]) { + pmsg_error("program enable instruction not defined for part %s\n", p->desc); + return -1; + } - memset(cmd, 0, sizeof(cmd)); - avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd); //set the cmd - pgm->cmd(pgm, cmd, res); + memset(cmd, 0, sizeof cmd); + avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd); // Set the cmd + pgm->cmd(pgm, cmd, res); - if (res[2] != cmd[1]) { - /** From ATtiny441 datasheet: - * - * In some systems, the programmer cannot guarantee that SCK is held low - * during power-up. In this case, RESET must be given a positive pulse after - * SCK has been set to '0'. The duration of the pulse must be at least t RST - * plus two CPU clock cycles. See Table 25-5 on page 240 for definition of - * minimum pulse width on RESET pin, t RST - * 2. Wait for at least 20 ms and then enable serial programming by sending - * the Programming Enable serial instruction to the SDO pin - * 3. The serial programming instructions will not work if the communication - * is out of synchronization. When in sync, the second byte (0x53) will echo - * back when issuing the third byte of the Programming Enable instruction - * ... - * If the 0x53 did not echo back, give RESET a positive pulse and issue a - * new Programming Enable command - */ - unsigned char cs_mode = CS_MODE_DESELECTED; - if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { - return -1; - } - usleep(5); - cs_mode = CS_MODE_SELECTED; - if (perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) { - return -1; - } - usleep(20000); + if(res[2] != cmd[1]) { - return -2; - } + /** From ATtiny441 datasheet: + * + * In some systems, the programmer cannot guarantee that SCK is held low + * during power-up. In this case, RESET must be given a positive pulse after + * SCK has been set to '0'. The duration of the pulse must be at least t RST + * plus two CPU clock cycles. See Table 25-5 on page 240 for definition of + * minimum pulse width on RESET pin, t RST + * 2. Wait for at least 20 ms and then enable serial programming by sending + * the Programming Enable serial instruction to the SDO pin + * 3. The serial programming instructions will not work if the communication + * is out of synchronization. When in sync, the second byte (0x53) will echo + * back when issuing the third byte of the Programming Enable instruction + * ... + * If the 0x53 did not echo back, give RESET a positive pulse and issue a + * new Programming Enable command + */ - return 0; + unsigned char cs_mode = CS_MODE_DESELECTED; + if(perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) + return -1; + + usleep(5); + cs_mode = CS_MODE_SELECTED; + if(perform_serprog_cmd(pgm, S_CMD_S_CS_MODE, &cs_mode, 1, NULL, 0) != 0) + return -1; + + usleep(20000); + + return -2; + } + + return 0; } static int serprog_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { - unsigned char cmd[4], res[4]; + unsigned char cmd[4], res[4]; - if (!p->op[AVR_OP_CHIP_ERASE]) { - pmsg_error("chip erase instruction not defined for part %s\n", p->desc); - return -1; - } + if(!p->op[AVR_OP_CHIP_ERASE]) { + pmsg_error("chip erase instruction not defined for part %s\n", p->desc); + return -1; + } - memset(cmd, 0, sizeof(cmd)); - avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd); - pgm->cmd(pgm, cmd, res); - usleep(p->chip_erase_delay); - pgm->initialize(pgm, p); + memset(cmd, 0, sizeof cmd); + avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd); + pgm->cmd(pgm, cmd, res); + usleep(p->chip_erase_delay); + pgm->initialize(pgm, p); - return 0; + return 0; } static void serprog_display(const PROGRAMMER *pgm, const char *p) { @@ -435,87 +432,88 @@ static void serprog_enable(PROGRAMMER *pgm, const AVRPART *p) { } static void serprog_setup(PROGRAMMER *pgm) { - pgm->cookie = mmt_malloc(sizeof(struct pdata)); + pgm->cookie = mmt_malloc(sizeof(struct pdata)); } static void serprog_teardown(PROGRAMMER *pgm) { - mmt_free(pgm->cookie); - pgm->cookie = NULL; + mmt_free(pgm->cookie); + pgm->cookie = NULL; } static int serprog_set_sck_period(const PROGRAMMER *pgm, double v) { - if (!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { - return -1; - } - unsigned char buf[8]; - memset(buf, 0, sizeof(buf)); - write_le32(buf, v); - if (perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { - pmsg_error("cannot set SPI frequency\n"); - return -1; - } - my.actual_frequency = read_le32(buf); - return 0; + if(!is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) + return -1; + + unsigned char buf[8]; + + memset(buf, 0, sizeof buf); + write_le32(buf, v); + if(perform_serprog_cmd(pgm, S_CMD_S_SPI_FREQ, buf, 4, buf, 4) != 0) { + pmsg_error("cannot set SPI frequency\n"); + return -1; + } + my.actual_frequency = read_le32(buf); + return 0; } static int serprog_get_sck_period(const PROGRAMMER *pgm, double *v) { - *v = my.actual_frequency; - return 0; + *v = my.actual_frequency; + return 0; } static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; - int rv = 0; + LNODEID ln; + const char *extended_param; + int rv = 0; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for(ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); - if (str_starts(extended_param, "cs=")) { - unsigned int cs; - if (sscanf(extended_param, "cs=%u", &cs) != 1) { - pmsg_error("invalid chip select '%s'\n", extended_param); - rv = -1; - } - my.cs = cs; - continue; - } + if(str_starts(extended_param, "cs=")) { + unsigned int cs; - if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xcs=cs_num Sets the chip select (CS) to use on supported programmers\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT; - } - - pmsg_error("invalid extended parameter '%s'\n", extended_param); + if(sscanf(extended_param, "cs=%u", &cs) != 1) { + pmsg_error("invalid chip select '%s'\n", extended_param); rv = -1; + } + my.cs = cs; + continue; } - return rv; + if(str_eq(extended_param, "help")) { + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xcs=cs_num Sets the chip select (CS) to use on supported programmers\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return LIBAVRDUDE_EXIT; + } + + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; + } + + return rv; } void serprog_initpgm(PROGRAMMER *pgm) { - strcpy(pgm->type, "serprog"); + strcpy(pgm->type, "serprog"); - // required fields - pgm->initialize = serprog_initialize; - pgm->display = serprog_display; - pgm->enable = serprog_enable; - pgm->disable = serprog_disable; - pgm->program_enable = serprog_program_enable; - pgm->chip_erase = serprog_chip_erase; - pgm->cmd = serprog_cmd; - pgm->open = serprog_open; - pgm->close = serprog_close; - pgm->read_byte = avr_read_byte_default; - pgm->write_byte = avr_write_byte_default; + // Required fields + pgm->initialize = serprog_initialize; + pgm->display = serprog_display; + pgm->enable = serprog_enable; + pgm->disable = serprog_disable; + pgm->program_enable = serprog_program_enable; + pgm->chip_erase = serprog_chip_erase; + pgm->cmd = serprog_cmd; + pgm->open = serprog_open; + pgm->close = serprog_close; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; - // optional fields - pgm->setup = serprog_setup; - pgm->teardown = serprog_teardown; - pgm->parseextparams = serprog_parseextparams; - pgm->get_sck_period = serprog_get_sck_period; - pgm->set_sck_period = serprog_set_sck_period; + // Optional fields + pgm->setup = serprog_setup; + pgm->teardown = serprog_teardown; + pgm->parseextparams = serprog_parseextparams; + pgm->get_sck_period = serprog_get_sck_period; + pgm->set_sck_period = serprog_set_sck_period; } - diff --git a/src/serprog.h b/src/serprog.h index 99ec9401..587f66f8 100644 --- a/src/serprog.h +++ b/src/serprog.h @@ -1,3 +1,4 @@ + /* * avrdude - A Downloader/Uploader for AVR device programmers * @@ -31,6 +32,4 @@ void serprog_initpgm(PROGRAMMER *pgm); #ifdef __cplusplus } #endif - -#endif //serprog_h - +#endif // serprog_h From acf59cb61c86b49dd13118e571784141f7cdd35e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 21 May 2024 23:19:46 +0100 Subject: [PATCH 126/422] Convert bitclock period to frequency --- src/serprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serprog.c b/src/serprog.c index 240eac90..739790b2 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -293,7 +293,7 @@ static int serprog_initialize(const PROGRAMMER *pgm, const AVRPART *part) { if(is_serprog_cmd_supported(my.cmd_bitmap, S_CMD_S_SPI_FREQ)) { memset(buf, 0, sizeof buf); uint32_t frequency = - pgm->bitclock > 0? pgm->bitclock: + pgm->bitclock > 0? 1/pgm->bitclock: part->factory_fcpu > 0? part->factory_fcpu/4: 250000; write_le32(buf, frequency); From aa772876e5c5281d2694447fcfe158f7e80af24d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 27 May 2024 16:16:48 +0100 Subject: [PATCH 127/422] Remove EEPROM from ATtiny11 avrdude.conf entry --- src/avrdude.conf.in | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 48d68769..ce237335 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -3452,13 +3452,6 @@ part # t11 synchcycles = 6; factory_fcpu = 1200000; - memory "eeprom" - size = 64; - delay = 5; - blocksize = 64; - readsize = 256; - ; - memory "flash" size = 1024; delay = 3; From e0a5d47bbef0c79e4589dc6e75244dec99e32262 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 27 May 2024 16:19:05 +0100 Subject: [PATCH 128/422] Guard serial_number access in usbhid_open() to avoid sigfault --- src/usb_hidapi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/usb_hidapi.c b/src/usb_hidapi.c index 07732ff3..70a75cfc 100644 --- a/src/usb_hidapi.c +++ b/src/usb_hidapi.c @@ -97,14 +97,14 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor walk = list; while (walk) { - pmsg_notice("usbhid_open(): found %ls, serno: %ls\n", walk->product_string, walk->serial_number); - size_t slen = wcslen(walk->serial_number); - if (slen >= serlen && wcscmp(walk->serial_number + slen - serlen, wserno) == 0) - { - /* Found matching serial number */ - break; + if(walk->serial_number) { + pmsg_notice("usbhid_open(): found %ls, serno: %ls\n", walk->product_string, walk->serial_number); + size_t slen = wcslen(walk->serial_number); + // Found matching serial number? + if (slen >= serlen && wcscmp(walk->serial_number + slen - serlen, wserno) == 0) + break; + pmsg_debug("usbhid_open(): serial number does not match\n"); } - pmsg_debug("usbhid_open(): serial number does not match\n"); walk = walk->next; } if (walk == NULL) { From a7ba014d5a13ada2c8219516af6b0b7d135a75eb Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 29 May 2024 22:46:18 +0100 Subject: [PATCH 129/422] Allow selection of program modes for developer options --- src/developer_opts.c | 72 ++++++++++++++++++++++++++++++-------------- src/main.c | 8 ++--- 2 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index 27fec4cf..2b391cbe 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -827,7 +827,29 @@ void dev_output_pgm_part(int dev_opt_c, const char *programmer, int dev_opt_p, c } -// -p */[dASsrcow*ti] +// Which programming modes should be considered, given the flags? +static int prog_modes_in_flags(int prog_modes, const char *flags) { + int pm = 0, quirky = 0; + + for(const char *p = flags; *p; p++) + switch(*p) { + case 'B': pm |= PM_SPM; break; + case 'U': pm |= PM_UPDI; break; + case 'P': pm |= PM_PDI; break; + case 'T': pm |= PM_TPI; break; + case 'I': pm |= PM_ISP; break; + case 'J': pm |= PM_JTAG | PM_JTAGmkI | PM_XMEGAJTAG; break; + case 'W': pm |= PM_debugWIRE; break; + case 'H': pm |= PM_HVPP | PM_HVSP; break; + case 'Q': pm |= PM_ALL & ~(PM_SPM | PM_UPDI | PM_PDI | PM_TPI | PM_ISP | PM_JTAG | PM_JTAGmkI | + PM_XMEGAJTAG | PM_debugWIRE | PM_HVPP | PM_HVSP); + quirky = 1; + } + + return (prog_modes == 0 && quirky) || !pm || (prog_modes & pm); +} + +// -p /[cdoASsrw*tiBUPTIJWHQ] void dev_output_part_defs(char *partdesc) { bool cmdok, waits, opspi, descs, astrc, strct, cmpst, injct, raw, all, tsv; char *flags; @@ -840,7 +862,7 @@ void dev_output_part_defs(char *partdesc) { if(!flags && str_eq(partdesc, "*")) // Treat -p * as if it was -p */s flags = "s"; - if(!*flags || !strchr("cdoASsrw*ti", *flags)) { + if(!*flags || !strchr("cdoASsrw*tiBUPTIJWHQ", *flags)) { dev_info("%s: flags for developer option -p / not recognised\n", progname); dev_info( "Wildcard examples (these need protecting in the shell through quoting):\n" @@ -849,20 +871,22 @@ void dev_output_part_defs(char *partdesc) { " *32[0-9] matches ATmega329, ATmega325 and ATmega328\n" " *32? matches ATmega329, ATmega32A, ATmega325 and ATmega328\n" "Flags (one or more of the characters below):\n" - " d description of core part features\n" - " A show entries of avrdude.conf parts with all values\n" - " S show entries of avrdude.conf parts with necessary values\n" - " s show short entries of avrdude.conf parts using parent\n" - " r show entries of avrdude.conf parts as raw dump\n" - " c check and report errors in address bits of SPI commands\n" - " o opcodes for SPI programming parts and memories\n" - " 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" + " d description of core part features\n" + " A show entries of avrdude.conf parts with all values\n" + " S show entries of avrdude.conf parts with necessary values\n" + " s show short entries of avrdude.conf parts using parent\n" + " r show entries of avrdude.conf parts as raw dump\n" + " c check and report errors in address bits of SPI commands\n" + " o opcodes for SPI programming parts and memories\n" + " w wd_... constants for ISP parts\n" + " * as first character: all of the above except s and S\n" + " BUPTIJWHQ only Bootloader/UPDI/PDI/TPI/ISP/JTAG/debugWire/HV/quirky MUCs\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" + " $ avrdude -p ATmega*/Ud | wc -l\n" " avrdude -p*/r | sort\n" "Notes:\n" " -p * is the same as -p */s\n" @@ -888,7 +912,6 @@ void dev_output_part_defs(char *partdesc) { tsv = !!strchr(flags, 't'); injct = !!strchr(flags, 'i'); - // Go through all memories and add them to the memory order list for(LNODEID ln1 = lfirst(part_list); ln1; ln1 = lnext(ln1)) { AVRPART *p = ldata(ln1); @@ -918,6 +941,8 @@ void dev_output_part_defs(char *partdesc) { if(!part_eq(p, partdesc, str_casematch)) continue; + if(!prog_modes_in_flags(p->prog_modes, flags)) + continue; if(astrc || strct || cmpst) dev_part_strct(p, tsv, @@ -1338,7 +1363,7 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas } -// -c */[ASsrti] +// -c /[ASsrtiBUPTIJWHQ] void dev_output_pgm_defs(char *pgmidcp) { bool astrc, strct, cmpst, raw, tsv, injct; char *flags; @@ -1351,7 +1376,7 @@ void dev_output_pgm_defs(char *pgmidcp) { if(!flags && str_eq(pgmidcp, "*")) // Treat -c * as if it was -c */s flags = "s"; - if(!*flags || !strchr("ASsrti", *flags)) { + if(!*flags || !strchr("ASsrtiBUPTIJWHQ", *flags)) { dev_info("%s: flags for developer option -c / not recognised\n", progname); dev_info( "Wildcard examples (these need protecting in the shell through quoting):\n" @@ -1360,12 +1385,13 @@ void dev_output_pgm_defs(char *pgmidcp) { " jtag*pdi matches jtag2pdi, jtag3pdi, jtag3updi and jtag2updi\n" " jtag?pdi matches jtag2pdi and jtag3pdi\n" "Flags (one or more of the characters below):\n" - " A show entries of avrdude.conf programmers with all values\n" - " S show entries of avrdude.conf programmers with necessary values\n" - " s show short entries of avrdude.conf programmers using parent\n" - " r show entries of avrdude.conf programmers as raw dump\n" - " t use tab separated values as much as possible\n" - " i inject assignments from source code table\n" + " A show entries of avrdude.conf programmers with all values\n" + " S show entries of avrdude.conf programmers with necessary values\n" + " s show short entries of avrdude.conf programmers using parent\n" + " r show entries of avrdude.conf programmers as raw dump\n" + " t use tab separated values as much as possible\n" + " i inject assignments from source code table\n" + " BUPTIJWHQ only Bootloader/UPDI/PDI/TPI/ISP/JTAG/debugWire/HV/quirky MUCs\n" "Examples:\n" " $ avrdude -c usbasp/s\n" " $ avrdude -c */st | grep baudrate\n" @@ -1402,6 +1428,8 @@ void dev_output_pgm_defs(char *pgmidcp) { } if(!matched) continue; + if(!prog_modes_in_flags(pgm->prog_modes, flags)) + continue; if(dev_nprinted > nprinted) { dev_info("\n"); diff --git a/src/main.c b/src/main.c index 8d7b150f..f117ccee 100644 --- a/src/main.c +++ b/src/main.c @@ -437,11 +437,11 @@ static void replace_backslashes(char *s) } } -// Return 2 if str is * or starts with */, 1 if str contains / but is not a valid part, 0 otherwise +// Return whether a part/programmer string is a developer option and if so which type static int dev_opt(const char *str) { return !str? 0: - str_eq(str, "*") || str_starts(str, "*/")? 2: + str_eq(str, "*") || str_starts(str, "*/s")? 2: // Print PART DEFINITIONS comment as well strchr(str, '/') && !locate_part(part_list, str); } @@ -1127,8 +1127,8 @@ int main(int argc, char * argv []) pgmid = cache_string(default_programmer); // Developer options to print parts and/or programmer entries of avrdude.conf - int dev_opt_c = dev_opt(pgmid); // -c /[sSArt] - int dev_opt_p = dev_opt(partdesc); // -p /[dsSArcow*t] + int dev_opt_c = dev_opt(pgmid); // -c /[ASsrtiBUPTIJWHQ] + int dev_opt_p = dev_opt(partdesc); // -p /[cdoASsrw*tiBUPTIJWHQ] if(dev_opt_c || dev_opt_p) { // See -c/h and or -p/h dev_output_pgm_part(dev_opt_c, pgmid, dev_opt_p, partdesc); From d3c17771350196aeed437a91668c005cf57d7a9a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 29 May 2024 22:55:29 +0100 Subject: [PATCH 130/422] Add /d developer option for -c --- src/developer_opts.c | 23 +++++++++++++++++++---- src/main.c | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index 2b391cbe..fa8dd69c 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -1363,9 +1363,9 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas } -// -c /[ASsrtiBUPTIJWHQ] +// -c /[dASsrtiBUPTIJWHQ] void dev_output_pgm_defs(char *pgmidcp) { - bool astrc, strct, cmpst, raw, tsv, injct; + bool descs, astrc, strct, cmpst, raw, tsv, injct; char *flags; int nprinted; PROGRAMMER *nullpgm = pgm_new(); @@ -1376,7 +1376,7 @@ void dev_output_pgm_defs(char *pgmidcp) { if(!flags && str_eq(pgmidcp, "*")) // Treat -c * as if it was -c */s flags = "s"; - if(!*flags || !strchr("ASsrtiBUPTIJWHQ", *flags)) { + if(!*flags || !strchr("dASsrtiBUPTIJWHQ", *flags)) { dev_info("%s: flags for developer option -c / not recognised\n", progname); dev_info( "Wildcard examples (these need protecting in the shell through quoting):\n" @@ -1385,6 +1385,7 @@ void dev_output_pgm_defs(char *pgmidcp) { " jtag*pdi matches jtag2pdi, jtag3pdi, jtag3updi and jtag2updi\n" " jtag?pdi matches jtag2pdi and jtag3pdi\n" "Flags (one or more of the characters below):\n" + " d description of core programmer features\n" " A show entries of avrdude.conf programmers with all values\n" " S show entries of avrdude.conf programmers with necessary values\n" " s show short entries of avrdude.conf programmers using parent\n" @@ -1410,6 +1411,7 @@ void dev_output_pgm_defs(char *pgmidcp) { astrc = !!strchr(flags, 'A'); strct = !!strchr(flags, 'S'); cmpst = !!strchr(flags, 's'); + descs = !!strchr(flags, 'd'); raw = !!strchr(flags, 'r'); tsv = !!strchr(flags, 't'); injct = !!strchr(flags, 'i'); @@ -1431,7 +1433,7 @@ void dev_output_pgm_defs(char *pgmidcp) { if(!prog_modes_in_flags(pgm->prog_modes, flags)) continue; - if(dev_nprinted > nprinted) { + if(!descs && dev_nprinted > nprinted) { dev_info("\n"); nprinted = dev_nprinted; } @@ -1443,6 +1445,19 @@ void dev_output_pgm_defs(char *pgmidcp) { pgm->parent_id && *pgm->parent_id? locate_programmer(programmers, pgm->parent_id): nullpgm, injct); + if(descs) + for(LNODEID idn=lfirst(pgm->id); idn; idn=lnext(idn)) { + char *id = ldata(idn); + int len = 19-strlen(id); + dev_info("%s '%s' =>%*s ['%s', '%s'], # %s %d\n", + tsv? ".desc": " ", + id, len > 0? len: 0, "", + dev_prog_modes(pgm->prog_modes), + pgm->desc, + pgm->config_file, pgm->lineno + ); + } + if(raw) dev_pgm_raw(pgm); } diff --git a/src/main.c b/src/main.c index f117ccee..0742d128 100644 --- a/src/main.c +++ b/src/main.c @@ -1127,7 +1127,7 @@ int main(int argc, char * argv []) pgmid = cache_string(default_programmer); // Developer options to print parts and/or programmer entries of avrdude.conf - int dev_opt_c = dev_opt(pgmid); // -c /[ASsrtiBUPTIJWHQ] + int dev_opt_c = dev_opt(pgmid); // -c /[dASsrtiBUPTIJWHQ] int dev_opt_p = dev_opt(partdesc); // -p /[cdoASsrw*tiBUPTIJWHQ] if(dev_opt_c || dev_opt_p) { // See -c/h and or -p/h From 2754cb0d62e3ef4504b50ac602a141fb5100259c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 1 Jun 2024 08:59:18 +0100 Subject: [PATCH 131/422] Update NEWS --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index c9a3f82a..8dedfe92 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ Changes since version 7.3: * New programmers supported: + - serprog + * Issues fixed: - Avrintel.h missing from installation #1683 @@ -36,6 +38,7 @@ Changes since version 7.3: - Add support for more AVR-DU parts #1742 - Misleading error message: cannot find programmer id #1805 - Custom programmer broken in v7.3 #1807 + - ATtiny11 does not have EEPROM #1812 * Pull requests: @@ -83,6 +86,10 @@ Changes since version 7.3: - Prepare for next urboot version #1808 - Rename AVRDUDE symbol names ending in _t #1809 - Warn when programmer failes to define prog_modes #1810 + - Add serprog programmer #1801 + - Remove EEPROM from ATtiny11 avrdude.conf entry #1814 + - Guard serial_number access in usbhid_open() to avoid segfault #1815 + - Allow selection of program modes for developer options #1816 * Internals: From ffdf66d927a717d29e1eca43092fe0cea6c39564 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 10 Jun 2024 20:40:11 +0100 Subject: [PATCH 132/422] Make Copyright notices greppable/systematic --- AUTHORS | 3 +-- src/Makefile.am | 2 +- src/avr.c | 2 +- src/avr910.c | 6 +++--- src/avr910.h | 2 +- src/avrcache.c | 2 +- src/avrftdi.c | 4 ++-- src/avrftdi.h | 4 ++-- src/avrpart.c | 2 +- src/bitbang.c | 2 +- src/bitbang.h | 2 +- src/butterfly.c | 2 +- src/butterfly.h | 2 +- src/ch341a.c | 2 +- src/ch341a.h | 2 +- src/config.c | 2 +- src/config.h | 2 +- src/config_gram.y | 2 +- src/configure.ac | 2 +- src/doc/Makefile.am | 2 +- src/dryrun.h | 2 +- src/fileio.c | 2 +- src/ft245r.c | 2 +- src/jtagmkI.h | 2 +- src/jtagmkII.h | 2 +- src/lexer.l | 2 +- src/linuxspi.h | 2 +- src/lists.c | 2 +- src/main.c | 4 ++-- src/msvc/getopt.c | 2 +- src/par.c | 2 +- src/par.h | 2 +- src/pgm.c | 4 ++-- src/pgm_type.c | 4 ++-- src/pickit2.c | 2 +- src/pickit2.h | 2 +- src/pindefs.c | 2 +- src/ppi.c | 2 +- src/ppi.h | 2 +- src/ppiwin.c | 5 ++--- src/ser_avrdoper.c | 2 +- src/ser_posix.c | 2 +- src/ser_win32.c | 4 ++-- src/serbb.h | 2 +- src/serbb_posix.c | 2 +- src/serbb_win32.c | 2 +- src/serialupdi.c | 2 +- src/serialupdi.h | 2 +- src/stk500.h | 2 +- src/stk500v2.c | 2 +- src/stk500v2.h | 2 +- src/term.c | 2 +- src/tpi.h | 2 +- src/update.c | 2 +- src/updi_constants.h | 2 +- src/updi_link.c | 2 +- src/updi_link.h | 2 +- src/updi_nvm.c | 2 +- src/updi_nvm.h | 2 +- src/updi_nvm_v0.c | 2 +- src/updi_nvm_v0.h | 2 +- src/updi_nvm_v2.c | 2 +- src/updi_nvm_v2.h | 2 +- src/updi_nvm_v3.c | 2 +- src/updi_nvm_v3.h | 2 +- src/updi_nvm_v4.c | 2 +- src/updi_nvm_v4.h | 2 +- src/updi_nvm_v5.c | 2 +- src/updi_nvm_v5.h | 2 +- src/updi_readwrite.c | 2 +- src/updi_readwrite.h | 2 +- src/updi_state.c | 2 +- src/updi_state.h | 2 +- src/usbasp.c | 4 ++-- src/usbasp.h | 2 +- src/windows.rc.in | 2 +- 76 files changed, 86 insertions(+), 88 deletions(-) diff --git a/AUTHORS b/AUTHORS index 116d1290..bcebd68b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,7 +16,7 @@ Contributors: Eric Weddington Jan-Hinnerk Reichert Alex Shepherd - Martin Thomas + Martin J. Thomas Theodore A. Roth Juliane Holzt Colin O'Flynn @@ -47,4 +47,3 @@ Contributors to code no longer present: Chris Liechti for loaddrv modifications For minor contributions, please see the ChangeLog files / Git log. - diff --git a/src/Makefile.am b/src/Makefile.am index f67ac711..9e7a76ad 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # avrdude - A Downloader/Uploader for AVR device programmers -# Copyright (C) 2003, 2004 Theodore A. Roth +# Copyright (C) 2003, 2004 Theodore A. Roth # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/avr.c b/src/avr.c index 4a3a9fef..969fdff7 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2011 Darell Tan * * This program is free software; you can redistribute it and/or modify diff --git a/src/avr910.c b/src/avr910.c index 1cc28f18..2770a04a 100644 --- a/src/avr910.c +++ b/src/avr910.c @@ -1,8 +1,8 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth - * Copyright 2007 Joerg Wunsch - * Copyright 2008 Klaus Leidinger + * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright (C) 2007 Joerg Wunsch + * Copyright (C) 2008 Klaus Leidinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/avr910.h b/src/avr910.h index c18e7779..f30fa6a3 100644 --- a/src/avr910.h +++ b/src/avr910.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright (C) 2003-2004 Theodore A. Roth * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/avrcache.c b/src/avrcache.c index fe0ff9a2..ea091577 100644 --- a/src/avrcache.c +++ b/src/avrcache.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2022 Stefan Rueger + * Copyright (C) 2022 Stefan Rueger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/avrftdi.c b/src/avrftdi.c index 36408334..e3435300 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -1,6 +1,6 @@ /* - * avrftdi - extension for avrdude, Wolfgang Moser, Ville Voipio - * Copyright (C) 2011 Hannes Weisbach, Doug Springer + * avrftdi - extension for avrdude + * Copyright (C) 2011 Wolfgang Moser, Ville Voipio, Hannes Weisbach, Doug Springer * Copyright (C) 2023 Jeff Kent * * This program is free software; you can redistribute it and/or modify diff --git a/src/avrftdi.h b/src/avrftdi.h index 3c3a4983..30493271 100644 --- a/src/avrftdi.h +++ b/src/avrftdi.h @@ -1,6 +1,6 @@ /* - * avrftdi - extension for avrdude, Wolfgang Moser, Ville Voipio - * Copyright (C) 2011 Hannes Weisbach, Doug Springer + * avrftdi - extension for avrdude + * Copyright (C) 2011 Wolfgang Moser, Ville Voipio, Hannes Weisbach, Doug Springer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/avrpart.c b/src/avrpart.c index 57099d07..24a241d5 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2006 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify diff --git a/src/bitbang.c b/src/bitbang.c index dabefc81..6c184832 100644 --- a/src/bitbang.c +++ b/src/bitbang.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean + * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean * Copyright (C) 2005 Juliane Holzt * Copyright (C) 2011 Darell Tan * diff --git a/src/bitbang.h b/src/bitbang.h index 08c248af..1e38afb0 100644 --- a/src/bitbang.h +++ b/src/bitbang.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean + * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean * Copyright (C) 2005 Juliane Holzt * Copyright (C) 2011 Darell Tan * diff --git a/src/butterfly.c b/src/butterfly.c index 9d453748..a645e540 100644 --- a/src/butterfly.c +++ b/src/butterfly.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright (C) 2003-2004 Theodore A. Roth * Copyright (C) 2005, 2007 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify diff --git a/src/butterfly.h b/src/butterfly.h index 2d4bfa64..c1492504 100644 --- a/src/butterfly.h +++ b/src/butterfly.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright (C) 2003-2004 Theodore A. Roth * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ch341a.c b/src/ch341a.c index 12f4ff0b..ba2276c0 100644 --- a/src/ch341a.c +++ b/src/ch341a.c @@ -2,7 +2,7 @@ * avrdude - A Downloader/Uploader for AVR device programmers * * avrdude support for CH341A/B - * Copyright (C) 2016 Alexey Sadkov, paged access by smr 2023 + * Copyright (C) 2016 Alexey Sadkov, paged access by smr 2023 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ch341a.h b/src/ch341a.h index 05347562..1d9b04bc 100644 --- a/src/ch341a.h +++ b/src/ch341a.h @@ -2,7 +2,7 @@ * avrdude - A Downloader/Uploader for AVR device programmers * * avrdude support for CH341A/B - * Copyright (C) 2016 Alexey Sadkov + * Copyright (C) 2016 Alexey Sadkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/config.c b/src/config.c index 5adef5a7..eb7b45a8 100644 --- a/src/config.c +++ b/src/config.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2022 Stefan Rueger * * This program is free software; you can redistribute it and/or modify diff --git a/src/config.h b/src/config.h index 82583158..630f9c7a 100644 --- a/src/config.h +++ b/src/config.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/config_gram.y b/src/config_gram.y index 29c2ca1e..f6af4744 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2006 Joerg Wunsch * Copyright (C) 2022- Stefan Rueger * diff --git a/src/configure.ac b/src/configure.ac index 969fc085..0b9a2e85 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -1,6 +1,6 @@ # # avrdude - A Downloader/Uploader for AVR device programmers -# Copyright (C) 2003, 2004 Theodore A. Roth +# Copyright (C) 2003, 2004 Theodore A. Roth # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/doc/Makefile.am b/src/doc/Makefile.am index e0b19d12..7be681c8 100644 --- a/src/doc/Makefile.am +++ b/src/doc/Makefile.am @@ -1,6 +1,6 @@ # # avrdude - A Downloader/Uploader for AVR device programmers -# Copyright (C) 2003 Theodore A. Roth +# Copyright (C) 2003 Theodore A. Roth # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/dryrun.h b/src/dryrun.h index bebe2413..7685053a 100644 --- a/src/dryrun.h +++ b/src/dryrun.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2022 Stefan Rueger + * Copyright (C) 2022 Stefan Rueger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/fileio.c b/src/fileio.c index b0aeb586..08d624c1 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2023 Stefan Rueger * * This program is free software; you can redistribute it and/or modify diff --git a/src/ft245r.c b/src/ft245r.c index e52ec3d6..7cb93fe7 100644 --- a/src/ft245r.c +++ b/src/ft245r.c @@ -1,6 +1,6 @@ /* * AVRDUDE - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright (C) 2003-2004 Theodore A. Roth * some code: * Copyright (C) 2011-2012 Roger E. Wolff * diff --git a/src/jtagmkI.h b/src/jtagmkI.h index 5624ad9e..0a7ade1b 100644 --- a/src/jtagmkI.h +++ b/src/jtagmkI.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004 Brian S. Dean + * Copyright (C) 2002-2004 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/jtagmkII.h b/src/jtagmkII.h index 0e407c7c..b4005c9d 100644 --- a/src/jtagmkII.h +++ b/src/jtagmkII.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004, 2006 Brian S. Dean + * Copyright (C) 2002-2004, 2006 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/lexer.l b/src/lexer.l index 679d921a..f0882904 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2006 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify diff --git a/src/linuxspi.h b/src/linuxspi.h index 21c65d46..db289095 100644 --- a/src/linuxspi.h +++ b/src/linuxspi.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2013 Kevin Cuzner + * Copyright (C) 2013 Kevin Cuzner * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/lists.c b/src/lists.c index 21f3e0ef..f44e0947 100644 --- a/src/lists.c +++ b/src/lists.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 1990-2004 Brian S. Dean + * Copyright (C) 1990-2004 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/main.c b/src/main.c index 0742d128..6cc74233 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2005 Brian S. Dean - * Copyright Joerg Wunsch + * Copyright (C) 2000-2005 Brian S. Dean + * Copyright (C) Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/msvc/getopt.c b/src/msvc/getopt.c index acc2ebff..66447867 100644 --- a/src/msvc/getopt.c +++ b/src/msvc/getopt.c @@ -2,7 +2,7 @@ /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ /* - * Copyright (c) 2002 Todd C. Miller + * Copyright (C) 2002 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/src/par.c b/src/par.c index ce702f9f..490068e9 100644 --- a/src/par.c +++ b/src/par.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2006 Brian S. Dean + * Copyright (C) 2000-2006 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/par.h b/src/par.h index 0f8392ee..e50ea60f 100644 --- a/src/par.h +++ b/src/par.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/pgm.c b/src/pgm.c index 8c61bd57..f815406b 100644 --- a/src/pgm.c +++ b/src/pgm.c @@ -1,7 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004 Brian S. Dean - * Copyright 2007 Joerg Wunsch + * Copyright (C) 2002-2004 Brian S. Dean + * Copyright (C) 2007 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/pgm_type.c b/src/pgm_type.c index 56639eb8..e439e856 100644 --- a/src/pgm_type.c +++ b/src/pgm_type.c @@ -1,7 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004 Brian S. Dean - * Copyright 2007 Joerg Wunsch + * Copyright (C) 2002-2004 Brian S. Dean + * Copyright (C) 2007 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/pickit2.c b/src/pickit2.c index 836a11f9..f17d5a09 100644 --- a/src/pickit2.c +++ b/src/pickit2.c @@ -3,7 +3,7 @@ * Copyright (C) 2005 Erik Walthinsen * Copyright (C) 2002-2004 Brian S. Dean * Copyright (C) 2006 David Moore - * Copyright (C) 2006,2007 Joerg Wunsch + * Copyright (C) 2006, 2007 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/pickit2.h b/src/pickit2.h index 4663266f..b56a33ef 100644 --- a/src/pickit2.h +++ b/src/pickit2.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2006 Thomas Fischl + * Copyright (C) 2006 Thomas Fischl * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/pindefs.c b/src/pindefs.c index 6aec71ad..82c0e2b4 100644 --- a/src/pindefs.c +++ b/src/pindefs.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ppi.c b/src/ppi.c index e883553f..ee09a598 100644 --- a/src/ppi.c +++ b/src/ppi.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ppi.h b/src/ppi.h index 6438a0c7..7641dd84 100644 --- a/src/ppi.h +++ b/src/ppi.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ppiwin.c b/src/ppiwin.c index 171e90f3..077bb7fb 100644 --- a/src/ppiwin.c +++ b/src/ppiwin.c @@ -1,8 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003, 2004, 2006 - * Eric B. Weddington - * Copyright 2008, Joerg Wunsch + * Copyright (C) 2003, 2004, 2006 Eric B. Weddington + * Copyright (C) 2008 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ser_avrdoper.c b/src/ser_avrdoper.c index fb9aa001..2a0ebf7d 100644 --- a/src/ser_avrdoper.c +++ b/src/ser_avrdoper.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright (C) 2003-2004 Theodore A. Roth * Copyright (C) 2006 Joerg Wunsch * Copyright (C) 2006 Christian Starkjohann * diff --git a/src/ser_posix.c b/src/ser_posix.c index 60668cc7..8962f1cd 100644 --- a/src/ser_posix.c +++ b/src/ser_posix.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright (C) 2003-2004 Theodore A. Roth * Copyright (C) 2006 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify diff --git a/src/ser_win32.c b/src/ser_win32.c index 95ef8fc4..88441a88 100644 --- a/src/ser_win32.c +++ b/src/ser_win32.c @@ -1,7 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003, 2004 Martin J. Thomas - * Copyright (C) 2006 Joerg Wunsch + * Copyright (C) 2003, 2004 Martin J. Thomas + * Copyright (C) 2006 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/serbb.h b/src/serbb.h index 8e92ebba..11808bff 100644 --- a/src/serbb.h +++ b/src/serbb.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean + * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean * Copyright (C) 2005 Juliane Holzt * * This program is free software; you can redistribute it and/or modify diff --git a/src/serbb_posix.c b/src/serbb_posix.c index b9d2f180..81393dd2 100644 --- a/src/serbb_posix.c +++ b/src/serbb_posix.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean + * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean * Copyright (C) 2005 Juliane Holzt * Copyright (C) 2006 Joerg Wunsch * diff --git a/src/serbb_win32.c b/src/serbb_win32.c index b0b14a35..ec0f7908 100644 --- a/src/serbb_win32.c +++ b/src/serbb_win32.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003, 2004 Martin J. Thomas + * Copyright (C) 2003, 2004 Martin J. Thomas * Copyright (C) 2005 Juliane Holzt * Copyright (C) 2005, 2006 Joerg Wunsch * diff --git a/src/serialupdi.c b/src/serialupdi.c index 1664670c..d9f58eb8 100644 --- a/src/serialupdi.c +++ b/src/serialupdi.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/serialupdi.h b/src/serialupdi.h index 701a915f..990c395e 100644 --- a/src/serialupdi.h +++ b/src/serialupdi.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/stk500.h b/src/stk500.h index 10ff3b39..6c9b8188 100644 --- a/src/stk500.h +++ b/src/stk500.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004 Brian S. Dean + * Copyright (C) 2002-2004 Brian S. Dean * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/stk500v2.c b/src/stk500v2.c index 6c89f18f..70256677 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -3,7 +3,7 @@ * Copyright (C) 2005 Erik Walthinsen * Copyright (C) 2002-2004 Brian S. Dean * Copyright (C) 2006 David Moore - * Copyright (C) 2006,2007,2010 Joerg Wunsch + * Copyright (C) 2006, 2007, 2010 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/stk500v2.h b/src/stk500v2.h index a84d0710..5edcfac2 100644 --- a/src/stk500v2.h +++ b/src/stk500v2.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2005 Brian S. Dean + * Copyright (C) 2002-2005 Brian S. Dean * Copyright (C) 2006 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify diff --git a/src/term.c b/src/term.c index e02bc094..5bce8675 100644 --- a/src/term.c +++ b/src/term.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean + * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2021-2023 Hans Eirik Bull * Copyright (C) 2022-2023 Stefan Rueger * diff --git a/src/tpi.h b/src/tpi.h index 89d438d8..afb26b97 100644 --- a/src/tpi.h +++ b/src/tpi.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2011 Darell Tan + * Copyright (C) 2011 Darell Tan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/update.c b/src/update.c index 4982f825..35aab086 100644 --- a/src/update.c +++ b/src/update.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2005 Brian S. Dean + * Copyright (C) 2000-2005 Brian S. Dean * Copyright (C) 2007 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify diff --git a/src/updi_constants.h b/src/updi_constants.h index c9e8e1a0..93fbc270 100644 --- a/src/updi_constants.h +++ b/src/updi_constants.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_link.c b/src/updi_link.c index 39be1e64..735d0a4e 100644 --- a/src/updi_link.c +++ b/src/updi_link.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_link.h b/src/updi_link.h index 796788ad..fe350674 100644 --- a/src/updi_link.h +++ b/src/updi_link.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm.c b/src/updi_nvm.c index 10fdc792..89bb2fe9 100644 --- a/src/updi_nvm.c +++ b/src/updi_nvm.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm.h b/src/updi_nvm.h index a6439f01..cc5e6e5a 100644 --- a/src/updi_nvm.h +++ b/src/updi_nvm.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v0.c b/src/updi_nvm_v0.c index f8b18629..ece24f67 100644 --- a/src/updi_nvm_v0.c +++ b/src/updi_nvm_v0.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v0.h b/src/updi_nvm_v0.h index 8aed500c..40d9e3f1 100644 --- a/src/updi_nvm_v0.h +++ b/src/updi_nvm_v0.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v2.c b/src/updi_nvm_v2.c index 8599b130..bff8e799 100644 --- a/src/updi_nvm_v2.c +++ b/src/updi_nvm_v2.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v2.h b/src/updi_nvm_v2.h index 89248ba4..21d97d0c 100644 --- a/src/updi_nvm_v2.h +++ b/src/updi_nvm_v2.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v3.c b/src/updi_nvm_v3.c index 0d611c51..51aab6b5 100644 --- a/src/updi_nvm_v3.c +++ b/src/updi_nvm_v3.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v3.h b/src/updi_nvm_v3.h index 49461d2d..b0bd293e 100644 --- a/src/updi_nvm_v3.h +++ b/src/updi_nvm_v3.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v4.c b/src/updi_nvm_v4.c index 76dc9bb8..154edb5a 100644 --- a/src/updi_nvm_v4.c +++ b/src/updi_nvm_v4.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v4.h b/src/updi_nvm_v4.h index 310a59ef..aa8a6135 100644 --- a/src/updi_nvm_v4.h +++ b/src/updi_nvm_v4.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v5.c b/src/updi_nvm_v5.c index ad954904..24002c45 100644 --- a/src/updi_nvm_v5.c +++ b/src/updi_nvm_v5.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_nvm_v5.h b/src/updi_nvm_v5.h index eb7958f9..0cb1259c 100644 --- a/src/updi_nvm_v5.h +++ b/src/updi_nvm_v5.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 Dawid Buchwald + * Copyright (C) 2024 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_readwrite.c b/src/updi_readwrite.c index f242af2a..e2ba1766 100644 --- a/src/updi_readwrite.c +++ b/src/updi_readwrite.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_readwrite.h b/src/updi_readwrite.h index 53e74520..adef2e8a 100644 --- a/src/updi_readwrite.h +++ b/src/updi_readwrite.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_state.c b/src/updi_state.c index 022c8991..5e0a1ae5 100644 --- a/src/updi_state.c +++ b/src/updi_state.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/updi_state.h b/src/updi_state.h index bb8cfcea..4579d8fc 100644 --- a/src/updi_state.h +++ b/src/updi_state.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2021 Dawid Buchwald + * Copyright (C) 2021 Dawid Buchwald * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/usbasp.c b/src/usbasp.c index 3de8ed77..86957420 100644 --- a/src/usbasp.c +++ b/src/usbasp.c @@ -1,7 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2006 Thomas Fischl - * Copyright 2007 Joerg Wunsch + * Copyright (C) 2006 Thomas Fischl + * Copyright (C) 2007 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/usbasp.h b/src/usbasp.h index eacf8005..98d782f1 100644 --- a/src/usbasp.h +++ b/src/usbasp.h @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2006 Thomas Fischl + * Copyright (C) 2006 Thomas Fischl * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/windows.rc.in b/src/windows.rc.in index 33314e75..11e76cca 100644 --- a/src/windows.rc.in +++ b/src/windows.rc.in @@ -1,6 +1,6 @@ // // avrdude - A Downloader / Uploader for AVR device programmers -// Copyright(C) 2021 Marius Greuel +// Copyright (C) 2021 Marius Greuel // // This program is free software; you can redistribute itand /or modify // it under the terms of the GNU General Public License as published by From 21802d7a69a007307252c590e983cb11b4618e72 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 12 Jun 2024 21:31:00 +0100 Subject: [PATCH 133/422] Widen address print size --- src/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index 5bce8675..06e7658d 100644 --- a/src/term.c +++ b/src/term.c @@ -582,7 +582,7 @@ static int cmd_write(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch pmsg_warning("(write) clipping data to fit into %s %s memory\n", p->desc, mem->desc); } - pmsg_notice2("(write) writing %d byte%s starting from address 0x%02x", + pmsg_notice2("(write) writing %d byte%s starting from address 0x%04x", len + bytes_grown, str_plural(len + bytes_grown), addr); if (write_mode == WRITE_MODE_FILL && filling) msg_notice2("; remaining space filled with %s", argv[argc - 2]); From b151bb6b9cc60d015b037b9071e1b4d22b0f5acf Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 12 Jun 2024 22:19:09 +0100 Subject: [PATCH 134/422] Downgrade hex out-of-bounds error to warning on -F --- src/fileio.c | 54 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 08d624c1..fbb1f97d 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -377,28 +377,62 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, imsg_notice("checksum=0x%02x, computed checksum=0x%02x\n", ihex.cksum, rc); } + unsigned below = 0; switch (ihex.rectyp) { case 0: /* data record */ if (fileoffset != 0 && ihex.loadofs + baseaddr < fileoffset) { - pmsg_error("address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n", + if(!ovsigck) { + pmsg_error("address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n", + ihex.loadofs + baseaddr, fileoffset, lineno, infile); + imsg_error("use -F to skip this check\n"); + mmt_free(buffer); + return -1; + } + pmsg_warning("address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n", ihex.loadofs + baseaddr, fileoffset, lineno, infile); - mmt_free(buffer); - return -1; + below = fileoffset - baseaddr - ihex.loadofs; + if(below < ihex.reclen) { // Clip record + ihex.reclen -= below; + ihex.loadofs += below; + } else { // Nothing to write + ihex.reclen = 0; + } + imsg_warning("%s record\n", ihex.reclen? "clipping": "ignoring"); } nextaddr = ihex.loadofs + baseaddr - fileoffset; unsigned int beg = segp->addr, end = segp->addr + segp->len-1; - if(nextaddr < beg || nextaddr + ihex.reclen-1 > end) { - pmsg_error("Intel Hex record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", + if(ihex.reclen && (nextaddr < beg || nextaddr + ihex.reclen-1 > end)) { + if(!ovsigck) { + pmsg_error("Intel Hex record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", + digits, nextaddr, digits, nextaddr+ihex.reclen-1, digits, beg, digits, end); + imsg_error("at line %d of %s; use -F to skip this check\n", lineno, infile); + mmt_free(buffer); + return -1; + } + pmsg_warning("Intel Hex record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", digits, nextaddr, digits, nextaddr+ihex.reclen-1, digits, beg, digits, end); - imsg_error("at line %d of %s\n", lineno, infile); - mmt_free(buffer); - return -1; + if(nextaddr < beg) { + unsigned low = beg - nextaddr; + if(low < ihex.reclen) { // Clip record + ihex.reclen -= low; + ihex.loadofs += low; + nextaddr += low; + below += low; + } else { // Nothing to write + ihex.reclen = 0; + } + } + if(ihex.reclen && nextaddr + ihex.reclen-1 > end) { + int above = nextaddr + ihex.reclen-1 - end; + ihex.reclen = above < ihex.reclen? ihex.reclen - above: 0; // Clip or zap + } + imsg_warning("at line %d of %s; %s record\n", lineno, infile, ihex.reclen? "clipping": "ignoring"); } for(int i=0; ibuf[nextaddr+i] = ihex.data[i]; + mem->buf[nextaddr+i] = ihex.data[below + i]; mem->tags[nextaddr+i] = TAG_ALLOCATED; } - if (nextaddr+ihex.reclen > maxaddr) + if(ihex.reclen && nextaddr+ihex.reclen > maxaddr) maxaddr = nextaddr+ihex.reclen; break; From 5fef24a7bf1fd168cbb7a85973f41efc9748c2c5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 12 Jun 2024 22:21:22 +0100 Subject: [PATCH 135/422] Add debug message after reading hex record\n --- src/fileio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index fbb1f97d..6b4eb336 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -258,7 +258,6 @@ static int ihex_readrec(struct ihexsrec *ihex, char * rec) { int offset, len; char * e; unsigned char cksum; - int rc; len = strlen(rec); offset = 1; @@ -320,9 +319,10 @@ static int ihex_readrec(struct ihexsrec *ihex, char * rec) { if (e == buf || *e != 0) return -1; - rc = -cksum & 0x000000ff; + pmsg_debug("read ihex record type 0x%02x at 0x%04x with %2d bytes and chksum 0x%02x (0x%02x)\n", + ihex->rectyp, ihex->loadofs, ihex->reclen, ihex->cksum, -cksum & 0xff); - return rc; + return -cksum & 0xff; } From 5315c620f69c045db877e4b8fd80225f84df60dc Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 12 Jun 2024 22:33:46 +0100 Subject: [PATCH 136/422] Downgrade S-Record out-of-bounds error to warning on -F --- src/fileio.c | 57 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 6b4eb336..4eab1a55 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -423,7 +423,7 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, } } if(ihex.reclen && nextaddr + ihex.reclen-1 > end) { - int above = nextaddr + ihex.reclen-1 - end; + unsigned above = nextaddr + ihex.reclen-1 - end; ihex.reclen = above < ihex.reclen? ihex.reclen - above: 0; // Clip or zap } imsg_warning("at line %d of %s; %s record\n", lineno, infile, ihex.reclen? "clipping": "ignoring"); @@ -726,26 +726,61 @@ static int srec2b(const char *infile, FILE * inf, if (datarec == 1) { nextaddr = srec.loadofs; + unsigned below = 0; if (nextaddr < fileoffset) { - pmsg_error("address 0x%0*x below memory offset at line %d of %s\n", + if(!ovsigck) { + pmsg_error("address 0x%0*x below memory offset at line %d of %s\n", + hexdigs, nextaddr, lineno, infile); + imsg_error("use -F to skip this check\n"); + mmt_free(buffer); + return -1; + } + pmsg_warning("address 0x%0*x below memory offset at line %d of %s\n", hexdigs, nextaddr, lineno, infile); - mmt_free(buffer); - return -1; + below = fileoffset - nextaddr; + if(below < srec.reclen) { // Clip record + nextaddr += below; + srec.loadofs += below; + srec.reclen -= below; + } else { // Ignore record + srec.reclen = 0; + } + imsg_warning("%s record\n", srec.reclen? "clipping": "ignoring"); } nextaddr -= fileoffset; unsigned int beg = segp->addr, end = segp->addr + segp->len-1; - if(nextaddr < beg || nextaddr + srec.reclen-1 > end) { - pmsg_error("Motorola S-Record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", + if(srec.reclen && (nextaddr < beg || nextaddr + srec.reclen-1 > end)) { + if(!ovsigck) { + pmsg_error("Motorola S-Record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", + digits, nextaddr, digits, nextaddr+srec.reclen-1, digits, beg, digits, end); + imsg_error("at line %d of %s; use -F to skip this check\n", lineno, infile); + mmt_free(buffer); + return -1; + } + pmsg_warning("Motorola S-Record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", digits, nextaddr, digits, nextaddr+srec.reclen-1, digits, beg, digits, end); - imsg_error("at line %d of %s\n", lineno, infile); - mmt_free(buffer); - return -1; + if(nextaddr < beg) { + unsigned low = beg - nextaddr; + if(low < srec.reclen) { // Clip record + srec.reclen -= low; + srec.loadofs += low; + nextaddr += low; + below += low; + } else { // Nothing to write + srec.reclen = 0; + } + } + if(srec.reclen && nextaddr + srec.reclen-1 > end) { + unsigned above = nextaddr + srec.reclen-1 - end; + srec.reclen = above < srec.reclen? srec.reclen - above: 0; // Clip or zap + } + imsg_warning("at line %d of %s; %s record\n", lineno, infile, srec.reclen? "clipping": "ignoring"); } for(int i=0; ibuf[nextaddr+i] = srec.data[i]; + mem->buf[nextaddr+i] = srec.data[below + i]; mem->tags[nextaddr+i] = TAG_ALLOCATED; } - if (nextaddr+srec.reclen > maxaddr) + if(srec.reclen && nextaddr+srec.reclen > maxaddr) maxaddr = nextaddr+srec.reclen; reccount++; } From 2d2da40e5d48bc63d1695bd9e9abb2f5c707fc5f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 12 Jun 2024 22:35:46 +0100 Subject: [PATCH 137/422] Remove unnecessary loadofs changes --- src/fileio.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 4eab1a55..b7df2203 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -415,7 +415,6 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, unsigned low = beg - nextaddr; if(low < ihex.reclen) { // Clip record ihex.reclen -= low; - ihex.loadofs += low; nextaddr += low; below += low; } else { // Nothing to write @@ -740,7 +739,6 @@ static int srec2b(const char *infile, FILE * inf, below = fileoffset - nextaddr; if(below < srec.reclen) { // Clip record nextaddr += below; - srec.loadofs += below; srec.reclen -= below; } else { // Ignore record srec.reclen = 0; @@ -763,7 +761,6 @@ static int srec2b(const char *infile, FILE * inf, unsigned low = beg - nextaddr; if(low < srec.reclen) { // Clip record srec.reclen -= low; - srec.loadofs += low; nextaddr += low; below += low; } else { // Nothing to write From 212b8226575aee48b6a7584ef0336bccb9058a14 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 12 Jun 2024 22:50:57 +0100 Subject: [PATCH 138/422] Remove unnecessary fileoffset comparison --- src/fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fileio.c b/src/fileio.c index b7df2203..2a1a268b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -380,7 +380,7 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, unsigned below = 0; switch (ihex.rectyp) { case 0: /* data record */ - if (fileoffset != 0 && ihex.loadofs + baseaddr < fileoffset) { + if(ihex.loadofs + baseaddr < fileoffset) { if(!ovsigck) { pmsg_error("address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n", ihex.loadofs + baseaddr, fileoffset, lineno, infile); From 98268b07ba566ea392a0a46d8f12073f71157e7a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 12 Jun 2024 23:50:04 +0100 Subject: [PATCH 139/422] Make copyright notice systematic/greppable --- src/stk500.c | 2 +- src/usb_libusb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stk500.c b/src/stk500.c index e580b0cc..fa4dcb38 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -1,7 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2002-2004 Brian S. Dean - * Copyright (C) 2008,2014 Joerg Wunsch + * Copyright (C) 2008, 2014 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/usb_libusb.c b/src/usb_libusb.c index 995437fb..2b11c862 100644 --- a/src/usb_libusb.c +++ b/src/usb_libusb.c @@ -1,6 +1,6 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2005,2006 Joerg Wunsch + * Copyright (C) 2005, 2006 Joerg Wunsch * Copyright (C) 2006 David Moore * * This program is free software; you can redistribute it and/or modify From 3f73f0b88d45aa9f5fa0a82e325b1e6675118033 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 12 Jun 2024 23:50:41 +0100 Subject: [PATCH 140/422] Update AUTHORS list --- AUTHORS | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index bcebd68b..42988f79 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,32 +13,48 @@ AVRDUDE is currently maintained by: Contributors: Joerg Wunsch - Eric Weddington - Jan-Hinnerk Reichert - Alex Shepherd + Eric B. Weddington Martin J. Thomas Theodore A. Roth + Erik Walthinsen + Jan-Hinnerk Reichert + Alex Shepherd Juliane Holzt Colin O'Flynn Thomas Fischl David Hoerl + Christian Starkjohann + David Moore + David Brownell + Dick Streefland + Limor Fried + Klaus Leidinger + Lars Immisch Michal Ludvig + Roger E. Wolff Darell Tan + Brett Hagman Wolfgang Moser Ville Voipio Hannes Weisbach Doug Springer - Brett Hagman Rene Liebscher Jim Paris Jan Egil Ruud David Mosberger + Kirill Levchenko + Kevin Cuzner David Sainty + Alexey Sadkov Marius Greuel + Ralf Ramsauer Dawid Buchwald Hans Eirik Bull Stefan Rueger Xiaofan Chen + Jeff Kent + Sebastian Kuzminsky + Sydney Louisa Wilke Contributors to code no longer present: From aed7c07a6a36517e45619284000294c8276b9dee Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 13 Jun 2024 21:30:57 +0100 Subject: [PATCH 141/422] Extend elf format for bootrow --- src/fileio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fileio.c b/src/fileio.c index 08d624c1..cca2e43e 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -794,6 +794,10 @@ static int elf_mem_limits(const AVRMEM *mem, const AVRPART *p, *lowbound = 0x850000; *highbound = 0x85ffff; *fileoff = 0; + } else if (mem_is_bootrow(mem)) { + *lowbound = 0x860000; + *highbound = 0x86ffff; + *fileoff = 0; } else { rv = -1; } From 9279530ea5a37dcdefebacb6477e22438d4af0f9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 14 Jun 2024 19:16:00 +0100 Subject: [PATCH 142/422] Return -1 on write error --- src/avr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/avr.c b/src/avr.c index 969fdff7..c8b1600a 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1203,8 +1203,9 @@ int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, int if (do_write) { if(avr_write_byte(pgm, p, m, i, data)) { - msg_error(" ***failed;\n"); + msg_error(" *** failed\n"); led_set(pgm, LED_ERR); + goto error; } } @@ -1212,15 +1213,20 @@ int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, int flush_page = 0; if(avr_write_page(pgm, p, m, i)) { - msg_error(" *** page %d (addresses 0x%04x - 0x%04x) failed to write\n\n", + msg_error(" *** failed to write page %d [0x%04x, 0x%04x]\n", i / m->page_size, i - m->page_size + 1, i); led_set(pgm, LED_ERR); + goto error; } } } led_clr(pgm, LED_PGM); return i; + +error: + led_clr(pgm, LED_PGM); + return -1; } From 3bca53f3faf5ac5a5c76635882c6f74bf5e8d596 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 15 Jun 2024 13:07:22 +0100 Subject: [PATCH 143/422] Add Jan Egil Ruud as author to jtag3 sources --- src/jtag3.c | 1 + src/jtag3.h | 1 + src/jtag3_private.h | 1 + 3 files changed, 3 insertions(+) diff --git a/src/jtag3.c b/src/jtag3.c index c18f518e..c5ff43db 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -1,6 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2012 Joerg Wunsch + * Copyright (C) 2017 Jan Egil Ruud * * * This program is free software; you can redistribute it and/or modify diff --git a/src/jtag3.h b/src/jtag3.h index a94649f5..b6773dab 100644 --- a/src/jtag3.h +++ b/src/jtag3.h @@ -1,6 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2012 Joerg Wunsch + * Copyright (C) 2017 Jan Egil Ruud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/jtag3_private.h b/src/jtag3_private.h index bb3bc5a2..a26c5160 100644 --- a/src/jtag3_private.h +++ b/src/jtag3_private.h @@ -1,6 +1,7 @@ /* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2012 Joerg Wunsch + * Copyright (C) 2017 Jan Egil Ruud * * * This program is free software; you can redistribute it and/or modify From 6b9102b8798b3ccc28abc681dbe27e0999d4cf49 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 15 Jun 2024 13:08:48 +0100 Subject: [PATCH 144/422] Fix email address in AUTHORS list --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 42988f79..17c360a1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,7 +13,7 @@ AVRDUDE is currently maintained by: Contributors: Joerg Wunsch - Eric B. Weddington + Eric B. Weddington Martin J. Thomas Theodore A. Roth Erik Walthinsen From 41781bdd3c01ef593d090ad8ee367110e5e2dd63 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 15 Jun 2024 13:17:35 +0100 Subject: [PATCH 145/422] Update NEWS --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 8dedfe92..0433dd0c 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,7 @@ Changes since version 7.3: - Misleading error message: cannot find programmer id #1805 - Custom programmer broken in v7.3 #1807 - ATtiny11 does not have EEPROM #1812 + - AVRDUDE fails to return -1 on some write errors #1821 * Pull requests: @@ -90,6 +91,10 @@ Changes since version 7.3: - Remove EEPROM from ATtiny11 avrdude.conf entry #1814 - Guard serial_number access in usbhid_open() to avoid segfault #1815 - Allow selection of program modes for developer options #1816 + - Return -1 on write error #1822 + - Extend elf format for bootrow #1820 + - Update AUTHORS list #1819 + - Downgrade out-of-range file input errors on -F #1818 * Internals: From dd6fea2e3d6138a333ad647673fc066e14462a0a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 15 Jun 2024 13:37:23 +0100 Subject: [PATCH 146/422] Clarify role of Segorder where variable --- src/fileio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 1f3a0b2f..9754295d 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -150,6 +150,7 @@ FILEFMT fileio_format(char c) { } } +// Tells lower level .hex/.srec routines whether to write intros/outros typedef enum { FIRST_SEG = 1, LAST_SEG = 2, @@ -1610,10 +1611,8 @@ static int fileio_segments_normalise(int oprwv, const char *filename, FILEFMT fo if(fio.op == FIO_READ) // Fill unspecified memory in segment memset(mem->buf+addr, 0xff, len); memset(mem->tags+addr, 0, len); - Segorder where = 0; - if(i == 0) - where |= FIRST_SEG; + Segorder where = i == 0? FIRST_SEG: 0; if(i+1 == n) where |= LAST_SEG; From 61a130dc6451f04f205e6e2be02a6694f1ad13b9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 13:04:25 +0100 Subject: [PATCH 147/422] Extend .hex fileio() to multiple-memory input files --- src/avrpart.c | 16 +++++ src/config_gram.y | 2 + src/fileio.c | 164 ++++++++++++++++++++++++++++++++-------------- src/libavrdude.h | 6 ++ 4 files changed, 139 insertions(+), 49 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index 24a241d5..fea3da60 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -2,6 +2,8 @@ * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2006 Joerg Wunsch + * Copyright (C) 2022- Stefan Rueger + * Copyright (C) 2023- Hans Eirik Bull * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -304,6 +306,20 @@ AVRMEM *avr_new_mem(void) { return m; } +// Create memory from name and size +AVRMEM *avr_new_memory(const char *name, int size) { + AVRMEM *m = (AVRMEM *) mmt_malloc(sizeof(*m)); + m->desc = cache_string(name); + m->page_size = 1; // Ensure not 0 + m->size = size; + m->buf = mmt_malloc(size); + m->tags = mmt_malloc(size); + m->initval = -1; // Unknown value represented as -1 + m->bitmask = -1; // Default to -1 + + return m; +} + AVRMEM_ALIAS *avr_new_memalias(void) { AVRMEM_ALIAS *m = (AVRMEM_ALIAS *) mmt_malloc(sizeof *m); m->desc = cache_string(""); diff --git a/src/config_gram.y b/src/config_gram.y index f6af4744..8b9c2875 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -367,6 +367,8 @@ part_def : m->num_pages = m->size / m->page_size; } + if(fileio_mem_offset(current_part, m) == -1U) + yywarning("revise fileio_mem_offset(), avrdude.conf entry or memory type assignment"); } existing_part = locate_part(part_list, current_part->id); diff --git a/src/fileio.c b/src/fileio.c index 9754295d..2811308e 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -327,31 +327,98 @@ static int ihex_readrec(struct ihexsrec *ihex, char * rec) { } +// Extends where memory is put in flat address space of .elf files +unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { + AVRMEM *base; + + unsigned location = + mem_is_in_flash(mem) && (base = avr_locate_flash(p))? mem->offset - base->offset: + mem_is_io(mem) || mem_is_sram(mem)? MAX_FLASH_SIZE + mem->offset: + mem_is_eeprom(mem)? 0x810000: + mem_is_in_fuses(mem)? 0x820000 + mem_fuse_offset(mem): + mem_is_lock(mem)? 0x830000: + // Classic parts intersperse signature and calibration bytes, this code places them together + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_signature(mem)? 0x840000: + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_calibration(mem)? 0x840003: + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_sigrow(mem)? 0x840010: // Few parts, eg m328pb + // XMEGA parts have signature separate from prodsig, place prodsig at +0x10 as above + (p->prog_modes & PM_PDI) && mem_is_signature(mem)? 0x840000: + (p->prog_modes & PM_PDI) && mem_is_in_sigrow(mem) && (base = avr_locate_sigrow(p))? + 0x840010 + mem->offset - base->offset: + mem_is_in_sigrow(mem) && (base = avr_locate_sigrow(p))? 0x840000 + mem->offset - base->offset: + mem_is_sib(mem)? 0x841000: // Arbitrary 0x1000 offset in signature section for sib + mem_is_userrow(mem)? 0x850000: + mem_is_bootrow(mem)? 0x860000: + -1U; + + if(location == -1U) + pmsg_error("unable to locate %s's %s in multi-memory address space\n", p->desc, mem->desc); + else if(location >= ANY_MEM_SIZE || location + mem->size > ANY_MEM_SIZE) { // Consider overflow + pmsg_error("%s's %s location [0x%06x, 0x%06x] outside flat address space [0, 0x%06x]\n", + p->desc, mem->desc, location, location + mem->size-1, ANY_MEM_SIZE-1); + location = -1U; + } else if(location < MAX_FLASH_SIZE && location + mem->size > MAX_FLASH_SIZE) { + pmsg_error("%s's %s location [0x%06x, 0x%06x] straddles flash section boundary 0x%06x\n", + p->desc, mem->desc, location, location + mem->size-1, MAX_FLASH_SIZE); + location = -1U; + } else if(location >= MAX_FLASH_SIZE && location/0x10000 != (location + mem->size-1)/0x10000) { + pmsg_error("%s's %s memory location [0x%06x, 0x%06x] straddles memory section boundary 0x%02x0000\n", + p->desc, mem->desc, location, location + mem->size-1, 1+location/0x10000); + location = -1U; + } + + return location; +} + +// Extract correct memory from large any memory assuming multi-memory model +static int any2mem(const AVRPART *p, const AVRMEM *mem, const Segment *segp, + const AVRMEM *any, unsigned maxsize) { + + // Compute location for multi-memory file input + unsigned location = maxsize > MAX_FLASH_SIZE? fileio_mem_offset(p, mem): 0; + + if(location == -1U) + return -1; + + unsigned ret = 0; + // Copy over memory to right place and return highest written address plus one + for(unsigned i = segp->addr, end = segp->addr + segp->len; i < end; i++) + if(any->tags[location + i]) { + mem->buf[i] = any->buf[location + i]; + mem->tags[i] = any->tags[location + i]; + ret = i+1; + } + + return ret; +} /* * Intel Hex to binary buffer * - * Given an open file 'inf' which contains Intel Hex formatted data, - * parse the file and lay it out within the memory buffer pointed to - * by mem->buf. The segment within buf, segp, is honoured; if data - * were to fall outside of the memory segment, an error is generated. + * Given an open file 'inf' which contains Intel Hex formatted data, parse + * the file, which potentially contains many AVR memories, and lay it out + * in a temporary AVR "any memory". This also determines whether inf + * contains the AVR memory mem to write to. Only the segment within + * mem->buf, segp, is written to. * - * Return the maximum memory address within mem->buf that was written - * plus one. If an error occurs, return -1. + * Return 0 if nothing was written, otherwise the maximum memory address + * within mem->buf that was written plus one. On error, return -1. */ -static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, +static int ihex2b(const char *infile, FILE *inf, const AVRPART *p, const AVRMEM *mem, const Segment *segp, unsigned int fileoffset, FILEFMT ffmt) { const char *errstr; unsigned int nextaddr, baseaddr, maxaddr; - int lineno, rc, digits; + int lineno, rc; struct ihexsrec ihex; lineno = 0; baseaddr = 0; maxaddr = 0; nextaddr = 0; - digits = mem->size > 0x10000? 5: 4; + rewind(inf); + + AVRMEM *any = avr_new_memory("any", ANY_MEM_SIZE); for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) { lineno++; @@ -364,21 +431,21 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, if(rc < 0) { pmsg_error("invalid record at line %d of %s\n", lineno, infile); mmt_free(buffer); - return -1; + goto error; } if(rc != ihex.cksum) { if(ffmt == FMT_IHEX) { pmsg_error("checksum mismatch at line %d of %s\n", lineno, infile); imsg_error("checksum=0x%02x, computed checksum=0x%02x\n", ihex.cksum, rc); mmt_free(buffer); - return -1; + goto error; } // Just warn with more permissive format FMT_IHXC pmsg_notice("checksum mismatch at line %d of %s\n", lineno, infile); imsg_notice("checksum=0x%02x, computed checksum=0x%02x\n", ihex.cksum, rc); } - unsigned below = 0; + unsigned below = 0, anysize = any->size; switch (ihex.rectyp) { case 0: /* data record */ if(ihex.loadofs + baseaddr < fileoffset) { @@ -387,9 +454,9 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, ihex.loadofs + baseaddr, fileoffset, lineno, infile); imsg_error("use -F to skip this check\n"); mmt_free(buffer); - return -1; + goto error; } - pmsg_warning("address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n", + pmsg_warning("address 0x%04x below fileoffset 0x%x at line %d of %s: ", ihex.loadofs + baseaddr, fileoffset, lineno, infile); below = fileoffset - baseaddr - ihex.loadofs; if(below < ihex.reclen) { // Clip record @@ -398,39 +465,28 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, } else { // Nothing to write ihex.reclen = 0; } - imsg_warning("%s record\n", ihex.reclen? "clipping": "ignoring"); + msg_warning("%s record\n", ihex.reclen? "clipping": "ignoring"); } nextaddr = ihex.loadofs + baseaddr - fileoffset; - unsigned int beg = segp->addr, end = segp->addr + segp->len-1; - if(ihex.reclen && (nextaddr < beg || nextaddr + ihex.reclen-1 > end)) { + if(ihex.reclen && nextaddr + ihex.reclen > anysize) { if(!ovsigck) { - pmsg_error("Intel Hex record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", - digits, nextaddr, digits, nextaddr+ihex.reclen-1, digits, beg, digits, end); + pmsg_error("Intel Hex record [0x%06x, 0x%06x] out of range [0, 0x%06x]\n", + nextaddr, nextaddr+ihex.reclen-1, anysize-1); imsg_error("at line %d of %s; use -F to skip this check\n", lineno, infile); mmt_free(buffer); - return -1; + goto error; } - pmsg_warning("Intel Hex record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", - digits, nextaddr, digits, nextaddr+ihex.reclen-1, digits, beg, digits, end); - if(nextaddr < beg) { - unsigned low = beg - nextaddr; - if(low < ihex.reclen) { // Clip record - ihex.reclen -= low; - nextaddr += low; - below += low; - } else { // Nothing to write - ihex.reclen = 0; - } - } - if(ihex.reclen && nextaddr + ihex.reclen-1 > end) { - unsigned above = nextaddr + ihex.reclen-1 - end; + pmsg_warning("Intel Hex record [0x%06x, 0x%06x] out of range [0, 0x%06x]: ", + nextaddr, nextaddr+ihex.reclen-1, anysize-1); + if(ihex.reclen && nextaddr + ihex.reclen > anysize) { + unsigned above = nextaddr + ihex.reclen - anysize; ihex.reclen = above < ihex.reclen? ihex.reclen - above: 0; // Clip or zap } - imsg_warning("at line %d of %s; %s record\n", lineno, infile, ihex.reclen? "clipping": "ignoring"); + msg_warning("%s it\n", ihex.reclen? "clipping": "ignoring"); } for(int i=0; ibuf[nextaddr+i] = ihex.data[below + i]; - mem->tags[nextaddr+i] = TAG_ALLOCATED; + any->buf[nextaddr+i] = ihex.data[below + i]; + any->tags[nextaddr+i] = TAG_ALLOCATED; } if(ihex.reclen && nextaddr+ihex.reclen > maxaddr) maxaddr = nextaddr+ihex.reclen; @@ -438,7 +494,7 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, case 1: /* end of file record */ mmt_free(buffer); - return maxaddr; + goto done; case 2: /* extended segment address record */ baseaddr = (ihex.data[0] << 8 | ihex.data[1]) << 4; @@ -460,22 +516,32 @@ static int ihex2b(const char *infile, FILE *inf, const AVRMEM *mem, pmsg_error("do not know how to deal with rectype=%d " "at line %d of %s\n", ihex.rectyp, lineno, infile); mmt_free(buffer); - return -1; + goto error; } } if(errstr) { pmsg_error("read error in Intel Hex file %s: %s\n", infile, errstr); - return -1; + goto error; } if (maxaddr == 0) { pmsg_error("no valid record found in Intel Hex file %s\n", infile); - return -1; + goto error; } pmsg_warning("no end of file record found for Intel Hex file %s\n", infile); - return maxaddr; + +done: + rc = any2mem(p, mem, segp, any, maxaddr); + avr_free_mem(any); + if(!rc) + pmsg_warning("no %s data found in Intel Hex file %s\n", mem->desc, infile); + return rc; + +error: + avr_free_mem(any); + return -1; } static unsigned int cksum_srec(const unsigned char *buf, int n, unsigned addr, int addr_width) { @@ -642,7 +708,7 @@ static int srec_readrec(struct ihexsrec *srec, char *rec) { } // Motorola S-Record to binary -static int srec2b(const char *infile, FILE * inf, +static int srec2b(const char *infile, FILE * inf, const AVRPART *p, const AVRMEM *mem, const Segment *segp, unsigned int fileoffset) { const char *errstr; @@ -1150,7 +1216,7 @@ static int fileio_imm(struct fioparms *fio, const char *fname, FILE *f_unused, static int fileio_ihex(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const Segment *segp, FILEFMT ffmt, Segorder where) { + const AVRPART *p, const AVRMEM *mem, const Segment *segp, FILEFMT ffmt, Segorder where) { int rc; @@ -1160,7 +1226,7 @@ static int fileio_ihex(struct fioparms *fio, const char *filename, FILE *f, break; case FIO_READ: - rc = ihex2b(filename, f, mem, segp, fio->fileoffset, ffmt); + rc = ihex2b(filename, f, p, mem, segp, fio->fileoffset, ffmt); break; default: @@ -1173,7 +1239,7 @@ static int fileio_ihex(struct fioparms *fio, const char *filename, FILE *f, static int fileio_srec(struct fioparms *fio, const char *filename, FILE *f, - const AVRMEM *mem, const Segment *segp, Segorder where) { + const AVRPART* p, const AVRMEM *mem, const Segment *segp, Segorder where) { int rc; @@ -1183,7 +1249,7 @@ static int fileio_srec(struct fioparms *fio, const char *filename, FILE *f, break; case FIO_READ: - rc = srec2b(filename, f, mem, segp, fio->fileoffset); + rc = srec2b(filename, f, p, mem, segp, fio->fileoffset); break; default: @@ -1620,11 +1686,11 @@ static int fileio_segments_normalise(int oprwv, const char *filename, FILEFMT fo switch(format) { case FMT_IHEX: case FMT_IHXC: - thisrc = fileio_ihex(&fio, fname, f, mem, seglist+i, format, where); + thisrc = fileio_ihex(&fio, fname, f, p, mem, seglist+i, format, where); break; case FMT_SREC: - thisrc = fileio_srec(&fio, fname, f, mem, seglist+i, where); + thisrc = fileio_srec(&fio, fname, f, p, mem, seglist+i, where); break; case FMT_RBIN: diff --git a/src/libavrdude.h b/src/libavrdude.h index 0fece9dd..7b12031e 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -554,6 +554,7 @@ char *opcode2str(const OPCODE *op, int opnum, int detailed); /* Functions for AVRMEM structures */ AVRMEM * avr_new_mem(void); +AVRMEM *avr_new_memory(const char *name, int size); AVRMEM_ALIAS * avr_new_memalias(void); int avr_initmem(const AVRPART *p); AVRMEM * avr_dup_mem(const AVRMEM *m); @@ -1216,6 +1217,9 @@ enum { FIO_READ_FOR_VERIFY, }; +#define ANY_MEM_SIZE 0x870000 // Max size of multi-memory input file, see fileio_mem_offset() +#define MAX_FLASH_SIZE 0x800000 // rjmp/call can only address 8 MiB in AVR8 architectures + #ifdef __cplusplus extern "C" { #endif @@ -1226,6 +1230,8 @@ char *fileio_fmtstr(FILEFMT format); int fileio_fmtchr(FILEFMT format); +unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem); + FILE *fileio_fopenr(const char *fname); int fileio_fmt_autodetect_fp(FILE *f); From 88a9a269be2b2e5a377f3ecccab82b5e204cb059 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 13:06:49 +0100 Subject: [PATCH 148/422] Define mem_is_prodsig() and mem_is_usersig() --- src/libavrdude.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 7b12031e..7beef42f 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -377,7 +377,8 @@ typedef struct { #define MEM_BOOT (1<< 8) // boot #define MEM_FUSES (1<< 9) // fuses #define MEM_LOCK (1<<10) // lock lockbits -#define MEM_SIGROW (1<<11) // prodsig sigrow +#define MEM_SIGROW (1<<11) // sigrow prodsig +#define MEM_PRODSIG MEM_SIGROW #define MEM_SIGNATURE (1<<12) // signature #define MEM_CALIBRATION (1<<13) // calibration #define MEM_TEMPSENSE (1<<14) // tempsense @@ -388,6 +389,7 @@ typedef struct { #define MEM_OSC20ERR (1<<19) // osc20err #define MEM_BOOTROW (1<<20) // bootrow #define MEM_USERROW (1<<21) // userrow usersig +#define MEM_USERSIG MEM_USERROW #define MEM_IO (1<<22) // io #define MEM_SRAM (1<<23) // sram #define MEM_SIB (1<<24) // sib @@ -408,7 +410,7 @@ typedef struct { #define avr_locate_fuses(p) avr_locate_mem_by_type((p), MEM_FUSES) #define avr_locate_lock(p) avr_locate_mem_by_type((p), MEM_LOCK) #define avr_locate_lockbits(p) avr_locate_mem_by_type((p), MEM_LOCK) -#define avr_locate_prodsig(p) avr_locate_mem_by_type((p), MEM_SIGROW) +#define avr_locate_prodsig(p) avr_locate_mem_by_type((p), MEM_PRODSIG) #define avr_locate_sigrow(p) avr_locate_mem_by_type((p), MEM_SIGROW) #define avr_locate_signature(p) avr_locate_mem_by_type((p), MEM_SIGNATURE) #define avr_locate_calibration(p) avr_locate_mem_by_type((p), MEM_CALIBRATION) @@ -419,7 +421,7 @@ typedef struct { #define avr_locate_osc16err(p) avr_locate_mem_by_type((p), MEM_OSC16ERR) #define avr_locate_osc20err(p) avr_locate_mem_by_type((p), MEM_OSC20ERR) #define avr_locate_bootrow(p) avr_locate_mem_by_type((p), MEM_BOOTROW) -#define avr_locate_usersig(p) avr_locate_mem_by_type((p), MEM_USERROW) +#define avr_locate_usersig(p) avr_locate_mem_by_type((p), MEM_USERSIG) #define avr_locate_userrow(p) avr_locate_mem_by_type((p), MEM_USERROW) #define avr_locate_io(p) avr_locate_mem_by_type((p), MEM_IO) #define avr_locate_sram(p) avr_locate_mem_by_type((p), MEM_SRAM) @@ -458,6 +460,7 @@ typedef struct { #define mem_is_boot(mem) (!!((mem)->type & MEM_BOOT)) #define mem_is_fuses(mem) (!!((mem)->type & MEM_FUSES)) #define mem_is_lock(mem) (!!((mem)->type & MEM_LOCK)) +#define mem_is_prodsig(mem) (!!((mem)->type & MEM_PRODSIG)) #define mem_is_sigrow(mem) (!!((mem)->type & MEM_SIGROW)) #define mem_is_signature(mem) (!!((mem)->type & MEM_SIGNATURE)) #define mem_is_calibration(mem) (!!((mem)->type & MEM_CALIBRATION)) @@ -469,6 +472,7 @@ typedef struct { #define mem_is_osc20err(mem) (!!((mem)->type & MEM_OSC20ERR)) #define mem_is_bootrow(mem) (!!((mem)->type & MEM_BOOTROW)) #define mem_is_userrow(mem) (!!((mem)->type & MEM_USERROW)) +#define mem_is_usersig(mem) (!!((mem)->type & MEM_USERSIG)) #define mem_is_io(mem) (!!((mem)->type & MEM_IO)) #define mem_is_sram(mem) (!!((mem)->type & MEM_SRAM)) #define mem_is_sib(mem) (!!((mem)->type & MEM_SIB)) From 9273bd7bd490855ddac1189dba42d3f56ead39f6 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 13:29:37 +0100 Subject: [PATCH 149/422] Extend .srec fileio() to multiple-memory input files --- src/fileio.c | 82 ++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 2811308e..708ef0f3 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -450,13 +450,13 @@ static int ihex2b(const char *infile, FILE *inf, const AVRPART *p, const AVRMEM case 0: /* data record */ if(ihex.loadofs + baseaddr < fileoffset) { if(!ovsigck) { - pmsg_error("address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n", + pmsg_error("address 0x%06x below memory offset 0x%x at line %d of %s\n", ihex.loadofs + baseaddr, fileoffset, lineno, infile); imsg_error("use -F to skip this check\n"); mmt_free(buffer); goto error; } - pmsg_warning("address 0x%04x below fileoffset 0x%x at line %d of %s: ", + pmsg_warning("address 0x%06x below memory offset 0x%x at line %d of %s: ", ihex.loadofs + baseaddr, fileoffset, lineno, infile); below = fileoffset - baseaddr - ihex.loadofs; if(below < ihex.reclen) { // Clip record @@ -714,14 +714,16 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, const char *errstr; unsigned int nextaddr, maxaddr; struct ihexsrec srec; - int lineno, rc, digits, hexdigs; + int lineno, rc, hexdigs; unsigned int reccount; unsigned char datarec; lineno = 0; maxaddr = 0; reccount = 0; - digits = mem->size > 0x10000? 5: 4; + rewind(inf); + + AVRMEM *any = avr_new_memory("any", ANY_MEM_SIZE); for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) { lineno++; @@ -734,13 +736,13 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, if(rc < 0) { pmsg_error("invalid record at line %d of %s\n", lineno, infile); mmt_free(buffer); - return -1; + goto error; } if(rc != srec.cksum) { pmsg_error("checksum mismatch at line %d of %s\n", lineno, infile); imsg_error("checksum=0x%02x, computed checksum=0x%02x\n", srec.cksum, rc); mmt_free(buffer); - return -1; + goto error; } datarec=0; @@ -766,14 +768,14 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, case '4': // S4: symbol record (LSI extension) pmsg_error("not supported record at line %d of %s\n", lineno, infile); mmt_free(buffer); - return -1; + goto error; case '5': // S5: count of S1, S2 and S3 records previously tx'd if (srec.loadofs != reccount){ pmsg_error("count of transmitted data records mismatch at line %d of %s\n", lineno, infile); imsg_error("transmitted data records= %d, expected value= %d\n", reccount, srec.loadofs); mmt_free(buffer); - return -1; + goto error; } break; @@ -781,28 +783,28 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, case '8': // S8: end record for 24 bit addresses case '9': // S9: end record for 16 bit addresses mmt_free(buffer); - return maxaddr; + goto done; default: pmsg_error("do not know how to deal with rectype S%d at line %d of %s\n", srec.rectyp, lineno, infile); mmt_free(buffer); - return -1; + goto error; } if (datarec == 1) { nextaddr = srec.loadofs; - unsigned below = 0; + unsigned below = 0, anysize = any->size; if (nextaddr < fileoffset) { if(!ovsigck) { - pmsg_error("address 0x%0*x below memory offset at line %d of %s\n", - hexdigs, nextaddr, lineno, infile); + pmsg_error("address 0x%0*x below memory offset 0x%x at line %d of %s\n", + hexdigs, nextaddr, fileoffset, lineno, infile); imsg_error("use -F to skip this check\n"); mmt_free(buffer); - return -1; + goto error; } - pmsg_warning("address 0x%0*x below memory offset at line %d of %s\n", - hexdigs, nextaddr, lineno, infile); + pmsg_warning("address 0x%0*x below memory offset 0x%x at line %d of %s: ", + hexdigs, nextaddr, fileoffset, lineno, infile); below = fileoffset - nextaddr; if(below < srec.reclen) { // Clip record nextaddr += below; @@ -810,39 +812,28 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, } else { // Ignore record srec.reclen = 0; } - imsg_warning("%s record\n", srec.reclen? "clipping": "ignoring"); + msg_warning("%s record\n", srec.reclen? "clipping": "ignoring"); } nextaddr -= fileoffset; - unsigned int beg = segp->addr, end = segp->addr + segp->len-1; - if(srec.reclen && (nextaddr < beg || nextaddr + srec.reclen-1 > end)) { + if(srec.reclen && nextaddr + srec.reclen > anysize) { if(!ovsigck) { - pmsg_error("Motorola S-Record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", - digits, nextaddr, digits, nextaddr+srec.reclen-1, digits, beg, digits, end); + pmsg_error("Motorola S-Record [0x%06x, 0x%06x] out of range [0, 0x%06x]\n", + nextaddr, nextaddr+srec.reclen-1, anysize-1); imsg_error("at line %d of %s; use -F to skip this check\n", lineno, infile); mmt_free(buffer); - return -1; + goto error; } - pmsg_warning("Motorola S-Record [0x%0*x, 0x%0*x] out of range [0x%0*x, 0x%0*x]\n", - digits, nextaddr, digits, nextaddr+srec.reclen-1, digits, beg, digits, end); - if(nextaddr < beg) { - unsigned low = beg - nextaddr; - if(low < srec.reclen) { // Clip record - srec.reclen -= low; - nextaddr += low; - below += low; - } else { // Nothing to write - srec.reclen = 0; - } - } - if(srec.reclen && nextaddr + srec.reclen-1 > end) { - unsigned above = nextaddr + srec.reclen-1 - end; + pmsg_warning("Motorola S-Record [0x%06x, 0x%06x] out of range [0, 0x%06x]: ", + nextaddr, nextaddr+srec.reclen-1, anysize-1); + if(srec.reclen && nextaddr + srec.reclen > anysize) { + unsigned above = nextaddr + srec.reclen - anysize; srec.reclen = above < srec.reclen? srec.reclen - above: 0; // Clip or zap } - imsg_warning("at line %d of %s; %s record\n", lineno, infile, srec.reclen? "clipping": "ignoring"); + msg_warning("%s it\n", srec.reclen? "clipping": "ignoring"); } for(int i=0; ibuf[nextaddr+i] = srec.data[below + i]; - mem->tags[nextaddr+i] = TAG_ALLOCATED; + any->buf[nextaddr+i] = srec.data[below + i]; + any->tags[nextaddr+i] = TAG_ALLOCATED; } if(srec.reclen && nextaddr+srec.reclen > maxaddr) maxaddr = nextaddr+srec.reclen; @@ -852,11 +843,20 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, if(errstr) { pmsg_error("read error in Motorola S-Record file %s: %s\n", infile, errstr); - return -1; + goto error; } pmsg_warning("no end of file record found for Motorola S-Records file %s\n", infile); - return maxaddr; +done: + rc = any2mem(p, mem, segp, any, maxaddr); + avr_free_mem(any); + if(!rc) + pmsg_warning("no %s data found in Motorola S-Record file %s\n", mem->desc, infile); + return rc; + +error: + avr_free_mem(any); + return -1; } From 26d1753c9ec9ae55f1df42121883d11b9c65a2ff Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 15:07:54 +0100 Subject: [PATCH 150/422] Fix memory leak from alias_mem_desc --- src/avrpart.c | 17 +++++++++++++++++ src/libavrdude.h | 1 + src/update.c | 36 +++++++++++++----------------------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index fea3da60..31314422 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -326,6 +326,23 @@ AVRMEM_ALIAS *avr_new_memalias(void) { return m; } +// Return longer name of memory including alias if any, eg, fuse7/codesize +const char *avr_mem_name(const AVRPART *p, const AVRMEM *mem) { + char ret[1024]; + const int n = sizeof ret - 1; + + strncpy(ret, mem->desc, n/2); + ret[n/2] = 0; + + AVRMEM_ALIAS *alias = avr_find_memalias(p, mem); + if(alias && alias->desc && *alias->desc) { + int l = strlen(ret); + ret[l] = '/'; + strncpy(ret+l+1, alias->desc, n-l-1); + ret[n] = 0; + } + return cache_string(ret); +} /* * Allocate and initialize memory buffers for each of the device's diff --git a/src/libavrdude.h b/src/libavrdude.h index 7beef42f..1ecd3db7 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -560,6 +560,7 @@ char *opcode2str(const OPCODE *op, int opnum, int detailed); AVRMEM * avr_new_mem(void); AVRMEM *avr_new_memory(const char *name, int size); AVRMEM_ALIAS * avr_new_memalias(void); +const char *avr_mem_name(const AVRPART *p, const AVRMEM *mem); int avr_initmem(const AVRPART *p); AVRMEM * avr_dup_mem(const AVRMEM *m); void avr_free_mem(AVRMEM * m); diff --git a/src/update.c b/src/update.c index 35aab086..28aee85c 100644 --- a/src/update.c +++ b/src/update.c @@ -385,13 +385,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat return LIBAVRDUDE_SOFTFAIL; } - AVRMEM_ALIAS *alias_mem = avr_find_memalias(p, mem); - char *alias_mem_desc = mmt_malloc(2 + (alias_mem && alias_mem->desc? strlen(alias_mem->desc): 0)); - if(alias_mem && alias_mem->desc && *alias_mem->desc) { - *alias_mem_desc = '/'; - strcpy(alias_mem_desc+1, alias_mem->desc); - } - + const char *mem_desc = avr_mem_name(p, mem); switch (upd->op) { case DEVICE_READ: // Read out the specified device memory and write it to a file @@ -399,7 +393,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat pmsg_error("invalid file format 'immediate' for output\n"); return LIBAVRDUDE_GENERAL_FAILURE; } - pmsg_info("reading %s%s memory ...\n", mem->desc, alias_mem_desc); + pmsg_info("reading %s memory ...\n", mem_desc); if(mem->size > 32 || verbose > 1) report_progress(0, 1, "Reading"); @@ -407,7 +401,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat rc = avr_read(pgm, p, upd->memstr, 0); report_progress(1, 1, NULL); if (rc < 0) { - pmsg_error("unable to read all of %s%s memory, rc=%d\n", mem->desc, alias_mem_desc, rc); + pmsg_error("unable to read all of %s, rc=%d\n", mem_desc, rc); return LIBAVRDUDE_GENERAL_FAILURE; } size = rc; @@ -432,8 +426,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat return LIBAVRDUDE_GENERAL_FAILURE; } - pmsg_info("reading input file %s for %s%s\n", - str_inname(upd->filename), mem->desc, alias_mem_desc); + pmsg_info("reading input file %s for %s\n", str_inname(upd->filename), mem_desc); if(memstats(p, upd->memstr, rc, &fs) < 0) return LIBAVRDUDE_GENERAL_FAILURE; @@ -485,8 +478,8 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat size = rc; // Write the buffer contents to the selected memory - pmsg_info("writing %d byte%s %s%s ...\n", fs.nbytes, - str_plural(fs.nbytes), mem->desc, alias_mem_desc); + pmsg_info("writing %d byte%s %s ...\n", fs.nbytes, + str_plural(fs.nbytes), mem_desc); if (!(flags & UF_NOWRITE)) { if(mem->size > 32 || verbose > 1) @@ -499,12 +492,11 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat } if (rc < 0) { - pmsg_error("unable to write %s%s memory, rc=%d\n", mem->desc, alias_mem_desc, rc); + pmsg_error("unable to write %s, rc=%d\n", mem_desc, rc); return LIBAVRDUDE_GENERAL_FAILURE; } - pmsg_info("%d byte%s of %s%s written\n", fs.nbytes, - str_plural(fs.nbytes), mem->desc, alias_mem_desc); + pmsg_info("%d byte%s of %s written\n", fs.nbytes, str_plural(fs.nbytes), mem_desc); if (!(flags & UF_VERIFY)) // Fall through for auto verify unless break; @@ -516,13 +508,11 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat int userverify = upd->op == DEVICE_VERIFY; // Explicit -U :v by user - pmsg_info("verifying %s%s memory against %s\n", mem->desc, - alias_mem_desc, str_inname(upd->filename)); + pmsg_info("verifying %s against %s\n", mem_desc, str_inname(upd->filename)); // No need to read file when fallen through from DEVICE_WRITE if (userverify) { - pmsg_notice("load %s%s data from input file %s\n", mem->desc, - alias_mem_desc, str_inname(upd->filename)); + pmsg_notice("load %s data from input file %s\n", mem_desc, str_inname(upd->filename)); rc = fileio(FIO_READ_FOR_VERIFY, upd->filename, upd->format, p, upd->memstr, -1); @@ -550,7 +540,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat if (userverify) pmsg_notice("input file %s contains %d byte%s\n", str_inname(upd->filename), fs.nbytes, str_plural(fs.nbytes)); - pmsg_notice2("reading on-chip %s%s data ...\n", mem->desc, alias_mem_desc); + pmsg_notice2("reading on-chip %s data ...\n", mem_desc); } if(mem->size > 32 || verbose > 1) @@ -558,7 +548,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat rc = avr_read(pgm, p, upd->memstr, v); report_progress (1,1,NULL); if (rc < 0) { - pmsg_error("unable to read all of %s%s memory, rc=%d\n", mem->desc, alias_mem_desc, rc); + pmsg_error("unable to read all of %s, rc = %d\n", mem_desc, rc); led_set(pgm, LED_ERR); led_clr(pgm, LED_VFY); avr_free_part(v); @@ -578,7 +568,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat } int verified = fs.nbytes+fs.ntrailing; - pmsg_info("%d byte%s of %s%s verified\n", verified, str_plural(verified), mem->desc, alias_mem_desc); + pmsg_info("%d byte%s of %s verified\n", verified, str_plural(verified), mem_desc); led_clr(pgm, LED_VFY); avr_free_part(v); From 0e61f337395b5941ce901b5f41f5f896472dd30b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 15:38:59 +0100 Subject: [PATCH 151/422] Remove 'in sigrow' attribute from some signature/calibration memories --- src/avr.c | 4 ++-- src/config_gram.y | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/avr.c b/src/avr.c index c8b1600a..10a40981 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1569,8 +1569,8 @@ Memtable avr_mem_order[100] = { {"lockbits", MEM_LOCK}, {"prodsig", MEM_SIGROW | MEM_IN_SIGROW | MEM_READONLY}, {"sigrow", MEM_SIGROW | MEM_IN_SIGROW | MEM_READONLY}, - {"signature", MEM_SIGNATURE | MEM_IN_SIGROW | MEM_READONLY}, - {"calibration", MEM_CALIBRATION | MEM_IN_SIGROW | MEM_READONLY}, + {"signature", MEM_SIGNATURE | MEM_IN_SIGROW | MEM_READONLY}, // Not in SIGROW in Classic/XMEGA parts + {"calibration", MEM_CALIBRATION | MEM_IN_SIGROW | MEM_READONLY}, // Not in SIGROW in Classic parts {"tempsense", MEM_TEMPSENSE | MEM_IN_SIGROW | MEM_READONLY}, {"sernum", MEM_SERNUM | MEM_IN_SIGROW | MEM_READONLY}, {"osccal16", MEM_OSCCAL16 | MEM_IN_SIGROW | MEM_READONLY}, diff --git a/src/config_gram.y b/src/config_gram.y index 8b9c2875..c0b4f26f 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -367,8 +367,19 @@ part_def : m->num_pages = m->size / m->page_size; } + // Remove MEM_IN_SIGROW attribute from classic calibration and classic/XMEGA signature mem + if(!(current_part->prog_modes & (PM_PDI|PM_UPDI))) { + if(mem_is_signature(m)) + m->type &= ~MEM_IN_SIGROW; + if(mem_is_calibration(m)) + m->type &= ~MEM_IN_SIGROW; + } else if(current_part->prog_modes & PM_PDI) { + if(mem_is_signature(m)) + m->type &= ~MEM_IN_SIGROW; + } if(fileio_mem_offset(current_part, m) == -1U) yywarning("revise fileio_mem_offset(), avrdude.conf entry or memory type assignment"); + } existing_part = locate_part(part_list, current_part->id); From c235adf5c901349666137d48f9cca0a1545005ec Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 17:45:33 +0100 Subject: [PATCH 152/422] Remove in-flash/sigrow attr if no respective memories exist --- src/config_gram.y | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/config_gram.y b/src/config_gram.y index c0b4f26f..11e57316 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -339,6 +339,10 @@ part_def : cfg_update_mcuid(current_part); + Memtype and_mask = ~ ( // Remove in-flash/in-sigrow attributes if no respective memories + (!avr_locate_flash(current_part)? MEM_IN_FLASH: 0) | + (!avr_locate_sigrow(current_part)? MEM_IN_SIGROW: 0)); + // Sanity checks for memory sizes and compute/override num_pages entry for (ln=lfirst(current_part->mem); ln; ln=lnext(ln)) { m = ldata(ln); @@ -367,6 +371,8 @@ part_def : m->num_pages = m->size / m->page_size; } + + m->type &= and_mask; // Remove MEM_IN_SIGROW attribute from classic calibration and classic/XMEGA signature mem if(!(current_part->prog_modes & (PM_PDI|PM_UPDI))) { if(mem_is_signature(m)) @@ -379,7 +385,6 @@ part_def : } if(fileio_mem_offset(current_part, m) == -1U) yywarning("revise fileio_mem_offset(), avrdude.conf entry or memory type assignment"); - } existing_part = locate_part(part_list, current_part->id); From dfc22ea966f3b84a000ef2fa3e92fa2da8211727 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 17:53:43 +0100 Subject: [PATCH 153/422] Provide fileio_mem() function --- src/fileio.c | 17 ++++++++++++----- src/libavrdude.h | 5 ++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 708ef0f3..96f5f9c2 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1547,6 +1547,17 @@ int fileio_fmt_autodetect(const char *fname) { +int fileio_mem(int op, const char *filename, FILEFMT format, + const AVRPART *p, const AVRMEM *mem, int size) { + + if(size < 0 || op == FIO_READ || op == FIO_READ_FOR_VERIFY) + size = mem->size; + + const Segment seg = {0, size}; + return fileio_segments(op, filename, format, p, mem, 1, &seg); +} + + int fileio(int op, const char *filename, FILEFMT format, const AVRPART *p, const char *memstr, int size) { @@ -1556,11 +1567,7 @@ int fileio(int op, const char *filename, FILEFMT format, return -1; } - if(size < 0 || op == FIO_READ || op == FIO_READ_FOR_VERIFY) - size = mem->size; - - const Segment seg = {0, size}; - return fileio_segments(op, filename, format, p, mem, 1, &seg); + return fileio_mem(op, filename, format, p, mem, size); } diff --git a/src/libavrdude.h b/src/libavrdude.h index 1ecd3db7..728a3452 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -479,7 +479,7 @@ typedef struct { #define mem_is_in_flash(mem) (!!((mem)->type & MEM_IN_FLASH)) #define mem_is_a_fuse(mem) (!!((mem)->type & MEM_IS_A_FUSE)) -#define mem_is_in_fuses(mem) (!!((mem)->type & (MEM_FUSES | MEM_IS_A_FUSE))) // If fuses exists, that is +#define mem_is_in_fuses(mem) (!!((mem)->type & (MEM_FUSES | MEM_IS_A_FUSE))) // If fuses exists! #define mem_is_user_type(mem) (!!((mem)->type & MEM_USER_TYPE)) #define mem_is_in_sigrow(mem) (!!((mem)->type & MEM_IN_SIGROW)) // If sigrow exists, that is #define mem_is_readonly(mem) (!!((mem)->type & MEM_READONLY)) @@ -1243,6 +1243,9 @@ int fileio_fmt_autodetect_fp(FILE *f); int fileio_fmt_autodetect(const char *fname); +int fileio_mem(int oprwv, const char *filename, FILEFMT format, + const AVRPART *p, const AVRMEM *mem, int size); + int fileio(int oprwv, const char *filename, FILEFMT format, const AVRPART *p, const char *memstr, int size); From d949c06c71909e45ad31748b40a026d0bea07ab4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 18:41:19 +0100 Subject: [PATCH 154/422] Sort fuses by offset in memory list --- src/avr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/avr.c b/src/avr.c index 10a40981..3b6b69ca 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1634,6 +1634,11 @@ int avr_mem_cmp(void *mem1, void *mem2) { return diff; if(!m1) // Sanity, if called with NULL pointers return 0; + if(mem_is_in_fuses(m1)) { // Sort by fuse offset if fuses or a fuse + diff = mem_fuse_offset(m1) - mem_fuse_offset(m2); + if(diff) + return diff; + } diff = m1->offset - m2->offset; // Sort by offset within each group if(diff) return diff; From 693f5e60bda39b1b8fe8d08f0fd679a959666389 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 23:06:12 +0100 Subject: [PATCH 155/422] Provide str_numc(str, c) --- src/libavrdude.h | 1 + src/strutil.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 728a3452..eff89785 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1486,6 +1486,7 @@ const char *str_ccprintf(const char *fmt, ...) ; const char *str_ccstrdup(const char *str); char *str_fgets(FILE *fp, const char **errpp); +size_t str_numc(const char *str, char c); char *str_lc(char *s); char *str_uc(char *s); char *str_lcfirst(char *s); diff --git a/src/strutil.c b/src/strutil.c index 7a8e0085..8c7e42cf 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -77,7 +77,6 @@ int str_caseends(const char *str, const char *ends) { return str_caseeq(str + str_len - ends_len, ends); } - /* * Match string against the partname pattern, returning 1 if it matches, 0 if * not. Note: str_match_core() is a modified old copy of !fnmatch() from the @@ -337,6 +336,17 @@ char *str_fgets(FILE *fp, const char **errpp) { } +// Return the number of times a character c occurs in str +size_t str_numc(const char *str, char c) { + size_t ret = 0; + char is; + + while((is = *str++)) + if(is == c) + ret++; + return ret; +} + // Changes string to be all lowercase and returns original pointer char *str_lc(char *s) { for(char *t = s; *t; t++) From 39ed283a110ab71ea72ce16decfa54897d0d4377 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 16 Jun 2024 23:54:25 +0100 Subject: [PATCH 156/422] Enable writing multi-memory files via -U all:r:... or -U :r:... --- src/avr.c | 1 + src/libavrdude.h | 4 +- src/update.c | 215 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 168 insertions(+), 52 deletions(-) diff --git a/src/avr.c b/src/avr.c index 3b6b69ca..a062cd53 100644 --- a/src/avr.c +++ b/src/avr.c @@ -2,6 +2,7 @@ * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2000-2004 Brian S. Dean * Copyright (C) 2011 Darell Tan + * Copyright (C) 2022- Stefan Rueger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libavrdude.h b/src/libavrdude.h index eff89785..246e0ba5 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1543,8 +1543,8 @@ char *avr_cc_buffer(size_t n); typedef struct { // Closed-circuit space for returning strings in a persistent buffer -#define AVR_SAFETY_MARGIN 128 - char *avr_s, avr_space[8192+AVR_SAFETY_MARGIN]; +#define AVR_SAFETY_MARGIN 1024 + char *avr_s, avr_space[32768+AVR_SAFETY_MARGIN]; // Static variables from avr.c int avr_disableffopt; // Disables trailing 0xff flash optimisation diff --git a/src/update.c b/src/update.c index 28aee85c..95d8cb4e 100644 --- a/src/update.c +++ b/src/update.c @@ -2,6 +2,7 @@ * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2000-2005 Brian S. Dean * Copyright (C) 2007 Joerg Wunsch + * Copyright (C) 2022- Stefan Rueger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -276,14 +278,30 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { } /* - * Reject an update if memory name is not known amongst any part (suspect a typo) - * but accept when the specific part does not have it (allow unifying i/faces) + * Allow memory name to be a list. Reject an update if memory name is not + * known amongst any part (suspect a typo) but accept when the specific part + * does not have it (allow unifying i/faces); also accept pseudo memory all */ - if(!avr_mem_might_be_known(upd->memstr)) { - pmsg_error("unknown memory %s\n", upd->memstr); - ret = LIBAVRDUDE_GENERAL_FAILURE; - } else if(p && !avr_locate_mem(p, upd->memstr)) - ret = LIBAVRDUDE_SOFTFAIL; + char *umstr = upd->memstr, *dstr = mmt_strdup(umstr), *s = dstr, *e; + for(e = strchr(s, ','); 1; e = strchr(s, ',')) { + if(e) { // Terminate and remove trailing space + *e = 0; + for(char *z = e-1; z >= s && isascii(*z & 0xff) && isspace(*z & 0xff); z--) + *z = 0; + } + while(*s && isascii(*s & 0xff) && isspace(*s & 0xff)) // Skip spaces + s++; + if(*s && !avr_mem_might_be_known(s) && !str_eq(s, "all")) { + pmsg_error("unknown memory %s in -U %s:...\n", s, umstr); + ret = LIBAVRDUDE_GENERAL_FAILURE; + break; + } else if(*s && !avr_locate_mem(p, s)) + ret = LIBAVRDUDE_SOFTFAIL; + if(!e) + break; + s = e+1; + } + mmt_free(dstr); known = 0; // Necessary to check whether the file is readable? @@ -358,14 +376,24 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { return ret; } +// Whether a memory should be backup-ed: exclude sub-memories +static int backup_mem(const AVRPART *p, const AVRMEM *mem) { + return mem_is_in_flash(mem)? mem_is_flash(mem): + mem_is_in_sigrow(mem)? mem_is_sigrow(mem): + mem_is_in_fuses(mem)? mem_is_fuses(mem) || !avr_locate_fuses(p): + mem_is_io(mem)? 0: + !mem_is_sram(mem); +} + int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updateflags flags) { + int retval = LIBAVRDUDE_GENERAL_FAILURE; AVRPART *v; - AVRMEM *mem; - int size; - int rc; + AVRMEM *mem, **umemlist = NULL, *m; + Segment *seglist = NULL; Filestats fs, fs_patched; char *tofree; + const char *umstr = upd->memstr; lmsg_info("\n"); // Ensure an empty line for visual separation of operations pmsg_info("processing %s\n", tofree = update_str(upd)); @@ -379,57 +407,136 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat return terminal_mode(pgm, p); } - mem = avr_locate_mem(p, upd->memstr); + int size, len, maxmemstrlen = 0, ns = 0; + // Compute list of multiple memories if umstr indicates so + if(str_eq(umstr, "all") || strchr(umstr, ',')) { + ns = (lsize(p->mem) + 1) * ((int) str_numc(umstr, ',') + 1); // Upper limit of memories + umemlist = mmt_malloc(ns*sizeof*umemlist); + ns = 0; // Now count how many there really are mentioned + + char *dstr = mmt_strdup(umstr), *s = dstr, *e; + for(e = strchr(s, ','); 1; e = strchr(s, ',')) { + if(e) { // Terminate and remove trailing space + *e = 0; + for(char *z = e-1; z >= s && isascii(*z & 0xff) && isspace(*z & 0xff); z--) + *z = 0; + } + while(*s && isascii(*s & 0xff) && isspace(*s & 0xff)) // Skip spaces + s++; + if(str_eq(s, "all")) { + for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) + if(backup_mem(p, (m = ldata(lm)))) + umemlist[ns++] = m; + } else if(!*s) { // Ignore empty list elements + } else { + if(!(m = avr_locate_mem(p, s))) + pmsg_warning("skipping unknown memory %s in list -U %s:...\n", s, umstr); + else + umemlist[ns++] = m; + } + if(!e) + break; + s = e+1; + } + mmt_free(dstr); + + if(!ns) { + pmsg_warning("skipping -U %s:... as no memory in part %s available\n", umstr, p->desc); + mmt_free(umemlist); + return LIBAVRDUDE_SOFTFAIL; + } + // Maximum length of memory name for to-be-read memories + for(int i=0; i maxmemstrlen) + maxmemstrlen = len; + seglist = mmt_malloc(ns*sizeof*seglist); + } + + mem = umemlist? avr_new_memory("multi", ANY_MEM_SIZE): avr_locate_mem(p, umstr); if (mem == NULL) { - pmsg_warning("skipping -U %s:... as memory not defined for part %s\n", upd->memstr, p->desc); + pmsg_warning("skipping -U %s:... as memory not defined for part %s\n", umstr, p->desc); return LIBAVRDUDE_SOFTFAIL; } + int rc = 0; const char *mem_desc = avr_mem_name(p, mem); switch (upd->op) { case DEVICE_READ: // Read out the specified device memory and write it to a file if (upd->format == FMT_IMM) { pmsg_error("invalid file format 'immediate' for output\n"); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } - pmsg_info("reading %s memory ...\n", mem_desc); + if(umemlist) { + pmsg_info("reading %s memor%s ...\n", + ns==1? avr_mem_name(p, umemlist[0]): "multiple", ns==1? "y": "ies"); + int nn = 0; + for(int ii = 0; ii < ns; ii++) { + m = umemlist[ii]; + const char *m_name = avr_mem_name(p, m); + const char *caption = str_ccprintf("Reading %-*s", maxmemstrlen, m_name); + report_progress(0, 1, caption); + int ret = avr_read_mem(pgm, p, m, NULL); + report_progress(1, 1, NULL); + if(ret < 0) { + pmsg_warning("unable to read %s (ret = %d), skipping...\n", m_name, ret); + continue; + } + unsigned off = fileio_mem_offset(p, m); + if(off == -1U) { + pmsg_warning("cannot map %s to flat address space, skipping ...\n", m_name); + continue; + } + if(ret > 0) { + // Copy individual memory into multi memory + memcpy(mem->buf+off, m->buf, ret); + seglist[nn].addr = off; + seglist[nn].len = ret; + nn++; + } + } - if(mem->size > 32 || verbose > 1) - report_progress(0, 1, "Reading"); - - rc = avr_read(pgm, p, upd->memstr, 0); - report_progress(1, 1, NULL); - if (rc < 0) { - pmsg_error("unable to read all of %s, rc=%d\n", mem_desc, rc); - return LIBAVRDUDE_GENERAL_FAILURE; + if(nn) + rc = fileio_segments(FIO_WRITE, upd->filename, upd->format, p, mem, nn, seglist); + else + pmsg_notice("empty memory, resulting file has no contents\n"); + } else { // Regular file + pmsg_info("reading %s memory ...\n", mem_desc); + if(mem->size > 32 || verbose > 1) + report_progress(0, 1, "Reading"); + + rc = avr_read(pgm, p, umstr, 0); + report_progress(1, 1, NULL); + if (rc < 0) { + pmsg_error("unable to read all of %s, rc=%d\n", mem_desc, rc); + goto error; + } + if (rc == 0) + pmsg_notice("empty memory, resulting file has no contents\n"); + pmsg_info("writing output file %s\n", str_outname(upd->filename)); + rc = fileio_mem(FIO_WRITE, upd->filename, upd->format, p, mem, rc); } - size = rc; - if (rc == 0) - pmsg_notice("flash is empty, resulting file has no contents\n"); - pmsg_info("writing output file %s\n", str_outname(upd->filename)); - - rc = fileio(FIO_WRITE, upd->filename, upd->format, p, upd->memstr, size); if (rc < 0) { pmsg_error("write to file %s failed\n", str_outname(upd->filename)); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } + break; case DEVICE_WRITE: // Write the selected device memory using data from a file - rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memstr, -1); + rc = fileio(FIO_READ, upd->filename, upd->format, p, umstr, -1); if (rc < 0) { pmsg_error("read from file %s failed\n", str_inname(upd->filename)); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } pmsg_info("reading input file %s for %s\n", str_inname(upd->filename), mem_desc); - if(memstats(p, upd->memstr, rc, &fs) < 0) - return LIBAVRDUDE_GENERAL_FAILURE; + if(memstats(p, umstr, rc, &fs) < 0) + goto error; imsg_info("with %d byte%s in %d section%s within %s\n", fs.nbytes, str_plural(fs.nbytes), @@ -447,15 +554,15 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat // Patch flash input, eg, for vector bootloaders if(pgm->flash_readhook) { - AVRMEM *mem = avr_locate_mem(p, upd->memstr); + AVRMEM *mem = avr_locate_mem(p, umstr); if(mem && mem_is_flash(mem)) { rc = pgm->flash_readhook(pgm, p, mem, upd->filename, rc); if (rc < 0) { pmsg_notice("readhook for file %s failed\n", str_inname(upd->filename)); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } - if(memstats(p, upd->memstr, rc, &fs_patched) < 0) - return LIBAVRDUDE_GENERAL_FAILURE; + if(memstats(p, umstr, rc, &fs_patched) < 0) + goto error; if(memcmp(&fs_patched, &fs, sizeof fs)) { pmsg_info("preparing flash input for device%s\n", pgm->prog_modes & PM_SPM? " bootloader": ""); @@ -484,16 +591,16 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat if (!(flags & UF_NOWRITE)) { if(mem->size > 32 || verbose > 1) report_progress(0, 1, "Writing"); - rc = avr_write(pgm, p, upd->memstr, size, (flags & UF_AUTO_ERASE) != 0); + rc = avr_write(pgm, p, umstr, size, (flags & UF_AUTO_ERASE) != 0); report_progress(1, 1, NULL); } else { // Test mode: write to stdout in intel hex rather than to the chip - rc = fileio(FIO_WRITE, "-", FMT_IHEX, p, upd->memstr, size); + rc = fileio(FIO_WRITE, "-", FMT_IHEX, p, umstr, size); } if (rc < 0) { pmsg_error("unable to write %s, rc=%d\n", mem_desc, rc); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } pmsg_info("%d byte%s of %s written\n", fs.nbytes, str_plural(fs.nbytes), mem_desc); @@ -514,20 +621,20 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat if (userverify) { pmsg_notice("load %s data from input file %s\n", mem_desc, str_inname(upd->filename)); - rc = fileio(FIO_READ_FOR_VERIFY, upd->filename, upd->format, p, upd->memstr, -1); + rc = fileio(FIO_READ_FOR_VERIFY, upd->filename, upd->format, p, umstr, -1); if (rc < 0) { pmsg_error("read from file %s failed\n", str_inname(upd->filename)); led_set(pgm, LED_ERR); led_clr(pgm, LED_VFY); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } size = rc; - if(memstats(p, upd->memstr, size, &fs) < 0) { + if(memstats(p, umstr, size, &fs) < 0) { led_set(pgm, LED_ERR); led_clr(pgm, LED_VFY); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } } else { // Correct size of last read to include potentially cut off, trailing 0xff (flash) @@ -545,26 +652,26 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat if(mem->size > 32 || verbose > 1) report_progress (0,1,"Reading"); - rc = avr_read(pgm, p, upd->memstr, v); + rc = avr_read(pgm, p, umstr, v); report_progress (1,1,NULL); if (rc < 0) { pmsg_error("unable to read all of %s, rc = %d\n", mem_desc, rc); led_set(pgm, LED_ERR); led_clr(pgm, LED_VFY); avr_free_part(v); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } if (quell_progress < 2) pmsg_notice2("verifying ...\n"); - rc = avr_verify(pgm, p, v, upd->memstr, size); + rc = avr_verify(pgm, p, v, umstr, size); if (rc < 0) { pmsg_error("verification mismatch\n"); led_set(pgm, LED_ERR); led_clr(pgm, LED_VFY); avr_free_part(v); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } int verified = fs.nbytes+fs.ntrailing; @@ -576,8 +683,16 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat default: pmsg_error("invalid update operation (%d) requested\n", upd->op); - return LIBAVRDUDE_GENERAL_FAILURE; + goto error; } - return LIBAVRDUDE_SUCCESS; + retval = LIBAVRDUDE_SUCCESS; + +error: + if(umemlist) { + avr_free_mem(mem); + mmt_free(umemlist); + mmt_free(seglist); + } + return retval; } From 1d2983e46db1af303adcd7a292e50b4ec60d730b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 10:29:49 +0100 Subject: [PATCH 157/422] Provide memstats_mem() --- src/libavrdude.h | 1 + src/update.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 246e0ba5..09231667 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1307,6 +1307,7 @@ char *update_str(const UPDATE *upd); int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updateflags flags); int memstats(const AVRPART *p, const char *memstr, int size, Filestats *fsp); +int memstats_mem(const AVRPART *p, const AVRMEM *mem, int size, Filestats *fsp); // Helper functions for dry run to determine file access int update_is_okfile(const char *fn); diff --git a/src/update.c b/src/update.c index 95d8cb4e..73ea58c4 100644 --- a/src/update.c +++ b/src/update.c @@ -146,7 +146,6 @@ char *update_str(const UPDATE *upd) { // Memory statistics considering holes after a file read returned size bytes int memstats(const AVRPART *p, const char *memstr, int size, Filestats *fsp) { - Filestats ret = { 0 }; AVRMEM *mem = avr_locate_mem(p, memstr); if(!mem) { @@ -154,8 +153,15 @@ int memstats(const AVRPART *p, const char *memstr, int size, Filestats *fsp) { return LIBAVRDUDE_GENERAL_FAILURE; } + return memstats_mem(p, mem, size, fsp); +} + +// Memory statistics considering holes after a file read returned size bytes +int memstats_mem(const AVRPART *p, const AVRMEM *mem, int size, Filestats *fsp) { + Filestats ret = { 0 }; + if(!mem->buf || !mem->tags) { - pmsg_error("%s %s is not set\n", p->desc, memstr); + pmsg_error("%s %s is not set\n", p->desc, mem->desc); return LIBAVRDUDE_GENERAL_FAILURE; } @@ -164,7 +170,7 @@ int memstats(const AVRPART *p, const char *memstr, int size, Filestats *fsp) { pgsize = 1; if(size < 0 || size > mem->size) { - pmsg_error("size %d at odds with %s %s size %d\n", size, p->desc, memstr, mem->size); + pmsg_error("size %d at odds with %s %s size %d\n", size, p->desc, mem->desc, mem->size); return LIBAVRDUDE_GENERAL_FAILURE; } From 9f8eeaa76df983c5cb0163fa7476bc56898fa60e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 10:53:57 +0100 Subject: [PATCH 158/422] Provide string trim functions --- src/libavrdude.h | 5 +++++ src/strutil.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index 09231667..816ef244 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1488,6 +1488,11 @@ const char *str_ccprintf(const char *fmt, ...) const char *str_ccstrdup(const char *str); char *str_fgets(FILE *fp, const char **errpp); size_t str_numc(const char *str, char c); +const char *str_ltrim(const char *s); +char *str_nrtrim(char *s, size_t n); +char *str_rtrim(char *s); +char *str_ntrim(char *s, size_t n); +char *str_trim(char *s); char *str_lc(char *s); char *str_uc(char *s); char *str_lcfirst(char *s); diff --git a/src/strutil.c b/src/strutil.c index 8c7e42cf..a5906ad0 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -347,6 +347,37 @@ size_t str_numc(const char *str, char c) { return ret; } +// Return a pointer to the first non-white-space character in a string (or the end) +const char *str_ltrim(const char *s) { + while(*s && isascii(*s & 0xff) && isspace(*s & 0xff)) + s++; + return s; +} + +// Terminate at position n and remove white space before that +char *str_nrtrim(char *s, size_t n) { + s[n] = 0; + if(n) + for(char *z = s+n-1; z >= s && isascii(*z & 0xff) && isspace(*z & 0xff); z--) + *z = 0; + return s; +} + +// Remove trailing white space +char *str_rtrim(char *s) { + return str_nrtrim(s, strlen(s)); +} + +// Terminate at position n and remove leading and trailing white space +char *str_ntrim(char *s, size_t n) { + return (char *) str_ltrim(str_nrtrim(s, n)); +} + +// Remove leading and trailing white space +char *str_trim(char *s) { + return (char *) str_ltrim(str_nrtrim(s, strlen(s))); +} + // Changes string to be all lowercase and returns original pointer char *str_lc(char *s) { for(char *t = s; *t; t++) From 0be19da627f20a461b29f462f2e80693a58dcc97 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 11:08:56 +0100 Subject: [PATCH 159/422] Simplify code using string trim functions --- src/update.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/update.c b/src/update.c index 73ea58c4..a7684880 100644 --- a/src/update.c +++ b/src/update.c @@ -290,13 +290,9 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { */ char *umstr = upd->memstr, *dstr = mmt_strdup(umstr), *s = dstr, *e; for(e = strchr(s, ','); 1; e = strchr(s, ',')) { - if(e) { // Terminate and remove trailing space + if(e) *e = 0; - for(char *z = e-1; z >= s && isascii(*z & 0xff) && isspace(*z & 0xff); z--) - *z = 0; - } - while(*s && isascii(*s & 0xff) && isspace(*s & 0xff)) // Skip spaces - s++; + s = str_trim(s); if(*s && !avr_mem_might_be_known(s) && !str_eq(s, "all")) { pmsg_error("unknown memory %s in -U %s:...\n", s, umstr); ret = LIBAVRDUDE_GENERAL_FAILURE; @@ -422,13 +418,9 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat char *dstr = mmt_strdup(umstr), *s = dstr, *e; for(e = strchr(s, ','); 1; e = strchr(s, ',')) { - if(e) { // Terminate and remove trailing space + if(e) *e = 0; - for(char *z = e-1; z >= s && isascii(*z & 0xff) && isspace(*z & 0xff); z--) - *z = 0; - } - while(*s && isascii(*s & 0xff) && isspace(*s & 0xff)) // Skip spaces - s++; + s = str_trim(s); if(str_eq(s, "all")) { for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) if(backup_mem(p, (m = ldata(lm)))) From 9ab4aac0455c1884fe70e2bdeb8366ccf642c7a9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 12:41:02 +0100 Subject: [PATCH 160/422] Switch off trailing 0xff optimisation when writing memory lists to file It is crucial not to skip empty flash memory: otherwise the output file cannot distinguish between flash having been deliberately dropped by the user or it having been empty. --- src/update.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/update.c b/src/update.c index a7684880..18c58fe2 100644 --- a/src/update.c +++ b/src/update.c @@ -379,7 +379,7 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { } // Whether a memory should be backup-ed: exclude sub-memories -static int backup_mem(const AVRPART *p, const AVRMEM *mem) { +static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { return mem_is_in_flash(mem)? mem_is_flash(mem): mem_is_in_sigrow(mem)? mem_is_sigrow(mem): mem_is_in_fuses(mem)? mem_is_fuses(mem) || !avr_locate_fuses(p): @@ -423,7 +423,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat s = str_trim(s); if(str_eq(s, "all")) { for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) - if(backup_mem(p, (m = ldata(lm)))) + if(is_backup_mem(p, (m = ldata(lm)))) umemlist[ns++] = m; } else if(!*s) { // Ignore empty list elements } else { @@ -466,6 +466,21 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat goto error; } if(umemlist) { + /* + * Writing to all memories or a list of memories. It is crucial not to + * skip empty flash memory: otherwise the output file cannot distinguish + * between flash having been deliberately dropped by the user or it + * having been empty. Therefore the code switches temporarily off + * trailing 0xff optimisation. In theory, the output file could only + * store those pages that are non-empty for a paged memory, and if it was + * all empty, store only the first empty page to indicate the memory was + * selected. However, file space on a PC is cheap and fast; the main use + * case for saving "all" memory is a backup, and AVRDUDE does not want to + * rely on the uploader to know that the backup file requires the paged + * memories to be erased first, so the code goes the full hog. + */ + int dffo = cx->avr_disableffopt; + cx->avr_disableffopt = 1; pmsg_info("reading %s memor%s ...\n", ns==1? avr_mem_name(p, umemlist[0]): "multiple", ns==1? "y": "ies"); int nn = 0; @@ -498,6 +513,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat rc = fileio_segments(FIO_WRITE, upd->filename, upd->format, p, mem, nn, seglist); else pmsg_notice("empty memory, resulting file has no contents\n"); + cx->avr_disableffopt = dffo; } else { // Regular file pmsg_info("reading %s memory ...\n", mem_desc); if(mem->size > 32 || verbose > 1) From bc5db547d9cbc3bae45d51d2e5723c3da6f53e38 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 14:44:42 +0100 Subject: [PATCH 161/422] De-duplicate memory list, keeping order --- src/update.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/update.c b/src/update.c index 18c58fe2..60aba7c7 100644 --- a/src/update.c +++ b/src/update.c @@ -437,6 +437,14 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat s = e+1; } mmt_free(dstr); + // De-duplicate list, keeping order + for(int i=0; i < ns; i++) { + m = umemlist[i]; + // Move down remaining list whenever same memory detected + for(int j = i+1; j < ns; j++) + for(; j < ns && m == umemlist[j]; ns--) + memmove(umemlist+j, umemlist+j+1, (ns-j-1)*sizeof*umemlist); + } if(!ns) { pmsg_warning("skipping -U %s:... as no memory in part %s available\n", umstr, p->desc); From 1cc25f3284a3fb7a1d58ad5e62f0bf64d6f6d329 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 15:03:08 +0100 Subject: [PATCH 162/422] Unify memory description for memory list --- src/update.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/update.c b/src/update.c index 60aba7c7..5a561927 100644 --- a/src/update.c +++ b/src/update.c @@ -464,8 +464,9 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat return LIBAVRDUDE_SOFTFAIL; } + const char *mem_desc = !umemlist? avr_mem_name(p, mem): + ns==1? avr_mem_name(p, umemlist[0]): "multiple memories"; int rc = 0; - const char *mem_desc = avr_mem_name(p, mem); switch (upd->op) { case DEVICE_READ: // Read out the specified device memory and write it to a file @@ -489,8 +490,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat */ int dffo = cx->avr_disableffopt; cx->avr_disableffopt = 1; - pmsg_info("reading %s memor%s ...\n", - ns==1? avr_mem_name(p, umemlist[0]): "multiple", ns==1? "y": "ies"); + pmsg_info("reading %s ...\n", mem_desc); int nn = 0; for(int ii = 0; ii < ns; ii++) { m = umemlist[ii]; @@ -547,17 +547,15 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat break; case DEVICE_WRITE: - // Write the selected device memory using data from a file + // Write the selected device memory/ies using data from a file - rc = fileio(FIO_READ, upd->filename, upd->format, p, umstr, -1); + pmsg_info("reading input file %s for %s\n", str_inname(upd->filename), mem_desc); + rc = fileio_mem(FIO_READ, upd->filename, upd->format, p, mem, -1); if (rc < 0) { pmsg_error("read from file %s failed\n", str_inname(upd->filename)); goto error; } - - pmsg_info("reading input file %s for %s\n", str_inname(upd->filename), mem_desc); - - if(memstats(p, umstr, rc, &fs) < 0) + if(memstats_mem(p, mem, rc, &fs) < 0) goto error; imsg_info("with %d byte%s in %d section%s within %s\n", @@ -574,6 +572,8 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat msg_info("\n"); } + + // Patch flash input, eg, for vector bootloaders if(pgm->flash_readhook) { AVRMEM *mem = avr_locate_mem(p, umstr); @@ -607,7 +607,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat size = rc; // Write the buffer contents to the selected memory - pmsg_info("writing %d byte%s %s ...\n", fs.nbytes, + pmsg_info("writing %d byte%s to %s ...\n", fs.nbytes, str_plural(fs.nbytes), mem_desc); if (!(flags & UF_NOWRITE)) { From bdde862bae656f0200e256cf1db02b1d6c92e934 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 17:00:35 +0100 Subject: [PATCH 163/422] Prepare update.c for multiple memory write --- src/update.c | 145 +++++++++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 67 deletions(-) diff --git a/src/update.c b/src/update.c index 5a561927..9fa4c1ff 100644 --- a/src/update.c +++ b/src/update.c @@ -388,12 +388,86 @@ static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { } +static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, + const UPDATE *upd, enum updateflags flags, int size, const char *caption) { + + int rc = 0; + Filestats fs, fs_patched; + + if(memstats_mem(p, mem, size, &fs) < 0) + return -1; + imsg_info("read %d byte%s in %d section%s within %s\n", + fs.nbytes, str_plural(fs.nbytes), + fs.nsections, str_plural(fs.nsections), + str_ccinterval(fs.firstaddr, fs.lastaddr)); + if(mem->page_size > 1) { + imsg_info("using %d page%s and %d pad byte%s", + fs.npages, str_plural(fs.npages), + fs.nfill, str_plural(fs.nfill)); + if(fs.ntrailing) + msg_info(", cutting off %d trailing 0xff byte%s", + fs.ntrailing, str_plural(fs.ntrailing)); + msg_info("\n"); + } + + // Patch flash input, eg, for vector bootloaders + if(pgm->flash_readhook && mem_is_flash(mem)) { + if((size = pgm->flash_readhook(pgm, p, mem, upd->filename, size)) < 0) { + pmsg_notice("readhook for file %s failed\n", str_inname(upd->filename)); + return -1; + } + if(memstats_mem(p, mem, size, &fs_patched) < 0) + return -1; + if(memcmp(&fs_patched, &fs, sizeof fs)) { + pmsg_info("preparing flash input for device%s\n", + pgm->prog_modes & PM_SPM? " bootloader": ""); + imsg_notice2("with %d byte%s in %d section%s within %s\n", + fs_patched.nbytes, str_plural(fs_patched.nbytes), + fs_patched.nsections, str_plural(fs_patched.nsections), + str_ccinterval(fs_patched.firstaddr, fs_patched.lastaddr)); + if(mem->page_size > 1) { + imsg_notice2("using %d page%s and %d pad byte%s", + fs_patched.npages, str_plural(fs_patched.npages), + fs_patched.nfill, str_plural(fs_patched.nfill)); + if(fs_patched.ntrailing) + msg_notice2(", and %d trailing 0xff byte%s", + fs_patched.ntrailing, str_plural(fs_patched.ntrailing)); + msg_notice2("\n"); + } + memcpy(&fs, &fs_patched, sizeof fs); + } + } + + // Write the buffer contents to the selected memory + pmsg_info("writing %d byte%s to %s ...\n", fs.nbytes, + str_plural(fs.nbytes), mem->desc); + + if(!(flags & UF_NOWRITE)) { + if(mem->size > 32 || verbose > 1) + report_progress(0, 1, "Writing"); + rc = avr_write_mem(pgm, p, mem, size, (flags & UF_AUTO_ERASE) != 0); + report_progress(1, 1, NULL); + } else { + // Test mode: write to stdout in intel hex rather than to the chip + rc = fileio_mem(FIO_WRITE, "-", FMT_IHEX, p, mem, size); + } + + if (rc < 0) { + pmsg_error("unable to write %s, rc=%d\n", mem->desc, rc); + return -1; + } + + pmsg_info("%d byte%s of %s written\n", fs.nbytes, str_plural(fs.nbytes), mem->desc); + + return rc; +} + int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updateflags flags) { int retval = LIBAVRDUDE_GENERAL_FAILURE; AVRPART *v; AVRMEM *mem, **umemlist = NULL, *m; Segment *seglist = NULL; - Filestats fs, fs_patched; + Filestats fs; char *tofree; const char *umstr = upd->memstr; @@ -558,75 +632,12 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat if(memstats_mem(p, mem, rc, &fs) < 0) goto error; - imsg_info("with %d byte%s in %d section%s within %s\n", - fs.nbytes, str_plural(fs.nbytes), - fs.nsections, str_plural(fs.nsections), - str_ccinterval(fs.firstaddr, fs.lastaddr)); - if(mem->page_size > 1) { - imsg_info("using %d page%s and %d pad byte%s", - fs.npages, str_plural(fs.npages), - fs.nfill, str_plural(fs.nfill)); - if(fs.ntrailing) - msg_info(", cutting off %d trailing 0xff byte%s", - fs.ntrailing, str_plural(fs.ntrailing)); - msg_info("\n"); - } - - - - // Patch flash input, eg, for vector bootloaders - if(pgm->flash_readhook) { - AVRMEM *mem = avr_locate_mem(p, umstr); - if(mem && mem_is_flash(mem)) { - rc = pgm->flash_readhook(pgm, p, mem, upd->filename, rc); - if (rc < 0) { - pmsg_notice("readhook for file %s failed\n", str_inname(upd->filename)); - goto error; - } - if(memstats(p, umstr, rc, &fs_patched) < 0) - goto error; - if(memcmp(&fs_patched, &fs, sizeof fs)) { - pmsg_info("preparing flash input for device%s\n", - pgm->prog_modes & PM_SPM? " bootloader": ""); - imsg_notice2("with %d byte%s in %d section%s within %s\n", - fs_patched.nbytes, str_plural(fs_patched.nbytes), - fs_patched.nsections, str_plural(fs_patched.nsections), - str_ccinterval(fs_patched.firstaddr, fs_patched.lastaddr)); - if(mem->page_size > 1) { - imsg_notice2("using %d page%s and %d pad byte%s", - fs_patched.npages, str_plural(fs_patched.npages), - fs_patched.nfill, str_plural(fs_patched.nfill)); - if(fs_patched.ntrailing) - msg_notice2(", and %d trailing 0xff byte%s", - fs_patched.ntrailing, str_plural(fs_patched.ntrailing)); - msg_notice2("\n"); - } - } - } - } - size = rc; - - // Write the buffer contents to the selected memory - pmsg_info("writing %d byte%s to %s ...\n", fs.nbytes, - str_plural(fs.nbytes), mem_desc); - - if (!(flags & UF_NOWRITE)) { - if(mem->size > 32 || verbose > 1) - report_progress(0, 1, "Writing"); - rc = avr_write(pgm, p, umstr, size, (flags & UF_AUTO_ERASE) != 0); - report_progress(1, 1, NULL); + if(umemlist) { + break; } else { - // Test mode: write to stdout in intel hex rather than to the chip - rc = fileio(FIO_WRITE, "-", FMT_IHEX, p, umstr, size); + update_avr_write(pgm, p, mem, upd, flags, rc, "Writing"); } - if (rc < 0) { - pmsg_error("unable to write %s, rc=%d\n", mem_desc, rc); - goto error; - } - - pmsg_info("%d byte%s of %s written\n", fs.nbytes, str_plural(fs.nbytes), mem_desc); - if (!(flags & UF_VERIFY)) // Fall through for auto verify unless break; // Fall through From a3347d7b0d216f38b9f10b9eba2f91d477b3a3bf Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 17:18:15 +0100 Subject: [PATCH 164/422] Enable writing input to multiple memories via -U [|all]:w:... --- src/fileio.c | 4 +++- src/update.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 96f5f9c2..35bea6a4 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -331,6 +331,9 @@ static int ihex_readrec(struct ihexsrec *ihex, char * rec) { unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { AVRMEM *base; + if(mem->type == 0 && mem->size == ANY_MEM_SIZE) + return 0; + unsigned location = mem_is_in_flash(mem) && (base = avr_locate_flash(p))? mem->offset - base->offset: mem_is_io(mem) || mem_is_sram(mem)? MAX_FLASH_SIZE + mem->offset: @@ -1546,7 +1549,6 @@ int fileio_fmt_autodetect(const char *fname) { } - int fileio_mem(int op, const char *filename, FILEFMT format, const AVRPART *p, const AVRMEM *mem, int size) { diff --git a/src/update.c b/src/update.c index 9fa4c1ff..a596d98d 100644 --- a/src/update.c +++ b/src/update.c @@ -396,8 +396,8 @@ static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRME if(memstats_mem(p, mem, size, &fs) < 0) return -1; - imsg_info("read %d byte%s in %d section%s within %s\n", - fs.nbytes, str_plural(fs.nbytes), + imsg_info("read %d byte%s for %s in %d section%s within %s\n", + fs.nbytes, str_plural(fs.nbytes), avr_mem_name(p, mem), fs.nsections, str_plural(fs.nsections), str_ccinterval(fs.firstaddr, fs.lastaddr)); if(mem->page_size > 1) { @@ -633,6 +633,37 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat goto error; if(umemlist) { + int allsize = rc; + for(int i=0; isize; + if(allsize - off < size) + size = allsize - off; + memcpy(m->buf, mem->buf+off, size); + memcpy(m->tags, mem->tags+off, size); + + int ret = update_avr_write(pgm, p, m, upd, flags, size, caption); + if(ret < 0) { + pmsg_warning("unable to write %s (ret = %d), skipping...\n", m_name, ret); + continue; + } + } break; } else { update_avr_write(pgm, p, mem, upd, flags, rc, "Writing"); From 3b728a344984bfe842ca9327f12ea4b1f8562228 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 17 Jun 2024 20:05:04 +0100 Subject: [PATCH 165/422] Provide avr_verify_mem() --- src/avr.c | 57 ++++++++++++++++++------------------------------ src/libavrdude.h | 7 +++--- 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/avr.c b/src/avr.c index a062cd53..8419391f 100644 --- a/src/avr.c +++ b/src/avr.c @@ -323,10 +323,9 @@ int avr_mem_hiaddr(const AVRMEM * mem) /* - * Read the entirety of the specified memory into the corresponding - * buffer of the avrpart pointed to by p. If v is non-NULL, verify against - * v's memory area, only those cells that are tagged TAG_ALLOCATED are - * verified. + * Read the entirety of the specified memory into the corresponding buffer of + * the avrpart pointed to by p. If v is non-NULL, verify against v's memory + * area, only those cells that are tagged TAG_ALLOCATED are verified. * * Return the number of bytes read, or < 0 if an error occurs. */ @@ -340,14 +339,6 @@ int avr_read(const PROGRAMMER *pgm, const AVRPART *p, const char *memstr, const return avr_read_mem(pgm, p, mem, v); } - -/* - * Read the entirety of the specified memory into the corresponding buffer of - * the avrpart pointed to by p. If v is non-NULL, verify against v's memory - * area, only those cells that are tagged TAG_ALLOCATED are verified. - * - * Return the number of bytes read, or < 0 if an error occurs. - */ int avr_read_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, const AVRPART *v) { unsigned long i, lastaddr; unsigned char cmd[4]; @@ -934,14 +925,6 @@ int avr_write(const PROGRAMMER *pgm, const AVRPART *p, const char *memstr, int s return avr_write_mem(pgm, p, m, size, auto_erase); } -/* - * Write the whole memory region of the specified memory from its buffer of - * the avrpart pointed to by p to the device. Write up to size bytes from - * the buffer. Data is only written if the corresponding tags byte is set. - * Data beyond size bytes are not affected. - * - * Return the number of bytes written, or LIBAVRDUDE_GENERAL_FAILURE on error. - */ int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, int size, int auto_erase) { int wsize; unsigned int i, lastaddr; @@ -1272,7 +1255,7 @@ int avr_mem_bitmask(const AVRPART *p, const AVRMEM *mem, int addr) { } // Bitmask for ISP programming (classic parts only) -static uint8_t get_fuse_bitmask(AVRMEM * m) { +static uint8_t get_fuse_bitmask(const AVRMEM *m) { uint8_t bitmask_r = 0; uint8_t bitmask_w = 0; int i; @@ -1304,27 +1287,29 @@ int compare_memory_masked(AVRMEM * m, uint8_t b1, uint8_t b2) { } /* - * Verify the memory buffer of p with that of v. The byte range of v - * may be a subset of p. The byte range of p should cover the whole - * chip's memory size. + * Verify the memory buffer of p with that of v. The byte range of v may be a + * subset of p. The byte range of p should cover the whole chip's memory size. * * Return the number of bytes verified, or -1 if they don't match. */ int avr_verify(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, const char *memstr, int size) { - int i; - unsigned char * buf1, * buf2; - int vsize; - AVRMEM * a, * b; + const AVRMEM *a = avr_locate_mem(p, memstr); - a = avr_locate_mem(p, memstr); - if (a == NULL) { + if(!a) { pmsg_error("memory %s not defined for part %s\n", memstr, p->desc); return -1; } + return avr_verify_mem(pgm, p, v, a, size); +} - b = avr_locate_mem(v, memstr); - if (b == NULL) { - pmsg_error("memory %s not defined for part %s\n", memstr, v->desc); +int avr_verify_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, const AVRMEM *a, int size) { + int i; + unsigned char *buf1, *buf2; + int vsize; + AVRMEM *b; + + if(!(b = avr_locate_mem(v, a->desc))) { + pmsg_error("memory %s not defined for part %s\n", a->desc, v->desc); return -1; } @@ -1334,7 +1319,7 @@ int avr_verify(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, const if (vsize < size) { pmsg_warning("requested verification for %d bytes\n", size); - imsg_warning("%s memory region only contains %d bytes\n", memstr, vsize); + imsg_warning("%s memory region only contains %d bytes\n", a->desc, vsize); imsg_warning("only %d bytes will be verified\n", vsize); size = vsize; } @@ -1371,12 +1356,12 @@ int avr_verify(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, const // Mismatch is only in unused bits if ((buf1[i] | bitmask) != 0xff) { // Programmer returned unused bits as 0, must be the part/programmer - pmsg_warning("ignoring mismatch in unused bits of %s\n", memstr); + pmsg_warning("ignoring mismatch in unused bits of %s\n", a->desc); imsg_warning("(device 0x%02x != input 0x%02x); to prevent this warning fix\n", buf1[i], buf2[i]); imsg_warning("the part or programmer definition in the config file\n"); } else { // Programmer returned unused bits as 1, must be the user - pmsg_warning("ignoring mismatch in unused bits of %s\n", memstr); + pmsg_warning("ignoring mismatch in unused bits of %s\n", a->desc); imsg_warning("(device 0x%02x != input 0x%02x); to prevent this warning set\n", buf1[i], buf2[i]); imsg_warning("unused bits to 1 when writing (double check with datasheet)\n"); } diff --git a/src/libavrdude.h b/src/libavrdude.h index 816ef244..5b442212 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1102,9 +1102,8 @@ int avr_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p, unsigned cha int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char * value); -int avr_read_mem(const PROGRAMMER * pgm, const AVRPART *p, const AVRMEM *mem, const AVRPART *v); - -int avr_read(const PROGRAMMER * pgm, const AVRPART *p, const char *memstr, const AVRPART *v); +int avr_read_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, const AVRPART *v); +int avr_read(const PROGRAMMER *pgm, const AVRPART *p, const char *memstr, const AVRPART *v); int avr_write_page(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr); @@ -1128,7 +1127,6 @@ int avr_write_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM unsigned long addr, unsigned char data); int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, int size, int auto_erase); - int avr_write(const PROGRAMMER *pgm, const AVRPART *p, const char *memstr, int size, int auto_erase); int avr_signature(const PROGRAMMER *pgm, const AVRPART *p); @@ -1136,6 +1134,7 @@ int avr_signature(const PROGRAMMER *pgm, const AVRPART *p); int avr_mem_bitmask(const AVRPART *p, const AVRMEM *mem, int addr); int avr_verify(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, const char *m, int size); +int avr_verify_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, const AVRMEM *a, int size); int avr_get_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int *cycles); From bb9df2f7bc537ee14447f0a930bfd5db3ec0dff6 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 18 Jun 2024 17:17:11 +0100 Subject: [PATCH 166/422] Automatic verify on writing to multiple -U memories --- src/avr.c | 4 +- src/update.c | 299 +++++++++++++++++++++++++++------------------------ 2 files changed, 158 insertions(+), 145 deletions(-) diff --git a/src/avr.c b/src/avr.c index 8419391f..b100313b 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1088,14 +1088,14 @@ int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, int // Read flash contents to separate memory spc and fill in holes if(avr_read_page_default(pgm, p, cm, beg, spc) >= 0) { - pmsg_notice2("padding %s [0x%04x, 0x%04x]\n", cm->desc, beg, end-1); + pmsg_debug("padding %s [0x%04x, 0x%04x]\n", cm->desc, beg, end-1); for(i = beg; i < end; i++) if(!(cm->tags[i] & TAG_ALLOCATED)) { cm->tags[i] |= TAG_ALLOCATED; cm->buf[i] = spc[i-beg]; } } else { - pmsg_notice2("cannot read %s [0x%04x, 0x%04x] to pad page\n", + pmsg_debug("cannot read %s [0x%04x, 0x%04x] to pad page\n", cm->desc, beg, end-1); } } diff --git a/src/update.c b/src/update.c index a596d98d..5c29601a 100644 --- a/src/update.c +++ b/src/update.c @@ -156,7 +156,6 @@ int memstats(const AVRPART *p, const char *memstr, int size, Filestats *fsp) { return memstats_mem(p, mem, size, fsp); } -// Memory statistics considering holes after a file read returned size bytes int memstats_mem(const AVRPART *p, const AVRMEM *mem, int size, Filestats *fsp) { Filestats ret = { 0 }; @@ -261,7 +260,6 @@ int update_is_readable(const char *fn) { return access(fn, R_OK) == 0 && update_is_okfile(fn); } - static void ioerror(const char *iotype, const UPDATE *upd) { int errnocp = errno; @@ -378,6 +376,7 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { return ret; } + // Whether a memory should be backup-ed: exclude sub-memories static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { return mem_is_in_flash(mem)? mem_is_flash(mem): @@ -387,28 +386,29 @@ static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { !mem_is_sram(mem); } - static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, - const UPDATE *upd, enum updateflags flags, int size, const char *caption) { + const UPDATE *upd, enum updateflags flags, int size, int multiple) { - int rc = 0; + int rc = 0, pbar = (mem->size > 32 || verbose > 1) && update_progress; Filestats fs, fs_patched; + const char *m_name = avr_mem_name(p, mem); if(memstats_mem(p, mem, size, &fs) < 0) return -1; - imsg_info("read %d byte%s for %s in %d section%s within %s\n", - fs.nbytes, str_plural(fs.nbytes), avr_mem_name(p, mem), - fs.nsections, str_plural(fs.nsections), - str_ccinterval(fs.firstaddr, fs.lastaddr)); + if(multiple) // Single file writes multiple memories, say which ones + pmsg_info("%d byte%s %s ", fs.nbytes, str_plural(fs.nbytes), m_name); + else + imsg_info(""); + msg_info("in %d section%s %s%s", fs.nsections, str_plural(fs.nsections), + fs.nsections == 1? "": "of ", str_ccinterval(fs.firstaddr, fs.lastaddr)); if(mem->page_size > 1) { - imsg_info("using %d page%s and %d pad byte%s", - fs.npages, str_plural(fs.npages), - fs.nfill, str_plural(fs.nfill)); + msg_info(": %d page%s and %d pad byte%s", + fs.npages, str_plural(fs.npages), fs.nfill, str_plural(fs.nfill)); if(fs.ntrailing) - msg_info(", cutting off %d trailing 0xff byte%s", + imsg_info("cutting off %d trailing 0xff byte%s (use -A to keep trailing 0xff)", fs.ntrailing, str_plural(fs.ntrailing)); - msg_info("\n"); } + msg_info("\n"); // Patch flash input, eg, for vector bootloaders if(pgm->flash_readhook && mem_is_flash(mem)) { @@ -419,52 +419,95 @@ static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRME if(memstats_mem(p, mem, size, &fs_patched) < 0) return -1; if(memcmp(&fs_patched, &fs, sizeof fs)) { - pmsg_info("preparing flash input for device%s\n", + imsg_info("preparing flash input for device%s\n", pgm->prog_modes & PM_SPM? " bootloader": ""); - imsg_notice2("with %d byte%s in %d section%s within %s\n", + imsg_notice("%d byte%s in %d section%s %s%s", fs_patched.nbytes, str_plural(fs_patched.nbytes), fs_patched.nsections, str_plural(fs_patched.nsections), + fs_patched.nsections == 1? "": "of ", str_ccinterval(fs_patched.firstaddr, fs_patched.lastaddr)); if(mem->page_size > 1) { - imsg_notice2("using %d page%s and %d pad byte%s", + msg_notice(": %d page%s and %d pad byte%s", fs_patched.npages, str_plural(fs_patched.npages), fs_patched.nfill, str_plural(fs_patched.nfill)); if(fs_patched.ntrailing) - msg_notice2(", and %d trailing 0xff byte%s", + imsg_notice("note %d trailing 0xff byte%s", fs_patched.ntrailing, str_plural(fs_patched.ntrailing)); - msg_notice2("\n"); } + msg_notice("\n"); memcpy(&fs, &fs_patched, sizeof fs); } } // Write the buffer contents to the selected memory - pmsg_info("writing %d byte%s to %s ...\n", fs.nbytes, - str_plural(fs.nbytes), mem->desc); + imsg_info("writing %d byte%s to %s %s", fs.nbytes, str_plural(fs.nbytes), m_name, + size == 1 && fs.nbytes == 1? str_ccprintf("(0x%02x)", mem->buf[0]): "..."); - if(!(flags & UF_NOWRITE)) { - if(mem->size > 32 || verbose > 1) - report_progress(0, 1, "Writing"); - rc = avr_write_mem(pgm, p, mem, size, (flags & UF_AUTO_ERASE) != 0); - report_progress(1, 1, NULL); - } else { + if(flags & UF_NOWRITE) { // Test mode: write to stdout in intel hex rather than to the chip rc = fileio_mem(FIO_WRITE, "-", FMT_IHEX, p, mem, size); + } else { + if(pbar) + report_progress(0, 1, str_ccprintf("%*swriting", (int) strlen(progname)+2, "")); + rc = avr_write_mem(pgm, p, mem, size, (flags & UF_AUTO_ERASE) != 0); + report_progress(1, 1, NULL); } - if (rc < 0) { - pmsg_error("unable to write %s, rc=%d\n", mem->desc, rc); + if(rc < 0) return -1; + if(pbar && !(flags & UF_VERIFY)) + imsg_info("%d byte%s of %s written", fs.nbytes, str_plural(fs.nbytes), m_name); + else if(!pbar) + msg_info(", %d byte%s written", fs.nbytes, str_plural(fs.nbytes)); + + return rc; // Highest memory address written plus 1 +} + +static int update_avr_verify(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, + const UPDATE *upd, int size, const char *caption) { + + int retval = LIBAVRDUDE_GENERAL_FAILURE, pbar = (mem->size > 32 || verbose > 1) && update_progress; + Filestats fs; + AVRPART *v = avr_dup_part(p); + const char *m_name = avr_mem_name(p, mem); + + if(memstats_mem(p, mem, size, &fs) < 0) + goto error; + + led_set(pgm, LED_VFY); + if(pbar) + report_progress (0, 1, caption); + int rc = avr_read_mem(pgm, p, mem, v); + report_progress (1, 1, NULL); + if(rc < 0) { + pmsg_error("unable to read all of %s, rc = %d\n", m_name, rc); + led_set(pgm, LED_ERR); + goto error; } - pmsg_info("%d byte%s of %s written\n", fs.nbytes, str_plural(fs.nbytes), mem->desc); + rc = avr_verify_mem(pgm, p, v, mem, size); + if(rc < 0) { + pmsg_error("verification mismatch\n"); + led_set(pgm, LED_ERR); + goto error; + } - return rc; + int verified = fs.nbytes + fs.ntrailing; + if(pbar || upd->op == DEVICE_VERIFY) + imsg_info("%d byte%s of %s verified\n", verified, str_plural(verified), m_name); + else + msg_info(", %d verified\n", verified); + + retval = LIBAVRDUDE_SUCCESS; + +error: + led_clr(pgm, LED_VFY); + avr_free_part(v); + return retval; } int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updateflags flags) { - int retval = LIBAVRDUDE_GENERAL_FAILURE; - AVRPART *v; + int retval = LIBAVRDUDE_GENERAL_FAILURE, rwvproblem = 0, rwvsoftfail = 0; AVRMEM *mem, **umemlist = NULL, *m; Segment *seglist = NULL; Filestats fs; @@ -483,13 +526,14 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat return terminal_mode(pgm, p); } - int size, len, maxmemstrlen = 0, ns = 0; + int size, len, maxrlen = 0, ns = 0; // Compute list of multiple memories if umstr indicates so if(str_eq(umstr, "all") || strchr(umstr, ',')) { ns = (lsize(p->mem) + 1) * ((int) str_numc(umstr, ',') + 1); // Upper limit of memories umemlist = mmt_malloc(ns*sizeof*umemlist); ns = 0; // Now count how many there really are mentioned + // Parse comma-separated list of memories incl memory all char *dstr = mmt_strdup(umstr), *s = dstr, *e; for(e = strchr(s, ','); 1; e = strchr(s, ',')) { if(e) @@ -501,16 +545,19 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat umemlist[ns++] = m; } else if(!*s) { // Ignore empty list elements } else { - if(!(m = avr_locate_mem(p, s))) - pmsg_warning("skipping unknown memory %s in list -U %s:...\n", s, umstr); - else + if((m = avr_locate_mem(p, s))) umemlist[ns++] = m; + else { + pmsg_warning("skipping unknown memory %s in list -U %s:...\n", s, umstr); + rwvsoftfail = 1; + } } if(!e) break; s = e+1; } mmt_free(dstr); + // De-duplicate list, keeping order for(int i=0; i < ns; i++) { m = umemlist[i]; @@ -520,31 +567,34 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat memmove(umemlist+j, umemlist+j+1, (ns-j-1)*sizeof*umemlist); } - if(!ns) { + if(!ns) { // ns is number of memories listed pmsg_warning("skipping -U %s:... as no memory in part %s available\n", umstr, p->desc); mmt_free(umemlist); return LIBAVRDUDE_SOFTFAIL; } - // Maximum length of memory name for to-be-read memories + + // Maximum length of memory names for to-be-processed memories for(int i=0; i maxmemstrlen) - maxmemstrlen = len; + if((len = strlen(avr_mem_name(p, umemlist[i]))) > maxrlen) + maxrlen = len; + seglist = mmt_malloc(ns*sizeof*seglist); } mem = umemlist? avr_new_memory("multi", ANY_MEM_SIZE): avr_locate_mem(p, umstr); - if (mem == NULL) { + if(mem == NULL) { pmsg_warning("skipping -U %s:... as memory not defined for part %s\n", umstr, p->desc); return LIBAVRDUDE_SOFTFAIL; } + const char *rcap = str_ccprintf("%*sreading", (int) strlen(progname)+2, ""); const char *mem_desc = !umemlist? avr_mem_name(p, mem): ns==1? avr_mem_name(p, umemlist[0]): "multiple memories"; int rc = 0; - switch (upd->op) { + switch(upd->op) { case DEVICE_READ: // Read out the specified device memory and write it to a file - if (upd->format == FMT_IMM) { + if(upd->format == FMT_IMM) { pmsg_error("invalid file format 'immediate' for output\n"); goto error; } @@ -564,22 +614,24 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat */ int dffo = cx->avr_disableffopt; cx->avr_disableffopt = 1; - pmsg_info("reading %s ...\n", mem_desc); - int nn = 0; + imsg_info("reading %s ...\n", mem_desc); + int nn = 0, nbytes = 0; for(int ii = 0; ii < ns; ii++) { m = umemlist[ii]; const char *m_name = avr_mem_name(p, m); - const char *caption = str_ccprintf("Reading %-*s", maxmemstrlen, m_name); - report_progress(0, 1, caption); + const char *cap = str_ccprintf("%*s%-*s", (int) strlen(progname)+2, "", maxrlen, m_name); + report_progress(0, 1, cap); int ret = avr_read_mem(pgm, p, m, NULL); report_progress(1, 1, NULL); if(ret < 0) { pmsg_warning("unable to read %s (ret = %d), skipping...\n", m_name, ret); + rwvproblem = 1; continue; } unsigned off = fileio_mem_offset(p, m); if(off == -1U) { pmsg_warning("cannot map %s to flat address space, skipping ...\n", m_name); + rwvproblem = 1; continue; } if(ret > 0) { @@ -587,162 +639,121 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat memcpy(mem->buf+off, m->buf, ret); seglist[nn].addr = off; seglist[nn].len = ret; + nbytes += ret; nn++; } } + imsg_info("writing %d byte%s to output file %s\n", + nbytes, str_plural(nbytes), str_outname(upd->filename)); if(nn) rc = fileio_segments(FIO_WRITE, upd->filename, upd->format, p, mem, nn, seglist); else pmsg_notice("empty memory, resulting file has no contents\n"); cx->avr_disableffopt = dffo; } else { // Regular file - pmsg_info("reading %s memory ...\n", mem_desc); - if(mem->size > 32 || verbose > 1) - report_progress(0, 1, "Reading"); + imsg_info("reading %s memory ...\n", mem_desc); + if(mem->size > 32) + report_progress(0, 1, rcap); rc = avr_read(pgm, p, umstr, 0); report_progress(1, 1, NULL); - if (rc < 0) { + if(rc < 0) { pmsg_error("unable to read all of %s, rc=%d\n", mem_desc, rc); goto error; } - if (rc == 0) + if(rc == 0) pmsg_notice("empty memory, resulting file has no contents\n"); - pmsg_info("writing output file %s\n", str_outname(upd->filename)); + imsg_info("writing %d byte%s to output file %s\n", + rc, str_plural(rc), str_outname(upd->filename)); rc = fileio_mem(FIO_WRITE, upd->filename, upd->format, p, mem, rc); } - if (rc < 0) { + if(rc < 0) { pmsg_error("write to file %s failed\n", str_outname(upd->filename)); goto error; } - break; case DEVICE_WRITE: // Write the selected device memory/ies using data from a file - - pmsg_info("reading input file %s for %s\n", str_inname(upd->filename), mem_desc); rc = fileio_mem(FIO_READ, upd->filename, upd->format, p, mem, -1); - if (rc < 0) { + if(rc < 0) { pmsg_error("read from file %s failed\n", str_inname(upd->filename)); goto error; } if(memstats_mem(p, mem, rc, &fs) < 0) goto error; + pmsg_info("reading %d byte%s for %s from input file %s\n", + fs.nbytes, str_plural(fs.nbytes), mem_desc, str_inname(upd->filename)); if(umemlist) { - int allsize = rc; + int allsize = rc, ret; for(int i=0; iprog_modes & PM_SPM) && (mem_is_in_fuses(m) || mem_is_lock(m)))) continue; const char *m_name = avr_mem_name(p, m); - const char *caption = str_ccprintf("Writing %-*s", maxmemstrlen, m_name); int off = fileio_mem_offset(p, m); if(off < 0) { pmsg_warning("cannot map %s to flat address space, skipping ...\n", m_name); - continue; - } - if(allsize <= off) { - pmsg_warning("input file has no data for %s, skipping ...\n", m_name); + rwvproblem = 1; continue; } // Copy input file contents into memory size = m->size; - if(allsize - off < size) - size = allsize - off; + if(allsize-off < size) // Clip to available data in input + size = allsize > off? allsize-off: 0; + if(is_memset(mem->tags+off, 0, size)) // Nothing set? This memory was not present + size = 0; + if(size == 0) { + pmsg_warning("%s has no data for %s, skipping ...\n", str_inname(upd->filename), m_name); + rwvsoftfail = 1; + continue; + } memcpy(m->buf, mem->buf+off, size); memcpy(m->tags, mem->tags+off, size); - - int ret = update_avr_write(pgm, p, m, upd, flags, size, caption); - if(ret < 0) { + if((ret = update_avr_write(pgm, p, m, upd, flags, size, 1)) < 0) { pmsg_warning("unable to write %s (ret = %d), skipping...\n", m_name, ret); + rwvproblem = 1; + continue; + } + if((flags & UF_VERIFY) && update_avr_verify(pgm, p, m, upd, size, rcap) < 0) { + rwvproblem = 1; continue; } } break; } else { - update_avr_write(pgm, p, mem, upd, flags, rc, "Writing"); + if((rc = update_avr_write(pgm, p, mem, upd, flags, rc, 0)) < 0) { + pmsg_error("unable to write %s, rc=%d\n", mem_desc, rc); + goto error; + } + if((flags & UF_VERIFY) && update_avr_verify(pgm, p, mem, upd, fs.lastaddr+1, rcap) < 0) + goto error; } - - if (!(flags & UF_VERIFY)) // Fall through for auto verify unless - break; - // Fall through + break; case DEVICE_VERIFY: // Verify that the in memory file is the same as what is on the chip - led_set(pgm, LED_VFY); + rc = fileio_mem(FIO_READ_FOR_VERIFY, upd->filename, upd->format, p, mem, -1); + if(rc < 0) { + pmsg_error("read from file %s failed\n", str_inname(upd->filename)); + goto error; + } + size = rc; + if(memstats_mem(p, mem, size, &fs) < 0) + goto error; + pmsg_info("verifying %d byte%s for %s from input file %s\n", + fs.nbytes, str_plural(fs.nbytes), mem_desc, str_inname(upd->filename)); - int userverify = upd->op == DEVICE_VERIFY; // Explicit -U :v by user - - pmsg_info("verifying %s against %s\n", mem_desc, str_inname(upd->filename)); - - // No need to read file when fallen through from DEVICE_WRITE - if (userverify) { - pmsg_notice("load %s data from input file %s\n", mem_desc, str_inname(upd->filename)); - - rc = fileio(FIO_READ_FOR_VERIFY, upd->filename, upd->format, p, umstr, -1); - - if (rc < 0) { - pmsg_error("read from file %s failed\n", str_inname(upd->filename)); - led_set(pgm, LED_ERR); - led_clr(pgm, LED_VFY); - goto error; - } - size = rc; - - if(memstats(p, umstr, size, &fs) < 0) { - led_set(pgm, LED_ERR); - led_clr(pgm, LED_VFY); - goto error; - } + if(umemlist) { } else { - // Correct size of last read to include potentially cut off, trailing 0xff (flash) - size = fs.lastaddr+1; + if(update_avr_verify(pgm, p, mem, upd, size, rcap) < 0) + goto error; } - - v = avr_dup_part(p); - - if (quell_progress < 2) { - if (userverify) - pmsg_notice("input file %s contains %d byte%s\n", - str_inname(upd->filename), fs.nbytes, str_plural(fs.nbytes)); - pmsg_notice2("reading on-chip %s data ...\n", mem_desc); - } - - if(mem->size > 32 || verbose > 1) - report_progress (0,1,"Reading"); - rc = avr_read(pgm, p, umstr, v); - report_progress (1,1,NULL); - if (rc < 0) { - pmsg_error("unable to read all of %s, rc = %d\n", mem_desc, rc); - led_set(pgm, LED_ERR); - led_clr(pgm, LED_VFY); - avr_free_part(v); - goto error; - } - - if (quell_progress < 2) - pmsg_notice2("verifying ...\n"); - - rc = avr_verify(pgm, p, v, umstr, size); - if (rc < 0) { - pmsg_error("verification mismatch\n"); - led_set(pgm, LED_ERR); - led_clr(pgm, LED_VFY); - avr_free_part(v); - goto error; - } - - int verified = fs.nbytes+fs.ntrailing; - pmsg_info("%d byte%s of %s verified\n", verified, str_plural(verified), mem_desc); - - led_clr(pgm, LED_VFY); - avr_free_part(v); break; default: @@ -750,7 +761,9 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat goto error; } - retval = LIBAVRDUDE_SUCCESS; + retval = + rwvproblem? LIBAVRDUDE_GENERAL_FAILURE: + rwvsoftfail? LIBAVRDUDE_SOFTFAIL : LIBAVRDUDE_SUCCESS; error: if(umemlist) { From afd65c040f5c0ffe8a9d9809dbd946c4f5d3c05f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 18 Jun 2024 18:35:53 +0100 Subject: [PATCH 167/422] Enable verifying a single file against -U [|all]:v:... --- src/update.c | 142 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 55 deletions(-) diff --git a/src/update.c b/src/update.c index 5c29601a..091b0f3f 100644 --- a/src/update.c +++ b/src/update.c @@ -260,6 +260,7 @@ int update_is_readable(const char *fn) { return access(fn, R_OK) == 0 && update_is_okfile(fn); } + static void ioerror(const char *iotype, const UPDATE *upd) { int errnocp = errno; @@ -455,6 +456,7 @@ static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRME if(rc < 0) return -1; + // @@@ has there has been output in the meantime to make the ", x bytes written" look out of place? if(pbar && !(flags & UF_VERIFY)) imsg_info("%d byte%s of %s written", fs.nbytes, str_plural(fs.nbytes), m_name); else if(!pbar) @@ -492,6 +494,7 @@ static int update_avr_verify(const PROGRAMMER *pgm, const AVRPART *p, const AVRM goto error; } + // @@@ has there has been output in the meantime to make the ", x bytes verified" look out of place? int verified = fs.nbytes + fs.ntrailing; if(pbar || upd->op == DEVICE_VERIFY) imsg_info("%d byte%s of %s verified\n", verified, str_plural(verified), m_name); @@ -506,6 +509,49 @@ error: return retval; } +static int update_mem_from_all(const UPDATE *upd, const AVRPART *p, const AVRMEM *m, + const AVRMEM *all, int allsize) { + + const char *m_name = avr_mem_name(p, m); + int off = fileio_mem_offset(p, m); + if(off < 0) { + pmsg_warning("cannot map %s to flat address space, skipping ...\n", m_name); + return LIBAVRDUDE_GENERAL_FAILURE; + } + // Copy input file contents into memory + int size = m->size; + if(allsize-off < size) // Clip to available data in input + size = allsize > off? allsize-off: 0; + if(is_memset(all->tags+off, 0, size)) // Nothing set? This memory was not present + size = 0; + if(size == 0) + pmsg_warning("%s has no data for %s, skipping ...\n", str_inname(upd->filename), m_name); + + memcpy(m->buf, all->buf+off, size); + memcpy(m->tags, all->tags+off, size); + + return size; +} + +static int update_all_from_file(const UPDATE *upd, const AVRPART *p, const AVRMEM *all, + const char *mem_desc, Filestats *fsp) { + // On writing to the device trailing 0xff might be cut off + int op = upd->op == DEVICE_WRITE? FIO_READ: FIO_READ_FOR_VERIFY; + int allsize = fileio_mem(op, upd->filename, upd->format, p, all, -1); + if(allsize < 0) { + pmsg_error("reading from file %s failed\n", str_inname(upd->filename)); + return -1; + } + if(memstats_mem(p, all, allsize, fsp) < 0) + return -1; + pmsg_info(upd->op == DEVICE_WRITE? + "reading %d byte%s for %s from input file %s\n": + "verifying %d byte%s of %s against input file %s\n", + fsp->nbytes, str_plural(fsp->nbytes), mem_desc, str_inname(upd->filename) + ); + return allsize; +} + int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updateflags flags) { int retval = LIBAVRDUDE_GENERAL_FAILURE, rwvproblem = 0, rwvsoftfail = 0; AVRMEM *mem, **umemlist = NULL, *m; @@ -526,8 +572,8 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat return terminal_mode(pgm, p); } - int size, len, maxrlen = 0, ns = 0; - // Compute list of multiple memories if umstr indicates so + int allsize, len, maxrlen = 0, ns = 0; + if(str_eq(umstr, "all") || strchr(umstr, ',')) { ns = (lsize(p->mem) + 1) * ((int) str_numc(umstr, ',') + 1); // Upper limit of memories umemlist = mmt_malloc(ns*sizeof*umemlist); @@ -659,7 +705,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat rc = avr_read(pgm, p, umstr, 0); report_progress(1, 1, NULL); if(rc < 0) { - pmsg_error("unable to read all of %s, rc=%d\n", mem_desc, rc); + pmsg_error("unable to read all of %s (rc = %d)\n", mem_desc, rc); goto error; } if(rc == 0) @@ -677,58 +723,37 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat case DEVICE_WRITE: // Write the selected device memory/ies using data from a file - rc = fileio_mem(FIO_READ, upd->filename, upd->format, p, mem, -1); - if(rc < 0) { - pmsg_error("read from file %s failed\n", str_inname(upd->filename)); + if((allsize = update_all_from_file(upd, p, mem, mem_desc, &fs)) < 0) goto error; - } - if(memstats_mem(p, mem, rc, &fs) < 0) - goto error; - pmsg_info("reading %d byte%s for %s from input file %s\n", - fs.nbytes, str_plural(fs.nbytes), mem_desc, str_inname(upd->filename)); - if(umemlist) { - int allsize = rc, ret; for(int i=0; iprog_modes & PM_SPM) && (mem_is_in_fuses(m) || mem_is_lock(m)))) continue; - const char *m_name = avr_mem_name(p, m); - int off = fileio_mem_offset(p, m); - if(off < 0) { - pmsg_warning("cannot map %s to flat address space, skipping ...\n", m_name); - rwvproblem = 1; - continue; - } - // Copy input file contents into memory - size = m->size; - if(allsize-off < size) // Clip to available data in input - size = allsize > off? allsize-off: 0; - if(is_memset(mem->tags+off, 0, size)) // Nothing set? This memory was not present - size = 0; - if(size == 0) { - pmsg_warning("%s has no data for %s, skipping ...\n", str_inname(upd->filename), m_name); - rwvsoftfail = 1; - continue; - } - memcpy(m->buf, mem->buf+off, size); - memcpy(m->tags, mem->tags+off, size); - if((ret = update_avr_write(pgm, p, m, upd, flags, size, 1)) < 0) { - pmsg_warning("unable to write %s (ret = %d), skipping...\n", m_name, ret); - rwvproblem = 1; - continue; - } - if((flags & UF_VERIFY) && update_avr_verify(pgm, p, m, upd, size, rcap) < 0) { - rwvproblem = 1; - continue; + int ret, size = update_mem_from_all(upd, p, m, mem, allsize); + switch(size) { + case LIBAVRDUDE_GENERAL_FAILURE: + rwvproblem = 1; break; + case 0: + rwvsoftfail = 1; break; + default: + if((ret = update_avr_write(pgm, p, m, upd, flags, size, 1)) < 0) { + pmsg_warning("unable to write %s (ret = %d), skipping...\n", avr_mem_name(p, m), ret); + rwvproblem = 1; + continue; + } + // @@@ verify size could be too small if file was not a multi-file and had trailing 0xff + if((flags & UF_VERIFY) && update_avr_verify(pgm, p, m, upd, size, rcap) < 0) { + rwvproblem = 1; + continue; + } } } - break; } else { - if((rc = update_avr_write(pgm, p, mem, upd, flags, rc, 0)) < 0) { - pmsg_error("unable to write %s, rc=%d\n", mem_desc, rc); + if((rc = update_avr_write(pgm, p, mem, upd, flags, allsize, 0)) < 0) { + pmsg_error("unable to write %s (rc = %d)\n", mem_desc, rc); goto error; } if((flags & UF_VERIFY) && update_avr_verify(pgm, p, mem, upd, fs.lastaddr+1, rcap) < 0) @@ -738,20 +763,27 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat case DEVICE_VERIFY: // Verify that the in memory file is the same as what is on the chip - rc = fileio_mem(FIO_READ_FOR_VERIFY, upd->filename, upd->format, p, mem, -1); - if(rc < 0) { - pmsg_error("read from file %s failed\n", str_inname(upd->filename)); + if((allsize = update_all_from_file(upd, p, mem, mem_desc, &fs)) < 0) goto error; - } - size = rc; - if(memstats_mem(p, mem, size, &fs) < 0) - goto error; - pmsg_info("verifying %d byte%s for %s from input file %s\n", - fs.nbytes, str_plural(fs.nbytes), mem_desc, str_inname(upd->filename)); - if(umemlist) { + for(int i=0; i Date: Tue, 18 Jun 2024 18:49:24 +0100 Subject: [PATCH 168/422] Separate function creating a memory list from a string --- src/update.c | 102 ++++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/src/update.c b/src/update.c index 091b0f3f..eea1e948 100644 --- a/src/update.c +++ b/src/update.c @@ -272,6 +272,61 @@ static void ioerror(const char *iotype, const UPDATE *upd) { msg_ext_error("\n"); } +// Whether a memory should be backup-ed: exclude sub-memories +static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { + return mem_is_in_flash(mem)? mem_is_flash(mem): + mem_is_in_sigrow(mem)? mem_is_sigrow(mem): + mem_is_in_fuses(mem)? mem_is_fuses(mem) || !avr_locate_fuses(p): + mem_is_io(mem)? 0: + !mem_is_sram(mem); +} + +// Generate memory list from string and put number of memories into *np +static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *rwvsoftfailp) { + AVRMEM *m; + + int ns = (lsize(p->mem) + 1) * ((int) str_numc(umstr, ',') + 1); // Upper limit of memories + AVRMEM **umemlist = mmt_malloc(ns*sizeof*umemlist); + ns = 0; // Now count how many there really are mentioned + + // Parse comma-separated list of memories incl memory all + char *dstr = mmt_strdup(umstr), *s = dstr, *e; + for(e = strchr(s, ','); 1; e = strchr(s, ',')) { + if(e) + *e = 0; + s = str_trim(s); + if(str_eq(s, "all")) { + for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) + if(is_backup_mem(p, (m = ldata(lm)))) + umemlist[ns++] = m; + } else if(!*s) { // Ignore empty list elements + } else { + if((m = avr_locate_mem(p, s))) + umemlist[ns++] = m; + else if(rwvsoftfailp) { + pmsg_warning("skipping unknown memory %s in list -U %s:...\n", s, umstr); + *rwvsoftfailp = 1; + } + } + if(!e) + break; + s = e+1; + } + mmt_free(dstr); + + // De-duplicate list, keeping order + for(int i=0; i < ns; i++) { + m = umemlist[i]; + // Move down remaining list whenever same memory detected + for(int j = i+1; j < ns; j++) + for(; j < ns && m == umemlist[j]; ns--) + memmove(umemlist+j, umemlist+j+1, (ns-j-1)*sizeof*umemlist); + } + + *np = ns; + return umemlist; +} + // Basic checks to reveal serious failure before programming (and on autodetect set format) int update_dryrun(const AVRPART *p, UPDATE *upd) { int known, format_detect, ret = LIBAVRDUDE_SUCCESS; @@ -378,15 +433,6 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { } -// Whether a memory should be backup-ed: exclude sub-memories -static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { - return mem_is_in_flash(mem)? mem_is_flash(mem): - mem_is_in_sigrow(mem)? mem_is_sigrow(mem): - mem_is_in_fuses(mem)? mem_is_fuses(mem) || !avr_locate_fuses(p): - mem_is_io(mem)? 0: - !mem_is_sram(mem); -} - static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, const UPDATE *upd, enum updateflags flags, int size, int multiple) { @@ -575,43 +621,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat int allsize, len, maxrlen = 0, ns = 0; if(str_eq(umstr, "all") || strchr(umstr, ',')) { - ns = (lsize(p->mem) + 1) * ((int) str_numc(umstr, ',') + 1); // Upper limit of memories - umemlist = mmt_malloc(ns*sizeof*umemlist); - ns = 0; // Now count how many there really are mentioned - - // Parse comma-separated list of memories incl memory all - char *dstr = mmt_strdup(umstr), *s = dstr, *e; - for(e = strchr(s, ','); 1; e = strchr(s, ',')) { - if(e) - *e = 0; - s = str_trim(s); - if(str_eq(s, "all")) { - for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) - if(is_backup_mem(p, (m = ldata(lm)))) - umemlist[ns++] = m; - } else if(!*s) { // Ignore empty list elements - } else { - if((m = avr_locate_mem(p, s))) - umemlist[ns++] = m; - else { - pmsg_warning("skipping unknown memory %s in list -U %s:...\n", s, umstr); - rwvsoftfail = 1; - } - } - if(!e) - break; - s = e+1; - } - mmt_free(dstr); - - // De-duplicate list, keeping order - for(int i=0; i < ns; i++) { - m = umemlist[i]; - // Move down remaining list whenever same memory detected - for(int j = i+1; j < ns; j++) - for(; j < ns && m == umemlist[j]; ns--) - memmove(umemlist+j, umemlist+j+1, (ns-j-1)*sizeof*umemlist); - } + umemlist = memory_list(umstr, p, &ns, &rwvsoftfail); if(!ns) { // ns is number of memories listed pmsg_warning("skipping -U %s:... as no memory in part %s available\n", umstr, p->desc); From 847fcd5ad8353469a2970022d04b496a2b396405 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 18 Jun 2024 19:12:44 +0100 Subject: [PATCH 169/422] Utilise memory_list function for update_dryrun() --- src/update.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/update.c b/src/update.c index eea1e948..d04d0195 100644 --- a/src/update.c +++ b/src/update.c @@ -282,7 +282,7 @@ static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { } // Generate memory list from string and put number of memories into *np -static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *rwvsoftfailp) { +static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *rwvsoftfailp, int *dry) { AVRMEM *m; int ns = (lsize(p->mem) + 1) * ((int) str_numc(umstr, ',') + 1); // Upper limit of memories @@ -301,6 +301,16 @@ static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *r umemlist[ns++] = m; } else if(!*s) { // Ignore empty list elements } else { + if(dry) { + // Reject an update if memory name is not known amongst any part (suspect a typo) + if(!avr_mem_might_be_known(s)) { + pmsg_error("unknown memory %s in -U %s:...\n", s, umstr); + *dry = LIBAVRDUDE_GENERAL_FAILURE; + mmt_free(dstr); + goto done; + } else if(!avr_locate_mem(p, s)) + *dry = LIBAVRDUDE_SOFTFAIL; + } if((m = avr_locate_mem(p, s))) umemlist[ns++] = m; else if(rwvsoftfailp) { @@ -323,7 +333,13 @@ static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *r memmove(umemlist+j, umemlist+j+1, (ns-j-1)*sizeof*umemlist); } - *np = ns; +done: + if(np) + *np = ns; + if(dry) { + mmt_free(umemlist); + umemlist = NULL; + } return umemlist; } @@ -337,27 +353,7 @@ int update_dryrun(const AVRPART *p, UPDATE *upd) { return 0; } - /* - * Allow memory name to be a list. Reject an update if memory name is not - * known amongst any part (suspect a typo) but accept when the specific part - * does not have it (allow unifying i/faces); also accept pseudo memory all - */ - char *umstr = upd->memstr, *dstr = mmt_strdup(umstr), *s = dstr, *e; - for(e = strchr(s, ','); 1; e = strchr(s, ',')) { - if(e) - *e = 0; - s = str_trim(s); - if(*s && !avr_mem_might_be_known(s) && !str_eq(s, "all")) { - pmsg_error("unknown memory %s in -U %s:...\n", s, umstr); - ret = LIBAVRDUDE_GENERAL_FAILURE; - break; - } else if(*s && !avr_locate_mem(p, s)) - ret = LIBAVRDUDE_SOFTFAIL; - if(!e) - break; - s = e+1; - } - mmt_free(dstr); + (void) memory_list(upd->memstr, p, NULL, NULL, &ret); known = 0; // Necessary to check whether the file is readable? @@ -621,7 +617,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat int allsize, len, maxrlen = 0, ns = 0; if(str_eq(umstr, "all") || strchr(umstr, ',')) { - umemlist = memory_list(umstr, p, &ns, &rwvsoftfail); + umemlist = memory_list(umstr, p, &ns, &rwvsoftfail, NULL); if(!ns) { // ns is number of memories listed pmsg_warning("skipping -U %s:... as no memory in part %s available\n", umstr, p->desc); From 128b82d9a89f689da75356707b994252d7c22183 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 18 Jun 2024 22:30:50 +0100 Subject: [PATCH 170/422] Introduce without operator \ in memory lists --- src/update.c | 83 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/src/update.c b/src/update.c index d04d0195..bc28bfc4 100644 --- a/src/update.c +++ b/src/update.c @@ -281,16 +281,37 @@ static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { !mem_is_sram(mem); } -// Generate memory list from string and put number of memories into *np -static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *rwvsoftfailp, int *dry) { - AVRMEM *m; +/* + * Generate memory list from string and put number of memories into *np; Memory + * list can be sth like ee,fl,all\cal,efuse. Exactly one without operator \ can + * be present: it removes the second list from first. Normal use is to pass + * NULL for dry and let the function write to *np (ie, the number of resulting + * memories) and *rwvsoftfail indicating unknown memories for this part. If dry + * is set then -1 will be written to *dry when a generally unknown memory is + * mentioned or the string has a syntax error. + */ +static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rwvsoftp, int *dry) { + int nsub = 0, nm = (lsize(p->mem) + 1) * ((int) str_numc(mstr, ',') + 1); // Upper limit + AVRMEM *m, **sub = NULL, **umemlist = mmt_malloc(nm*sizeof*umemlist); + char *dstr = mmt_strdup(mstr), *s = dstr, *e; - int ns = (lsize(p->mem) + 1) * ((int) str_numc(umstr, ',') + 1); // Upper limit of memories - AVRMEM **umemlist = mmt_malloc(ns*sizeof*umemlist); - ns = 0; // Now count how many there really are mentioned + switch(str_numc(dstr, '\\')) { + case 0: + break; + default: + pmsg_error("list subtracting another with \\ only allowed once: %s\n", mstr); + if(*dry) + *dry = LIBAVRDUDE_GENERAL_FAILURE; + mmt_free(dstr); + goto done; + case 1: + e = strchr(dstr, '\\'); + sub = memory_list(e+1, p, &nsub, rwvsoftp, dry); + *e = 0; + } + nm = 0; // Now count how many there really are mentioned // Parse comma-separated list of memories incl memory all - char *dstr = mmt_strdup(umstr), *s = dstr, *e; for(e = strchr(s, ','); 1; e = strchr(s, ',')) { if(e) *e = 0; @@ -298,13 +319,13 @@ static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *r if(str_eq(s, "all")) { for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) if(is_backup_mem(p, (m = ldata(lm)))) - umemlist[ns++] = m; - } else if(!*s) { // Ignore empty list elements + umemlist[nm++] = m; + } else if(!*s) { // Ignore empty list elements } else { if(dry) { // Reject an update if memory name is not known amongst any part (suspect a typo) if(!avr_mem_might_be_known(s)) { - pmsg_error("unknown memory %s in -U %s:...\n", s, umstr); + pmsg_error("unknown memory %s in -U %s:...\n", s, mstr); *dry = LIBAVRDUDE_GENERAL_FAILURE; mmt_free(dstr); goto done; @@ -312,10 +333,10 @@ static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *r *dry = LIBAVRDUDE_SOFTFAIL; } if((m = avr_locate_mem(p, s))) - umemlist[ns++] = m; - else if(rwvsoftfailp) { - pmsg_warning("skipping unknown memory %s in list -U %s:...\n", s, umstr); - *rwvsoftfailp = 1; + umemlist[nm++] = m; + else if(rwvsoftp) { + pmsg_warning("skipping unknown memory %s in list -U %s:...\n", s, mstr); + *rwvsoftp = 1; } } if(!e) @@ -324,22 +345,28 @@ static AVRMEM **memory_list(const char *umstr, const AVRPART *p, int *np, int *r } mmt_free(dstr); - // De-duplicate list, keeping order - for(int i=0; i < ns; i++) { - m = umemlist[i]; - // Move down remaining list whenever same memory detected - for(int j = i+1; j < ns; j++) - for(; j < ns && m == umemlist[j]; ns--) - memmove(umemlist+j, umemlist+j+1, (ns-j-1)*sizeof*umemlist); + if(sub) { // Subtract all memories of second list + for(int d=0; dmemstr, p, NULL, NULL, &ret); + mmt_free(memory_list(upd->memstr, p, NULL, NULL, &ret)); known = 0; // Necessary to check whether the file is readable? @@ -616,7 +643,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat int allsize, len, maxrlen = 0, ns = 0; - if(str_eq(umstr, "all") || strchr(umstr, ',')) { + if(str_eq(umstr, "all") || strchr(umstr, ',') || strchr(umstr, '\\')) { umemlist = memory_list(umstr, p, &ns, &rwvsoftfail, NULL); if(!ns) { // ns is number of memories listed From adf2e5b98b235925b1df881fda8e6e61e1255465 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 18 Jun 2024 22:37:33 +0100 Subject: [PATCH 171/422] Ignore but warn about verification errors in readonly memory --- src/avr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/avr.c b/src/avr.c index b100313b..9e9d2f50 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1325,16 +1325,17 @@ int avr_verify_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, co } int verror = 0, vroerror = 0, maxerrs = verbose >= MSG_DEBUG? size+1: 10; + int ro = mem_is_readonly(a); // Other memories can have known protected zones such as bootloaders for (i=0; itags[i] & TAG_ALLOCATED) != 0 && buf1[i] != buf2[i]) { uint8_t bitmask = p->prog_modes & PM_ISP? get_fuse_bitmask(a): avr_mem_bitmask(p, a, i); - if(pgm->readonly && pgm->readonly(pgm, p, a, i)) { + if(ro || (pgm->readonly && pgm->readonly(pgm, p, a, i))) { if(quell_progress < 2) { if(vroerror < 10) { if(!(verror + vroerror)) pmsg_warning("verification mismatch%s\n", mem_is_in_flash(a)? " in r/o areas, expected for vectors and/or bootloader": ""); - imsg_warning("device 0x%02x != input 0x%02x at addr 0x%04x (read only location)\n", + imsg_warning("device 0x%02x != input 0x%02x at addr 0x%04x (read only location: ignored)\n", buf1[i], buf2[i], i); } else if(vroerror == 10) imsg_warning("suppressing further mismatches in read-only areas\n"); From 0e4d8fd4833727b86583e0e3a94e8a52b0529518 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 18 Jun 2024 22:53:52 +0100 Subject: [PATCH 172/422] Allow etc to be used in lieu of all in memory lists --- src/update.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/update.c b/src/update.c index bc28bfc4..7a067122 100644 --- a/src/update.c +++ b/src/update.c @@ -316,7 +316,7 @@ static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rw if(e) *e = 0; s = str_trim(s); - if(str_eq(s, "all")) { + if(str_eq(s, "all") || str_eq(s, "etc")) { for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) if(is_backup_mem(p, (m = ldata(lm)))) umemlist[nm++] = m; @@ -643,7 +643,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat int allsize, len, maxrlen = 0, ns = 0; - if(str_eq(umstr, "all") || strchr(umstr, ',') || strchr(umstr, '\\')) { + if(str_eq(umstr, "all") || str_eq(umstr, "etc") || strchr(umstr, ',') || strchr(umstr, '\\')) { umemlist = memory_list(umstr, p, &ns, &rwvsoftfail, NULL); if(!ns) { // ns is number of memories listed @@ -687,9 +687,9 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat * store those pages that are non-empty for a paged memory, and if it was * all empty, store only the first empty page to indicate the memory was * selected. However, file space on a PC is cheap and fast; the main use - * case for saving "all" memory is a backup, and AVRDUDE does not want to - * rely on the uploader to know that the backup file requires the paged - * memories to be erased first, so the code goes the full hog. + * case for saving "all/etc" memory is a backup, and AVRDUDE does not + * want to rely on the uploader to know that the backup file requires the + * paged memories to be erased first, so the code goes the full hog. */ int dffo = cx->avr_disableffopt; cx->avr_disableffopt = 1; @@ -734,7 +734,6 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat imsg_info("reading %s memory ...\n", mem_desc); if(mem->size > 32) report_progress(0, 1, rcap); - rc = avr_read(pgm, p, umstr, 0); report_progress(1, 1, NULL); if(rc < 0) { @@ -828,7 +827,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat retval = rwvproblem? LIBAVRDUDE_GENERAL_FAILURE: - rwvsoftfail? LIBAVRDUDE_SOFTFAIL : LIBAVRDUDE_SUCCESS; + rwvsoftfail? LIBAVRDUDE_SOFTFAIL: LIBAVRDUDE_SUCCESS; error: if(umemlist) { From b366078e6afd6a5a41ef9a392c67dbba1d8db86b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 19 Jun 2024 00:27:26 +0100 Subject: [PATCH 173/422] Provide str_mcunames_signature() --- src/libavrdude.h | 1 + src/strutil.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index 5b442212..1eec1ba5 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1514,6 +1514,7 @@ char *str_nexttok(char *buf, const char *delim, char **next); const char *str_ccfrq(double f, int n); int str_levenshtein(const char *str1, const char *str2, int swap, int subst, int add, int del); size_t str_weighted_damerau_levenshtein(const char *str1, const char *str2); +int str_mcunames_signature(uint8_t *sigs, char *p, size_t n); int led_set(const PROGRAMMER *pgm, int led); int led_clr(const PROGRAMMER *pgm, int led); diff --git a/src/strutil.c b/src/strutil.c index a5906ad0..d959ef1d 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1301,3 +1301,24 @@ size_t str_weighted_damerau_levenshtein(const char *s1, const char *s2) { mmt_free(row2); return i; } + + +// Puts a comma-separated list of matching MCU names into array p with n chars space +int str_mcunames_signature(uint8_t *sigs, char *p, size_t n) { + int matching = 0; + + for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++) { + if(0 == memcmp(sigs, uP_table[i].sigs, sizeof uP_table->sigs)) { + if(matching && n > 2) + strcpy(p, ", "), n -= 2, p += 2; + size_t len = strlen(uP_table[i].name); + if(n > len) { + strcpy(p, uP_table[i].name); + n -= len; p += len; + } + matching++; + } + } + + return matching; +} From 392ccf88144f4f880a22dbfe7de3b6aad1ac3fcb Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 19 Jun 2024 00:28:22 +0100 Subject: [PATCH 174/422] Specify memory name in verfication error --- src/avr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/avr.c b/src/avr.c index 9e9d2f50..51be9006 100644 --- a/src/avr.c +++ b/src/avr.c @@ -1333,7 +1333,7 @@ int avr_verify_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, co if(quell_progress < 2) { if(vroerror < 10) { if(!(verror + vroerror)) - pmsg_warning("verification mismatch%s\n", + pmsg_warning("%s verification mismatch%s\n", a->desc, mem_is_in_flash(a)? " in r/o areas, expected for vectors and/or bootloader": ""); imsg_warning("device 0x%02x != input 0x%02x at addr 0x%04x (read only location: ignored)\n", buf1[i], buf2[i], i); @@ -1345,7 +1345,7 @@ int avr_verify_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRPART *v, co // Mismatch is not just in unused bits if(verror < maxerrs) { if(!(verror + vroerror)) - pmsg_warning("verification mismatch\n"); + pmsg_warning("%s verification mismatch\n", a->desc); imsg_error("device 0x%02x != input 0x%02x at addr 0x%04x (error)\n", buf1[i], buf2[i], i); } else if(verror == maxerrs) { imsg_warning("suppressing further verification errors\n"); From 9a446ec0bb54b1c2317fa70ab582a1a6bf14d518 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 19 Jun 2024 00:29:02 +0100 Subject: [PATCH 175/422] Check signature of part against multi-memory file signature ... to avoid tears when mistakenly restoring a backup from another part $ avrdude -c dryrun -p t167 -U all:r:backup.hex:I avrdude: AVR device initialized and ready to accept instructions avrdude: device signature = 0x1e9487 (probably t167) avrdude: processing -U all:r:backup.hex:r reading multiple memories ... eeprom | ################################################## | 100% 0.00s flash | ################################################## | 100% 0.00s lfuse | ################################################## | 100% 0.00s hfuse | ################################################## | 100% 0.00s efuse | ################################################## | 100% 0.00s lock | ################################################## | 100% 0.00s signature | ################################################## | 100% 0.00s calibration | ################################################## | 100% 0.00s writing 16904 bytes to output file backup.hex avrdude done. Thank you. $ avrdude -c urclock -p m328p -b 115200 -P /dev/ttyUSB0 -U all:v:backup.hex:I avrdude -c urclock -p m328p -b 115200 -P /dev/ttyUSB0 -U all:v:backup.hex avrdude: AVR device initialized and ready to accept instructions avrdude: device signature = 0x1e950f (probably m328p) avrdude: processing -U all:v:backup.hex:i avrdude: verifying 16904 bytes of multiple memories against input file backup.hex avrdude error: signature of ATmega328P does not match file (ATtiny167, ATA5505, ATA6617C, ATA664251) use -F to override this check avrdude done. Thank you. $ avrdude -c dryrun -p m328p -U all:w:backup.hex:I -F avrdude: AVR device initialized and ready to accept instructions avrdude: device signature = 0x1e950f (probably m328p) avrdude: processing -U all:w:backup.hex:I avrdude: reading 16904 bytes for multiple memories from input file backup.hex avrdude: 512 bytes eeprom in 1 section [0, 0x1ff]: 128 pages and 0 pad bytes writing 512 bytes to eeprom ... writing | ################################################## | 100% 0.00s reading | ################################################## | 100% 0.00s 512 bytes of eeprom verified avrdude: 16384 bytes flash in 1 section [0, 0x3fff]: 128 pages and 0 pad bytes writing 16384 bytes to flash ... writing | ################################################## | 100% 0.00s reading | ################################################## | 100% 0.00s 16384 bytes of flash verified avrdude: 1 byte lfuse in 1 section [0, 0] writing 1 byte to lfuse (0x62), 1 byte written, 1 verified avrdude: 1 byte hfuse in 1 section [0, 0] writing 1 byte to hfuse (0xdf), 1 byte written, 1 verified avrdude: 1 byte efuse in 1 section [0, 0] writing 1 byte to efuse (0xff), 1 byte written, 1 verified avrdude: 1 byte lock in 1 section [0, 0] writing 1 byte to lock (0xff), 1 byte written, 1 verified avrdude done. Thank you. --- src/update.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/update.c b/src/update.c index 7a067122..91613439 100644 --- a/src/update.c +++ b/src/update.c @@ -558,7 +558,7 @@ static int update_avr_verify(const PROGRAMMER *pgm, const AVRPART *p, const AVRM rc = avr_verify_mem(pgm, p, v, mem, size); if(rc < 0) { - pmsg_error("verification mismatch\n"); + pmsg_error("%s verification mismatch\n", mem->desc); led_set(pgm, LED_ERR); goto error; } @@ -602,10 +602,11 @@ static int update_mem_from_all(const UPDATE *upd, const AVRPART *p, const AVRMEM return size; } -static int update_all_from_file(const UPDATE *upd, const AVRPART *p, const AVRMEM *all, - const char *mem_desc, Filestats *fsp) { +static int update_all_from_file(const UPDATE *upd, const PROGRAMMER *pgm, const AVRPART *p, + const AVRMEM *all, const char *mem_desc, Filestats *fsp) { // On writing to the device trailing 0xff might be cut off - int op = upd->op == DEVICE_WRITE? FIO_READ: FIO_READ_FOR_VERIFY; + AVRMEM *sig; + int off, op = upd->op == DEVICE_WRITE? FIO_READ: FIO_READ_FOR_VERIFY; int allsize = fileio_mem(op, upd->filename, upd->format, p, all, -1); if(allsize < 0) { pmsg_error("reading from file %s failed\n", str_inname(upd->filename)); @@ -618,6 +619,22 @@ static int update_all_from_file(const UPDATE *upd, const AVRPART *p, const AVRME "verifying %d byte%s of %s against input file %s\n", fsp->nbytes, str_plural(fsp->nbytes), mem_desc, str_inname(upd->filename) ); + + if(!ovsigck) // Check part signature is sane as multi-file signature + if((sig = avr_locate_signature(p)) && sig->size > 0 && (off = fileio_mem_offset(p, sig)) >= 0) + if(off+sig->size <= all->size && is_memset(all->tags+off, TAG_ALLOCATED, sig->size)) + if(avr_read_mem(pgm, p, sig, NULL) == sig->size) + if(memcmp(sig->buf, all->buf+off, sig->size)) { // Uh-oh: multi-file is for another part + pmsg_error("signature of %s does not match file", p->desc); + char names[1024] = {0}; + (void) str_mcunames_signature(all->buf+off, names, sizeof names); + if(*names) + msg_error(" (%s)", names); + msg_error("\n"); + imsg_error("use -F to override this check\n"); + allsize = -1; + } + return allsize; } @@ -755,7 +772,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat case DEVICE_WRITE: // Write the selected device memory/ies using data from a file - if((allsize = update_all_from_file(upd, p, mem, mem_desc, &fs)) < 0) + if((allsize = update_all_from_file(upd, pgm, p, mem, mem_desc, &fs)) < 0) goto error; if(umemlist) { for(int i=0; i Date: Wed, 19 Jun 2024 21:46:09 +0100 Subject: [PATCH 176/422] Parent XMEGA parts from common family sub-group This commit makes the parent of XMEGA parts one of three common ones: - .xmega-ab for XMEGA-A or XMEGA-B parts - .xmega-cd for XMEGA-C or XMEGA-D parts - .xmega-e for XMEGA-E parts The commit does not change any feature of parts or memories. In order to prove this carry out before this commit $ avrdude -p */At >/tmp/1 After this commit, the following command should not have any output: $ avrdude -p */At | sort | comm -3 - /tmp/1 | grep -v family.common.values (The only feature changes in the .xmega-* prototypes.) --- src/avrdude.conf.in | 1803 ++++++++++++++++++++++++++++++------------- 1 file changed, 1257 insertions(+), 546 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index a638d038..00d18262 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -17262,12 +17262,12 @@ part parent "m645" # m6450p ; #------------------------------------------------------------ -# AVR XMEGA family common values +# AVR XMEGA-C/D family common values #------------------------------------------------------------ -part # .xmega - desc = "AVR XMEGA family common values"; - id = ".xmega"; +part # .xmega-cd + desc = "AVR XMEGA-C/D family common values"; + id = ".xmega-cd"; prog_modes = PM_SPM | PM_PDI; n_boot_sections = 1; mcu_base = 0x0090; @@ -17275,6 +17275,34 @@ part # .xmega autobaud_sync = 0x20; factory_fcpu = 2000000; + memory "eeprom" + page_size = 32; + offset = 0x8c0000; + readsize = 256; + ; + + memory "flash" + page_size = 256; + offset = 0x800000; + readsize = 256; + ; + + memory "application" + page_size = 256; + offset = 0x800000; + readsize = 256; + ; + + memory "apptable" + page_size = 256; + readsize = 256; + ; + + memory "boot" + page_size = 256; + readsize = 256; + ; + memory "fuse1" size = 1; initval = 0x00; @@ -17309,9 +17337,9 @@ part # .xmega ; memory "prodsig" - size = 50; + size = 64; offset = 0x8e0200; - readsize = 50; + readsize = 64; ; memory "sigrow" @@ -17323,6 +17351,13 @@ part # .xmega offset = 0x1000090; ; + memory "usersig" + size = 256; + page_size = 256; + offset = 0x8e0400; + readsize = 256; + ; + memory "io" size = 4096; readsize = 1; @@ -17339,26 +17374,58 @@ part # .xmega # Fuse for fault detection action on Px0..5 (unique to XMEGA-E) -part parent ".xmega" # .xmega-e +part parent ".xmega-cd" # .xmega-e desc = "AVR XMEGA-E family common values"; id = ".xmega-e"; + n_interrupts = 43; + + memory "flash" + page_size = 128; + ; + + memory "application" + page_size = 128; + ; + + memory "apptable" + page_size = 128; + ; + + memory "boot" + page_size = 128; + ; + + memory "fuse2" + bitmask = 0x43; + ; memory "fuse6" size = 1; initval = 0xff; offset = 0x8f0026; ; + + memory "prodsig" + size = 54; + readsize = 54; + ; + + memory "usersig" + size = 128; + page_size = 128; + ; ; #------------------------------------------------------------ -# AVR XMEGA-A family common values +# AVR XMEGA-A/B family common values #------------------------------------------------------------ -# JTAG user ID (unique to XMEGA-A and XMEGA-B) +# Most XMEGA-A/B have JTAG, and therefore JTAG user ID -part parent ".xmega" # .xmega-a - desc = "AVR XMEGA-A family common values"; - id = ".xmega-a"; +part parent ".xmega-cd" # .xmega-ab + desc = "AVR XMEGA-A/B family common values"; + id = ".xmega-ab"; + prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; memory "fuse0" size = 1; @@ -17367,15 +17434,21 @@ part parent ".xmega" # .xmega-a ; memory "fuse4" + initval = 0xfe; bitmask = 0x1f; ; + + memory "prodsig" + size = 52; + readsize = 52; + ; ; #------------------------------------------------------------ # ATxmega16A4U #------------------------------------------------------------ -part parent ".xmega-a" # x16a4u +part parent ".xmega-ab" # x16a4u desc = "ATxmega16A4U"; id = "x16a4u"; variants = @@ -17388,6 +17461,7 @@ part parent ".xmega-a" # x16a4u "ATxmega16A4U-M7: VQFN44, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16A4U-MH: QFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16A4U-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; + prog_modes = PM_SPM | PM_PDI; mcuid = 232; n_interrupts = 127; boot_section_size = 4096; @@ -17396,53 +17470,24 @@ part parent ".xmega-a" # x16a4u memory "eeprom" size = 1024; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x5000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x4000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 4096; - page_size = 256; offset = 0x803000; - readsize = 256; ; memory "boot" size = 4096; - page_size = 256; offset = 0x804000; - readsize = 256; - ; - - memory "fuse4" - initval = 0xfe; - ; - - memory "prodsig" - size = 52; - readsize = 52; - ; - - memory "usersig" - size = 256; - page_size = 256; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -17454,7 +17499,7 @@ part parent ".xmega-a" # x16a4u # ATxmega16C4 #------------------------------------------------------------ -part parent "x16a4u" # x16c4 +part parent ".xmega-cd" # x16c4 desc = "ATxmega16C4"; id = "x16c4"; variants = @@ -17467,19 +17512,39 @@ part parent "x16a4u" # x16c4 "ATxmega16C4-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16C4-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 233; + n_interrupts = 127; + boot_section_size = 4096; signature = 0x1e 0x94 0x43; + usbpid = 0x2fe3; - memory "fuse0" = NULL; + memory "eeprom" + size = 1024; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x5000; + ; + + memory "application" + size = 0x4000; + ; + + memory "apptable" + size = 4096; + offset = 0x803000; + ; + + memory "boot" + size = 4096; + offset = 0x804000; ; memory "prodsig" - size = 64; page_size = 64; - readsize = 64; + ; + + memory "sram" + size = 2048; ; ; @@ -17487,7 +17552,7 @@ part parent "x16a4u" # x16c4 # ATxmega16D4 #------------------------------------------------------------ -part parent "x16a4u" # x16d4 +part parent ".xmega-cd" # x16d4 desc = "ATxmega16D4"; id = "x16d4"; variants = @@ -17502,13 +17567,39 @@ part parent "x16a4u" # x16d4 "ATxmega16D4-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 234; n_interrupts = 91; + boot_section_size = 4096; signature = 0x1e 0x94 0x42; + usbpid = 0x2fe3; - memory "fuse0" = NULL; + memory "eeprom" + size = 1024; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x5000; + ; + + memory "application" + size = 0x4000; + ; + + memory "apptable" + size = 4096; + offset = 0x803000; + ; + + memory "boot" + size = 4096; + offset = 0x804000; + ; + + memory "prodsig" + size = 52; + readsize = 52; + ; + + memory "sram" + size = 2048; ; ; @@ -17516,7 +17607,7 @@ part parent "x16a4u" # x16d4 # ATxmega16A4 #------------------------------------------------------------ -part parent "x16a4u" # x16a4 +part parent ".xmega-ab" # x16a4 desc = "ATxmega16A4"; id = "x16a4"; variants = @@ -17528,19 +17619,49 @@ part parent "x16a4u" # x16a4 "ATxmega16A4-MH: QFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16A4-MHR: QFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16A4-MU: VQFN44, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; + prog_modes = PM_SPM | PM_PDI; mcuid = 231; n_interrupts = 94; + boot_section_size = 4096; + signature = 0x1e 0x94 0x41; + usbpid = 0x2fe3; + + memory "eeprom" + size = 1024; + ; + + memory "flash" + size = 0x5000; + ; + + memory "application" + size = 0x4000; + ; + + memory "apptable" + size = 4096; + offset = 0x803000; + ; + + memory "boot" + size = 4096; + offset = 0x804000; + ; memory "fuse2" bitmask = 0x43; ; + + memory "sram" + size = 2048; + ; ; #------------------------------------------------------------ # ATxmega32A4U #------------------------------------------------------------ -part parent ".xmega-a" # x32a4u +part parent ".xmega-ab" # x32a4u desc = "ATxmega32A4U"; id = "x32a4u"; variants = @@ -17553,6 +17674,7 @@ part parent ".xmega-a" # x32a4u "ATxmega32A4U-M7: VQFN44, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32A4U-MH: QFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32A4U-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; + prog_modes = PM_SPM | PM_PDI; mcuid = 239; n_interrupts = 127; boot_section_size = 4096; @@ -17561,53 +17683,24 @@ part parent ".xmega-a" # x32a4u memory "eeprom" size = 1024; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x9000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x8000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 4096; - page_size = 256; offset = 0x807000; - readsize = 256; ; memory "boot" size = 4096; - page_size = 256; offset = 0x808000; - readsize = 256; - ; - - memory "fuse4" - initval = 0xfe; - ; - - memory "prodsig" - size = 52; - readsize = 52; - ; - - memory "usersig" - size = 256; - page_size = 256; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -17619,7 +17712,7 @@ part parent ".xmega-a" # x32a4u # ATxmega32C4 #------------------------------------------------------------ -part parent "x32a4u" # x32c4 +part parent ".xmega-cd" # x32c4 desc = "ATxmega32C4"; id = "x32c4"; variants = @@ -17632,19 +17725,39 @@ part parent "x32a4u" # x32c4 "ATxmega32C4-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32C4-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 240; + n_interrupts = 127; + boot_section_size = 4096; signature = 0x1e 0x95 0x44; + usbpid = 0x2fe4; - memory "fuse0" = NULL; + memory "eeprom" + size = 1024; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x9000; + ; + + memory "application" + size = 0x8000; + ; + + memory "apptable" + size = 4096; + offset = 0x807000; + ; + + memory "boot" + size = 4096; + offset = 0x808000; ; memory "prodsig" - size = 64; page_size = 64; - readsize = 64; + ; + + memory "sram" + size = 4096; ; ; @@ -17652,7 +17765,7 @@ part parent "x32a4u" # x32c4 # ATxmega32D4 #------------------------------------------------------------ -part parent "x32a4u" # x32d4 +part parent ".xmega-cd" # x32d4 desc = "ATxmega32D4"; id = "x32d4"; variants = @@ -17668,13 +17781,39 @@ part parent "x32a4u" # x32d4 "ATxmega32D4-MHR: VQFN44, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 241; n_interrupts = 91; + boot_section_size = 4096; signature = 0x1e 0x95 0x42; + usbpid = 0x2fe4; - memory "fuse0" = NULL; + memory "eeprom" + size = 1024; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x9000; + ; + + memory "application" + size = 0x8000; + ; + + memory "apptable" + size = 4096; + offset = 0x807000; + ; + + memory "boot" + size = 4096; + offset = 0x808000; + ; + + memory "prodsig" + size = 52; + readsize = 52; + ; + + memory "sram" + size = 4096; ; ; @@ -17682,7 +17821,7 @@ part parent "x32a4u" # x32d4 # ATxmega32A4 #------------------------------------------------------------ -part parent "x32a4u" # x32a4 +part parent ".xmega-ab" # x32a4 desc = "ATxmega32A4"; id = "x32a4"; variants = @@ -17694,19 +17833,49 @@ part parent "x32a4u" # x32a4 "ATxmega32A4-MH: QFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32A4-MHR: QFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32A4-MU: VQFN44, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; + prog_modes = PM_SPM | PM_PDI; mcuid = 238; n_interrupts = 94; + boot_section_size = 4096; + signature = 0x1e 0x95 0x41; + usbpid = 0x2fe4; + + memory "eeprom" + size = 1024; + ; + + memory "flash" + size = 0x9000; + ; + + memory "application" + size = 0x8000; + ; + + memory "apptable" + size = 4096; + offset = 0x807000; + ; + + memory "boot" + size = 4096; + offset = 0x808000; + ; memory "fuse2" bitmask = 0x43; ; + + memory "sram" + size = 4096; + ; ; #------------------------------------------------------------ # ATxmega64A4U #------------------------------------------------------------ -part parent ".xmega-a" # x64a4u +part parent ".xmega-ab" # x64a4u desc = "ATxmega64A4U"; id = "x64a4u"; variants = @@ -17718,6 +17887,7 @@ part parent ".xmega-a" # x64a4u "ATxmega64A4U-M7: VQFN44PW, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64A4U-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64A4U-MHR: VQFN44, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; + prog_modes = PM_SPM | PM_PDI; mcuid = 252; n_interrupts = 127; boot_section_size = 4096; @@ -17726,41 +17896,24 @@ part parent ".xmega-a" # x64a4u memory "eeprom" size = 2048; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x11000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x10000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 4096; - page_size = 256; offset = 0x80f000; - readsize = 256; ; memory "boot" size = 4096; - page_size = 256; offset = 0x810000; - readsize = 256; - ; - - memory "fuse4" - initval = 0xfe; ; memory "prodsig" @@ -17769,13 +17922,6 @@ part parent ".xmega-a" # x64a4u readsize = 64; ; - memory "usersig" - size = 256; - page_size = 256; - offset = 0x8e0400; - readsize = 256; - ; - memory "sram" size = 4096; ; @@ -17785,7 +17931,7 @@ part parent ".xmega-a" # x64a4u # ATxmega32C3 #------------------------------------------------------------ -part parent "x32a4u" # x32c3 +part parent ".xmega-cd" # x32c3 desc = "ATxmega32C3"; id = "x32c3"; variants = @@ -17797,19 +17943,39 @@ part parent "x32a4u" # x32c3 "ATxmega32C3-MH: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32C3-MHR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 236; + n_interrupts = 127; + boot_section_size = 4096; signature = 0x1e 0x95 0x49; + usbpid = 0x2fe4; - memory "fuse0" = NULL; + memory "eeprom" + size = 1024; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x9000; + ; + + memory "application" + size = 0x8000; + ; + + memory "apptable" + size = 4096; + offset = 0x807000; + ; + + memory "boot" + size = 4096; + offset = 0x808000; ; memory "prodsig" - size = 64; page_size = 64; - readsize = 64; + ; + + memory "sram" + size = 4096; ; ; @@ -17817,7 +17983,7 @@ part parent "x32a4u" # x32c3 # ATxmega32D3 #------------------------------------------------------------ -part parent "x32a4u" # x32d3 +part parent ".xmega-cd" # x32d3 desc = "ATxmega32D3"; id = "x32d3"; variants = @@ -17830,13 +17996,39 @@ part parent "x32a4u" # x32d3 "ATxmega32D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 237; n_interrupts = 114; + boot_section_size = 4096; signature = 0x1e 0x95 0x4a; + usbpid = 0x2fe4; - memory "fuse0" = NULL; + memory "eeprom" + size = 1024; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x9000; + ; + + memory "application" + size = 0x8000; + ; + + memory "apptable" + size = 4096; + offset = 0x807000; + ; + + memory "boot" + size = 4096; + offset = 0x808000; + ; + + memory "prodsig" + size = 52; + readsize = 52; + ; + + memory "sram" + size = 4096; ; ; @@ -17844,7 +18036,7 @@ part parent "x32a4u" # x32d3 # ATxmega64C3 #------------------------------------------------------------ -part parent "x64a4u" # x64c3 +part parent ".xmega-cd" # x64c3 desc = "ATxmega64C3"; id = "x64c3"; variants = @@ -17856,14 +18048,39 @@ part parent "x64a4u" # x64c3 "ATxmega64C3-MH: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64C3-MHR: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 249; + n_interrupts = 127; + boot_section_size = 4096; signature = 0x1e 0x96 0x49; usbpid = 0x2fd6; - memory "fuse0" = NULL; + memory "eeprom" + size = 2048; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; + ; + + memory "prodsig" + page_size = 64; + ; + + memory "sram" + size = 4096; ; ; @@ -17871,7 +18088,7 @@ part parent "x64a4u" # x64c3 # ATxmega64D3 #------------------------------------------------------------ -part parent "x64a4u" # x64d3 +part parent ".xmega-cd" # x64d3 desc = "ATxmega64D3"; id = "x64d3"; variants = @@ -17885,27 +18102,47 @@ part parent "x64a4u" # x64d3 "ATxmega64D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 250; n_interrupts = 114; + boot_section_size = 4096; signature = 0x1e 0x96 0x4a; + usbpid = 0x2fe5; - memory "fuse0" = NULL; + memory "eeprom" + size = 2048; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; ; memory "prodsig" size = 52; - page_size = 1; readsize = 52; ; + + memory "sram" + size = 4096; + ; ; #------------------------------------------------------------ # ATxmega64D4 #------------------------------------------------------------ -part parent "x64a4u" # x64d4 +part parent ".xmega-cd" # x64d4 desc = "ATxmega64D4"; id = "x64d4"; variants = @@ -17919,13 +18156,38 @@ part parent "x64a4u" # x64d4 "ATxmega64D4-MHR: VQFN44, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 253; n_interrupts = 91; + boot_section_size = 4096; signature = 0x1e 0x96 0x47; + usbpid = 0x2fe5; - memory "fuse0" = NULL; + memory "eeprom" + size = 2048; + ; - memory "fuse4" - initval = 0xff; - bitmask = 0x1e; + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; + ; + + memory "prodsig" + page_size = 64; + ; + + memory "sram" + size = 4096; ; ; @@ -17933,7 +18195,7 @@ part parent "x64a4u" # x64d4 # ATxmega64A1 #------------------------------------------------------------ -part parent "x64a4u" # x64a1 +part parent ".xmega-ab" # x64a1 desc = "ATxmega64A1"; id = "x64a1"; variants = @@ -17944,19 +18206,40 @@ part parent "x64a4u" # x64a1 "ATxmega64A1-C7UR: VFBGA100, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]", "ATxmega64A1-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64A1-CUR: BGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; - prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; mcuid = 243; n_interrupts = 125; + boot_section_size = 4096; signature = 0x1e 0x96 0x4e; + usbpid = 0x2fe5; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; + ; memory "fuse2" bitmask = 0x43; ; - memory "prodsig" - size = 52; - page_size = 1; - readsize = 52; + memory "sram" + size = 4096; ; ; @@ -17964,7 +18247,7 @@ part parent "x64a4u" # x64a1 # ATxmega64A1U #------------------------------------------------------------ -part parent "x64a1" # x64a1u +part parent ".xmega-ab" # x64a1u desc = "ATxmega64A1U"; id = "x64a1u"; variants = @@ -17977,10 +18260,30 @@ part parent "x64a1" # x64a1u "ATxmega64A1U-CUR: TFBGA100, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 244; n_interrupts = 127; + boot_section_size = 4096; + signature = 0x1e 0x96 0x4e; usbpid = 0x2fe8; - memory "fuse2" - bitmask = 0x63; + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; ; memory "prodsig" @@ -17988,13 +18291,17 @@ part parent "x64a1" # x64a1u page_size = 64; readsize = 64; ; + + memory "sram" + size = 4096; + ; ; #------------------------------------------------------------ # ATxmega64A3 #------------------------------------------------------------ -part parent "x64a1" # x64a3 +part parent ".xmega-ab" # x64a3 desc = "ATxmega64A3"; id = "x64a3"; variants = @@ -18006,14 +18313,46 @@ part parent "x64a1" # x64a3 "ATxmega64A3-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 246; n_interrupts = 122; + boot_section_size = 4096; signature = 0x1e 0x96 0x42; + usbpid = 0x2fe5; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; + ; + + memory "fuse2" + bitmask = 0x43; + ; + + memory "sram" + size = 4096; + ; ; #------------------------------------------------------------ # ATxmega64A3U #------------------------------------------------------------ -part parent "x64a1" # x64a3u +part parent ".xmega-ab" # x64a3u desc = "ATxmega64A3U"; id = "x64a3u"; variants = @@ -18025,10 +18364,34 @@ part parent "x64a1" # x64a3u "ATxmega64A3U-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 247; n_interrupts = 127; + boot_section_size = 4096; signature = 0x1e 0x96 0x42; + usbpid = 0x2fe5; - memory "fuse2" - bitmask = 0x63; + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; + ; + + memory "sram" + size = 4096; ; ; @@ -18036,13 +18399,38 @@ part parent "x64a1" # x64a3u # ATxmega64A4 #------------------------------------------------------------ -part parent "x64a1" # x64a4 +part parent ".xmega-ab" # x64a4 desc = "ATxmega64A4"; id = "x64a4"; variants = "ATxmega64A4: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 251; + n_interrupts = 125; + boot_section_size = 4096; signature = 0x1e 0x96 0x46; + usbpid = 0x2fe5; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; + ; memory "fuse0" initval = -1; @@ -18070,13 +18458,17 @@ part parent "x64a1" # x64a4 memory "lock" initval = -1; ; + + memory "sram" + size = 4096; + ; ; #------------------------------------------------------------ # ATxmega64B1 #------------------------------------------------------------ -part parent "x64a1" # x64b1 +part parent ".xmega-ab" # x64b1 desc = "ATxmega64B1"; id = "x64b1"; variants = @@ -18086,23 +18478,46 @@ part parent "x64a1" # x64b1 "ATxmega64B1-CUR: TQFP100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 245; n_interrupts = 81; + boot_section_size = 4096; signature = 0x1e 0x96 0x52; usbpid = 0x2fe1; - memory "fuse2" - bitmask = 0x63; + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; ; memory "fuse4" initval = 0xff; ; + + memory "sram" + size = 4096; + ; ; #------------------------------------------------------------ # ATxmega64B3 #------------------------------------------------------------ -part parent "x64a1" # x64b3 +part parent ".xmega-ab" # x64b3 desc = "ATxmega64B3"; id = "x64b3"; variants = @@ -18111,23 +18526,46 @@ part parent "x64a1" # x64b3 "ATxmega64B3-MH: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 248; n_interrupts = 54; + boot_section_size = 4096; signature = 0x1e 0x96 0x51; usbpid = 0x2fdf; - memory "fuse2" - bitmask = 0x63; + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x11000; + ; + + memory "application" + size = 0x10000; + ; + + memory "apptable" + size = 4096; + offset = 0x80f000; + ; + + memory "boot" + size = 4096; + offset = 0x810000; ; memory "fuse4" initval = 0xff; ; + + memory "sram" + size = 4096; + ; ; #------------------------------------------------------------ # ATxmega128C3 #------------------------------------------------------------ -part parent ".xmega" # x128c3 +part parent ".xmega-cd" # x128c3 desc = "ATxmega128C3"; id = "x128c3"; variants = @@ -18145,50 +18583,37 @@ part parent ".xmega" # x128c3 memory "eeprom" size = 2048; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x22000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x20000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 8192; page_size = 512; offset = 0x81e000; - readsize = 256; ; memory "boot" size = 8192; page_size = 512; offset = 0x820000; - readsize = 256; ; memory "prodsig" - size = 64; page_size = 64; - readsize = 64; ; memory "usersig" size = 512; page_size = 512; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -18200,7 +18625,7 @@ part parent ".xmega" # x128c3 # ATxmega128D3 #------------------------------------------------------------ -part parent "x128c3" # x128d3 +part parent ".xmega-cd" # x128d3 desc = "ATxmega128D3"; id = "x128d3"; variants = @@ -18213,20 +18638,56 @@ part parent "x128c3" # x128d3 "ATxmega128D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 262; n_interrupts = 114; + boot_section_size = 8192; signature = 0x1e 0x97 0x48; + usbpid = 0x2fd7; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x22000; + page_size = 512; + ; + + memory "application" + size = 0x20000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x81e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x820000; + ; memory "prodsig" size = 52; - page_size = 1; readsize = 52; ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 8192; + ; ; #------------------------------------------------------------ # ATxmega128D4 #------------------------------------------------------------ -part parent "x128c3" # x128d4 +part parent ".xmega-cd" # x128d4 desc = "ATxmega128D4"; id = "x128d4"; variants = @@ -18240,10 +18701,46 @@ part parent "x128c3" # x128d4 "ATxmega128D4-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 265; n_interrupts = 91; + boot_section_size = 8192; signature = 0x1e 0x97 0x47; + usbpid = 0x2fd7; + + memory "eeprom" + size = 2048; + ; memory "flash" - page_size = 256; + size = 0x22000; + ; + + memory "application" + size = 0x20000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x81e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x820000; + ; + + memory "prodsig" + page_size = 64; + ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 8192; ; ; @@ -18251,7 +18748,7 @@ part parent "x128c3" # x128d4 # ATxmega128A1 #------------------------------------------------------------ -part parent "x128c3" # x128a1 +part parent ".xmega-ab" # x128a1 desc = "ATxmega128A1"; id = "x128a1"; variants = @@ -18262,30 +18759,49 @@ part parent "x128c3" # x128a1 "ATxmega128A1-C7UR: VFBGA100, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]", "ATxmega128A1-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128A1-CUR: BGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; - prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; mcuid = 254; n_interrupts = 125; + boot_section_size = 8192; signature = 0x1e 0x97 0x4c; + usbpid = 0x2fd7; - memory "fuse0" - size = 1; - initval = 0xff; - offset = 0x8f0020; + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x22000; + page_size = 512; + ; + + memory "application" + size = 0x20000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x81e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x820000; ; memory "fuse2" bitmask = 0x43; ; - memory "fuse4" - initval = 0xfe; - bitmask = 0x1f; + memory "usersig" + size = 512; + page_size = 512; ; - memory "prodsig" - size = 52; - page_size = 1; - readsize = 52; + memory "sram" + size = 8192; ; ; @@ -18304,7 +18820,7 @@ part parent "x128a1" # x128a1d # ATxmega128A1U #------------------------------------------------------------ -part parent "x128a1" # x128a1u +part parent ".xmega-ab" # x128a1u desc = "ATxmega128A1U"; id = "x128a1u"; variants = @@ -18318,10 +18834,34 @@ part parent "x128a1" # x128a1u "ATxmega128A1U-CUR: CBGA100, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 256; n_interrupts = 127; + boot_section_size = 8192; + signature = 0x1e 0x97 0x4c; usbpid = 0x2fed; - memory "fuse2" - bitmask = 0x63; + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x22000; + page_size = 512; + ; + + memory "application" + size = 0x20000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x81e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x820000; ; memory "prodsig" @@ -18329,13 +18869,22 @@ part parent "x128a1" # x128a1u page_size = 64; readsize = 64; ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 8192; + ; ; #------------------------------------------------------------ # ATxmega128A3 #------------------------------------------------------------ -part parent "x128a1" # x128a3 +part parent ".xmega-ab" # x128a3 desc = "ATxmega128A3"; id = "x128a3"; variants = @@ -18347,14 +18896,55 @@ part parent "x128a1" # x128a3 "ATxmega128A3-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 258; n_interrupts = 122; + boot_section_size = 8192; signature = 0x1e 0x97 0x42; + usbpid = 0x2fd7; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x22000; + page_size = 512; + ; + + memory "application" + size = 0x20000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x81e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x820000; + ; + + memory "fuse2" + bitmask = 0x43; + ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 8192; + ; ; #------------------------------------------------------------ # ATxmega128A3U #------------------------------------------------------------ -part parent "x128a1" # x128a3u +part parent ".xmega-ab" # x128a3u desc = "ATxmega128A3U"; id = "x128a3u"; variants = @@ -18366,11 +18956,43 @@ part parent "x128a1" # x128a3u "ATxmega128A3U-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 259; n_interrupts = 127; + boot_section_size = 8192; signature = 0x1e 0x97 0x42; usbpid = 0x2fe6; - memory "fuse2" - bitmask = 0x63; + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x22000; + page_size = 512; + ; + + memory "application" + size = 0x20000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x81e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x820000; + ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 8192; ; ; @@ -18378,53 +19000,42 @@ part parent "x128a1" # x128a3u # ATxmega128A4 #------------------------------------------------------------ -part parent ".xmega" # x128a4 +part parent ".xmega-ab" # x128a4 desc = "ATxmega128A4"; id = "x128a4"; variants = "ATxmega128A4: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; - prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; mcuid = 263; signature = 0x1e 0x97 0x46; memory "eeprom" size = 2048; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x22000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x20000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 4096; page_size = 512; offset = 0x81f000; - readsize = 256; ; memory "boot" size = 8192; page_size = 512; offset = 0x820000; - readsize = 256; ; memory "fuse0" - size = 1; - offset = 0x8f0020; + initval = -1; ; memory "fuse1" @@ -18450,11 +19061,14 @@ part parent ".xmega" # x128a4 initval = -1; ; + memory "prodsig" + size = 50; + readsize = 50; + ; + memory "usersig" size = 512; page_size = 512; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -18466,7 +19080,7 @@ part parent ".xmega" # x128a4 # ATxmega128A4U #------------------------------------------------------------ -part parent ".xmega-a" # x128a4u +part parent ".xmega-ab" # x128a4u desc = "ATxmega128A4U"; id = "x128a4u"; variants = @@ -18477,6 +19091,7 @@ part parent ".xmega-a" # x128a4u "ATxmega128A4U-M7: VQFN44PW, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128A4U-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128A4U-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; + prog_modes = PM_SPM | PM_PDI; mcuid = 264; n_interrupts = 127; boot_section_size = 8192; @@ -18485,41 +19100,24 @@ part parent ".xmega-a" # x128a4u memory "eeprom" size = 2048; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x22000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x20000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 4096; - page_size = 256; offset = 0x81f000; - readsize = 256; ; memory "boot" size = 8192; - page_size = 256; offset = 0x820000; - readsize = 256; - ; - - memory "fuse4" - initval = 0xfe; ; memory "prodsig" @@ -18528,13 +19126,6 @@ part parent ".xmega-a" # x128a4u readsize = 64; ; - memory "usersig" - size = 256; - page_size = 256; - offset = 0x8e0400; - readsize = 256; - ; - memory "sram" size = 8192; ; @@ -18544,7 +19135,7 @@ part parent ".xmega-a" # x128a4u # ATxmega128B1 #------------------------------------------------------------ -part parent ".xmega" # x128b1 +part parent ".xmega-ab" # x128b1 desc = "ATxmega128B1"; id = "x128b1"; variants = @@ -18553,7 +19144,6 @@ part parent ".xmega" # x128b1 "ATxmega128B1-AUR: TQFP100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128B1-CU: VFBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128B1-CUR: TFBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; - prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; mcuid = 257; n_interrupts = 81; boot_section_size = 8192; @@ -18562,59 +19152,28 @@ part parent ".xmega" # x128b1 memory "eeprom" size = 2048; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x22000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x20000; - page_size = 256; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 8192; - page_size = 256; offset = 0x81e000; - readsize = 256; ; memory "boot" size = 8192; - page_size = 256; offset = 0x820000; - readsize = 256; - ; - - memory "fuse0" - size = 1; - initval = 0xff; - offset = 0x8f0020; ; memory "fuse4" - bitmask = 0x1f; - ; - - memory "prodsig" - size = 52; - readsize = 52; - ; - - memory "usersig" - size = 256; - page_size = 256; - offset = 0x8e0400; - readsize = 256; + initval = 0xff; ; memory "sram" @@ -18626,7 +19185,7 @@ part parent ".xmega" # x128b1 # ATxmega128B3 #------------------------------------------------------------ -part parent "x128b1" # x128b3 +part parent ".xmega-ab" # x128b3 desc = "ATxmega128B3"; id = "x128b3"; variants = @@ -18638,15 +19197,46 @@ part parent "x128b1" # x128b3 "ATxmega128B3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 260; n_interrupts = 54; + boot_section_size = 8192; signature = 0x1e 0x97 0x4b; usbpid = 0x2fe0; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x22000; + ; + + memory "application" + size = 0x20000; + ; + + memory "apptable" + size = 8192; + offset = 0x81e000; + ; + + memory "boot" + size = 8192; + offset = 0x820000; + ; + + memory "fuse4" + initval = 0xff; + ; + + memory "sram" + size = 8192; + ; ; #------------------------------------------------------------ # ATxmega192C3 #------------------------------------------------------------ -part parent ".xmega" # x192c3 +part parent ".xmega-cd" # x192c3 desc = "ATxmega192C3"; id = "x192c3"; variants = @@ -18663,50 +19253,37 @@ part parent ".xmega" # x192c3 memory "eeprom" size = 2048; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x32000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x30000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 8192; page_size = 512; offset = 0x82e000; - readsize = 256; ; memory "boot" size = 8192; page_size = 512; offset = 0x830000; - readsize = 256; ; memory "prodsig" - size = 64; page_size = 64; - readsize = 64; ; memory "usersig" size = 512; page_size = 512; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -18718,7 +19295,7 @@ part parent ".xmega" # x192c3 # ATxmega192D3 #------------------------------------------------------------ -part parent "x192c3" # x192d3 +part parent ".xmega-cd" # x192d3 desc = "ATxmega192D3"; id = "x192d3"; variants = @@ -18731,32 +19308,97 @@ part parent "x192c3" # x192d3 "ATxmega192D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 270; n_interrupts = 114; + boot_section_size = 8192; signature = 0x1e 0x97 0x49; +# usbpid = 0x2f??; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x32000; + page_size = 512; + ; + + memory "application" + size = 0x30000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x82e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x830000; + ; + memory "prodsig" size = 52; - page_size = 1; readsize = 52; ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 0x4000; + ; ; #------------------------------------------------------------ # ATxmega192A1 #------------------------------------------------------------ -part parent "x192c3" # x192a1 +part parent ".xmega-ab" # x192a1 desc = "ATxmega192A1"; id = "x192a1"; variants = "ATxmega192A1-AU: TQFP100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega192A1-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; - prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; mcuid = 266; + n_interrupts = 127; + boot_section_size = 8192; signature = 0x1e 0x97 0x4e; +# usbpid = 0x2f??; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x32000; + page_size = 512; + ; + + memory "application" + size = 0x30000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x82e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x830000; + ; + memory "fuse0" - size = 1; - offset = 0x8f0020; + initval = -1; ; memory "fuse1" @@ -18781,13 +19423,28 @@ part parent "x192c3" # x192a1 memory "lock" initval = -1; ; + + memory "prodsig" + size = 64; + page_size = 64; + readsize = 64; + ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 0x4000; + ; ; #------------------------------------------------------------ # ATxmega192A3 #------------------------------------------------------------ -part parent "x192c3" # x192a3 +part parent ".xmega-ab" # x192a3 desc = "ATxmega192A3"; id = "x192a3"; variants = @@ -18797,30 +19454,50 @@ part parent "x192c3" # x192a3 "ATxmega192A3-MH: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega192A3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega192A3-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; - prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; mcuid = 267; n_interrupts = 122; + boot_section_size = 8192; signature = 0x1e 0x97 0x44; - memory "fuse0" - size = 1; - initval = 0xff; - offset = 0x8f0020; +# usbpid = 0x2f??; + + memory "eeprom" + size = 2048; + ; + + memory "flash" + size = 0x32000; + page_size = 512; + ; + + memory "application" + size = 0x30000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x82e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x830000; ; memory "fuse2" bitmask = 0x43; ; - memory "fuse4" - initval = 0xfe; - bitmask = 0x1f; + memory "usersig" + size = 512; + page_size = 512; ; - memory "prodsig" - size = 52; - page_size = 1; - readsize = 52; + memory "sram" + size = 0x4000; ; ; @@ -18828,7 +19505,7 @@ part parent "x192c3" # x192a3 # ATxmega192A3U #------------------------------------------------------------ -part parent "x192a1" # x192a3u +part parent ".xmega-ab" # x192a3u desc = "ATxmega192A3U"; id = "x192a3u"; variants = @@ -18840,40 +19517,46 @@ part parent "x192a1" # x192a3u "ATxmega192A3U-MHR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", "ATxmega192A3U-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 268; + n_interrupts = 127; + boot_section_size = 8192; signature = 0x1e 0x97 0x44; usbpid = 0x2fe7; - memory "fuse0" - initval = 0xff; +# usbpid = 0x2f??; + + memory "eeprom" + size = 2048; ; - memory "fuse1" - initval = 0x00; + memory "flash" + size = 0x32000; + page_size = 512; ; - memory "fuse2" - initval = 0xff; - bitmask = 0x63; + memory "application" + size = 0x30000; + page_size = 512; ; - memory "fuse4" - initval = 0xfe; - bitmask = 0x1f; + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x82e000; ; - memory "fuse5" - initval = 0xff; - bitmask = 0x3f; + memory "boot" + size = 8192; + page_size = 512; + offset = 0x830000; ; - memory "lock" - initval = 0xff; + memory "usersig" + size = 512; + page_size = 512; ; - memory "prodsig" - size = 52; - page_size = 1; - readsize = 52; + memory "sram" + size = 0x4000; ; ; @@ -18881,7 +19564,7 @@ part parent "x192a1" # x192a3u # ATxmega256C3 #------------------------------------------------------------ -part parent ".xmega" # x256c3 +part parent ".xmega-cd" # x256c3 desc = "ATxmega256C3"; id = "x256c3"; variants = @@ -18899,50 +19582,37 @@ part parent ".xmega" # x256c3 memory "eeprom" size = 4096; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x42000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x40000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 8192; page_size = 512; offset = 0x83e000; - readsize = 256; ; memory "boot" size = 8192; page_size = 512; offset = 0x840000; - readsize = 256; ; memory "prodsig" - size = 64; page_size = 64; - readsize = 64; ; memory "usersig" size = 512; page_size = 512; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -18954,7 +19624,7 @@ part parent ".xmega" # x256c3 # ATxmega256D3 #------------------------------------------------------------ -part parent "x256c3" # x256d3 +part parent ".xmega-cd" # x256d3 desc = "ATxmega256D3"; id = "x256d3"; variants = @@ -18967,31 +19637,95 @@ part parent "x256c3" # x256d3 "ATxmega256D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 277; n_interrupts = 114; + boot_section_size = 8192; signature = 0x1e 0x98 0x44; + usbpid = 0x2fda; + + memory "eeprom" + size = 4096; + ; + + memory "flash" + size = 0x42000; + page_size = 512; + ; + + memory "application" + size = 0x40000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x83e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x840000; + ; memory "prodsig" size = 52; - page_size = 1; readsize = 52; ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 0x4000; + ; ; #------------------------------------------------------------ # ATxmega256A1 #------------------------------------------------------------ -part parent "x256c3" # x256a1 +part parent ".xmega-ab" # x256a1 desc = "ATxmega256A1"; id = "x256a1"; variants = "ATxmega256A1-AU: TQFP100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256A1-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; - prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; mcuid = 271; + n_interrupts = 127; + boot_section_size = 8192; + signature = 0x1e 0x98 0x46; + usbpid = 0x2fda; + + memory "eeprom" + size = 4096; + ; + + memory "flash" + size = 0x42000; + page_size = 512; + ; + + memory "application" + size = 0x40000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x83e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x840000; + ; memory "fuse0" - size = 1; - offset = 0x8f0020; + initval = -1; ; memory "fuse1" @@ -19016,13 +19750,28 @@ part parent "x256c3" # x256a1 memory "lock" initval = -1; ; + + memory "prodsig" + size = 64; + page_size = 64; + readsize = 64; + ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 0x4000; + ; ; #------------------------------------------------------------ # ATxmega256A3 #------------------------------------------------------------ -part parent "x256a1" # x256a3 +part parent ".xmega-ab" # x256a3 desc = "ATxmega256A3"; id = "x256a3"; variants = @@ -19034,39 +19783,47 @@ part parent "x256a1" # x256a3 "ATxmega256A3-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 272; n_interrupts = 122; + boot_section_size = 8192; signature = 0x1e 0x98 0x42; + usbpid = 0x2fda; - memory "fuse0" - initval = 0xff; + memory "eeprom" + size = 4096; ; - memory "fuse1" - initval = 0x00; + memory "flash" + size = 0x42000; + page_size = 512; + ; + + memory "application" + size = 0x40000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x83e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x840000; ; memory "fuse2" - initval = 0xff; bitmask = 0x43; ; - memory "fuse4" - initval = 0xfe; - bitmask = 0x1f; + memory "usersig" + size = 512; + page_size = 512; ; - memory "fuse5" - initval = 0xff; - bitmask = 0x3f; - ; - - memory "lock" - initval = 0xff; - ; - - memory "prodsig" - size = 52; - page_size = 1; - readsize = 52; + memory "sram" + size = 0x4000; ; ; @@ -19074,7 +19831,7 @@ part parent "x256a1" # x256a3 # ATxmega256A3U #------------------------------------------------------------ -part parent "x256a1" # x256a3u +part parent ".xmega-ab" # x256a3u desc = "ATxmega256A3U"; id = "x256a3u"; variants = @@ -19086,40 +19843,44 @@ part parent "x256a1" # x256a3u "ATxmega256A3U-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256A3U-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 275; + n_interrupts = 127; + boot_section_size = 8192; signature = 0x1e 0x98 0x42; usbpid = 0x2fec; - memory "fuse0" - initval = 0xff; + memory "eeprom" + size = 4096; ; - memory "fuse1" - initval = 0x00; + memory "flash" + size = 0x42000; + page_size = 512; ; - memory "fuse2" - initval = 0xff; - bitmask = 0x63; + memory "application" + size = 0x40000; + page_size = 512; ; - memory "fuse4" - initval = 0xfe; - bitmask = 0x1f; + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x83e000; ; - memory "fuse5" - initval = 0xff; - bitmask = 0x3f; + memory "boot" + size = 8192; + page_size = 512; + offset = 0x840000; ; - memory "lock" - initval = 0xff; + memory "usersig" + size = 512; + page_size = 512; ; - memory "prodsig" - size = 52; - page_size = 1; - readsize = 52; + memory "sram" + size = 0x4000; ; ; @@ -19127,7 +19888,7 @@ part parent "x256a1" # x256a3u # ATxmega256A3B #------------------------------------------------------------ -part parent "x256a1" # x256a3b +part parent ".xmega-ab" # x256a3b desc = "ATxmega256A3B"; id = "x256a3b"; variants = @@ -19138,39 +19899,47 @@ part parent "x256a1" # x256a3b "ATxmega256A3B-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 273; n_interrupts = 122; + boot_section_size = 8192; signature = 0x1e 0x98 0x43; + usbpid = 0x2fda; - memory "fuse0" - initval = 0xff; + memory "eeprom" + size = 4096; ; - memory "fuse1" - initval = 0x00; + memory "flash" + size = 0x42000; + page_size = 512; + ; + + memory "application" + size = 0x40000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x83e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x840000; ; memory "fuse2" - initval = 0xff; bitmask = 0x43; ; - memory "fuse4" - initval = 0xfe; - bitmask = 0x1f; + memory "usersig" + size = 512; + page_size = 512; ; - memory "fuse5" - initval = 0xff; - bitmask = 0x3f; - ; - - memory "lock" - initval = 0xff; - ; - - memory "prodsig" - size = 52; - page_size = 1; - readsize = 52; + memory "sram" + size = 0x4000; ; ; @@ -19178,7 +19947,7 @@ part parent "x256a1" # x256a3b # ATxmega256A3BU #------------------------------------------------------------ -part parent "x256a1" # x256a3bu +part parent ".xmega-ab" # x256a3bu desc = "ATxmega256A3BU"; id = "x256a3bu"; variants = @@ -19187,40 +19956,44 @@ part parent "x256a1" # x256a3bu "ATxmega256A3BU-MH: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256A3BU-MHR: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 274; + n_interrupts = 127; + boot_section_size = 8192; signature = 0x1e 0x98 0x43; usbpid = 0x2fe2; - memory "fuse0" - initval = 0xff; + memory "eeprom" + size = 4096; ; - memory "fuse1" - initval = 0x00; + memory "flash" + size = 0x42000; + page_size = 512; ; - memory "fuse2" - initval = 0xff; - bitmask = 0x63; + memory "application" + size = 0x40000; + page_size = 512; ; - memory "fuse4" - initval = 0xfe; - bitmask = 0x1f; + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x83e000; ; - memory "fuse5" - initval = 0xff; - bitmask = 0x3f; + memory "boot" + size = 8192; + page_size = 512; + offset = 0x840000; ; - memory "lock" - initval = 0xff; + memory "usersig" + size = 512; + page_size = 512; ; - memory "prodsig" - size = 52; - page_size = 1; - readsize = 52; + memory "sram" + size = 0x4000; ; ; @@ -19228,7 +20001,7 @@ part parent "x256a1" # x256a3bu # ATxmega384C3 #------------------------------------------------------------ -part parent ".xmega" # x384c3 +part parent ".xmega-cd" # x384c3 desc = "ATxmega384C3"; id = "x384c3"; variants = @@ -19246,50 +20019,37 @@ part parent ".xmega" # x384c3 memory "eeprom" size = 4096; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x62000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x60000; page_size = 512; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 8192; page_size = 512; offset = 0x85e000; - readsize = 256; ; memory "boot" size = 8192; page_size = 512; offset = 0x860000; - readsize = 256; ; memory "prodsig" - size = 64; page_size = 64; - readsize = 64; ; memory "usersig" size = 512; page_size = 512; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -19301,7 +20061,7 @@ part parent ".xmega" # x384c3 # ATxmega384D3 #------------------------------------------------------------ -part parent "x384c3" # x384d3 +part parent ".xmega-cd" # x384d3 desc = "ATxmega384D3"; id = "x384d3"; variants = @@ -19312,7 +20072,48 @@ part parent "x384c3" # x384d3 "ATxmega384D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 279; n_interrupts = 114; + boot_section_size = 8192; signature = 0x1e 0x98 0x47; + usbpid = 0x2fdb; + + memory "eeprom" + size = 4096; + ; + + memory "flash" + size = 0x62000; + page_size = 512; + ; + + memory "application" + size = 0x60000; + page_size = 512; + ; + + memory "apptable" + size = 8192; + page_size = 512; + offset = 0x85e000; + ; + + memory "boot" + size = 8192; + page_size = 512; + offset = 0x860000; + ; + + memory "prodsig" + page_size = 64; + ; + + memory "usersig" + size = 512; + page_size = 512; + ; + + memory "sram" + size = 0x8000; + ; ; #------------------------------------------------------------ @@ -19335,59 +20136,29 @@ part parent ".xmega-e" # x8e5 "ATxmega8E5-MU: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega8E5-MUR: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 230; - n_interrupts = 43; boot_section_size = 2048; signature = 0x1e 0x93 0x41; memory "eeprom" size = 512; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x2800; - page_size = 128; - offset = 0x800000; - readsize = 256; ; memory "application" size = 8192; - page_size = 128; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 2048; - page_size = 128; offset = 0x801800; - readsize = 256; ; memory "boot" size = 2048; - page_size = 128; offset = 0x802000; - readsize = 256; - ; - - memory "fuse2" - bitmask = 0x43; - ; - - memory "prodsig" - size = 54; - readsize = 54; - ; - - memory "usersig" - size = 128; - page_size = 128; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -19415,59 +20186,29 @@ part parent ".xmega-e" # x16e5 "ATxmega16E5-MU: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16E5-MUR: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 235; - n_interrupts = 43; boot_section_size = 4096; signature = 0x1e 0x94 0x45; memory "eeprom" size = 512; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x5000; - page_size = 128; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x4000; - page_size = 128; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 4096; - page_size = 128; offset = 0x803000; - readsize = 256; ; memory "boot" size = 4096; - page_size = 128; offset = 0x804000; - readsize = 256; - ; - - memory "fuse2" - bitmask = 0x43; - ; - - memory "prodsig" - size = 54; - readsize = 54; - ; - - memory "usersig" - size = 128; - page_size = 128; - offset = 0x8e0400; - readsize = 256; ; memory "sram" @@ -19495,59 +20236,29 @@ part parent ".xmega-e" # x32e5 "ATxmega32E5-MU: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32E5-MUR: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 242; - n_interrupts = 43; boot_section_size = 4096; signature = 0x1e 0x95 0x4c; memory "eeprom" size = 1024; - page_size = 32; - offset = 0x8c0000; - readsize = 256; ; memory "flash" size = 0x9000; - page_size = 128; - offset = 0x800000; - readsize = 256; ; memory "application" size = 0x8000; - page_size = 128; - offset = 0x800000; - readsize = 256; ; memory "apptable" size = 4096; - page_size = 128; offset = 0x807000; - readsize = 256; ; memory "boot" size = 4096; - page_size = 128; offset = 0x808000; - readsize = 256; - ; - - memory "fuse2" - bitmask = 0x43; - ; - - memory "prodsig" - size = 54; - readsize = 54; - ; - - memory "usersig" - size = 128; - page_size = 128; - offset = 0x8e0400; - readsize = 256; ; memory "sram" From 9576aec26af3278f68255e07c42a7e2d3e7ecd34 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 19 Jun 2024 21:57:35 +0100 Subject: [PATCH 177/422] Fix boot_section_size of ATxmega128A4 --- src/avrdude.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 00d18262..45d023e3 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -19006,6 +19006,7 @@ part parent ".xmega-ab" # x128a4 variants = "ATxmega128A4: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 263; + boot_section_size = 8192; signature = 0x1e 0x97 0x46; memory "eeprom" From 5d322eb9dc4a3e16618162918a5dfa8b1d418e55 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 19 Jun 2024 22:09:25 +0100 Subject: [PATCH 178/422] Add calibration, sernum and tempsense sub-memories to XMEGAs --- src/avrdude.conf.in | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 45d023e3..73f78feb 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -17351,6 +17351,21 @@ part # .xmega-cd offset = 0x1000090; ; + memory "calibration" + size = 5; + offset = 0x8e0200; + ; + + memory "tempsense" + size = 2; + offset = 0x8e022e; + ; + + memory "sernum" + size = 14; + offset = 0x8e0208; + ; + memory "usersig" size = 256; page_size = 256; @@ -17442,6 +17457,10 @@ part parent ".xmega-cd" # .xmega-ab size = 52; readsize = 52; ; + + memory "calibration" + size = 4; + ; ; #------------------------------------------------------------ @@ -18508,6 +18527,10 @@ part parent ".xmega-ab" # x64b1 initval = 0xff; ; + memory "calibration" + size = 5; + ; + memory "sram" size = 4096; ; @@ -18556,6 +18579,10 @@ part parent ".xmega-ab" # x64b3 initval = 0xff; ; + memory "calibration" + size = 5; + ; + memory "sram" size = 4096; ; @@ -19177,6 +19204,10 @@ part parent ".xmega-ab" # x128b1 initval = 0xff; ; + memory "calibration" + size = 5; + ; + memory "sram" size = 8192; ; @@ -19228,6 +19259,10 @@ part parent ".xmega-ab" # x128b3 initval = 0xff; ; + memory "calibration" + size = 5; + ; + memory "sram" size = 8192; ; From 2373b0a06c6c93ecb1f20a1b3750aa703050d37e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 20 Jun 2024 00:06:25 +0100 Subject: [PATCH 179/422] Fix access for XMEGA sernum and tempsense --- src/stk500v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stk500v2.c b/src/stk500v2.c index 70256677..e69ad7e6 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -4496,7 +4496,7 @@ static int stk600_xprog_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const b[1] = XPRG_MEM_TYPE_FUSE; } else if (mem_is_lock(mem)) { b[1] = XPRG_MEM_TYPE_LOCKBITS; - } else if (mem_is_calibration(mem) || mem_is_sigrow(mem)) { + } else if (mem_is_calibration(mem) || mem_is_in_sigrow(mem)) { b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION; } else if (mem_is_userrow(mem)) { b[1] = XPRG_MEM_TYPE_USERSIG; From 06b64bf9fbfb1bca953825c420c99f0a98792bd2 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 21 Jun 2024 21:40:02 +0100 Subject: [PATCH 180/422] Provide ALL memory (all + sub-memories excluded from all) --- src/update.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/update.c b/src/update.c index 91613439..1934c51e 100644 --- a/src/update.c +++ b/src/update.c @@ -272,13 +272,17 @@ static void ioerror(const char *iotype, const UPDATE *upd) { msg_ext_error("\n"); } +// Whether a memory should be returned for ALL: exclude IO/SRAM +static int is_interesting_mem(const AVRPART *p, const AVRMEM *mem) { + return !(mem_is_io(mem) || mem_is_sram(mem)); +} + // Whether a memory should be backup-ed: exclude sub-memories static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { return mem_is_in_flash(mem)? mem_is_flash(mem): mem_is_in_sigrow(mem)? mem_is_sigrow(mem): mem_is_in_fuses(mem)? mem_is_fuses(mem) || !avr_locate_fuses(p): - mem_is_io(mem)? 0: - !mem_is_sram(mem); + is_interesting_mem(p, mem); } /* @@ -316,7 +320,11 @@ static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rw if(e) *e = 0; s = str_trim(s); - if(str_eq(s, "all") || str_eq(s, "etc")) { + if(str_eq(s, "ALL")) { + for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) + if(is_interesting_mem(p, (m = ldata(lm)))) + umemlist[nm++] = m; + } else if(str_eq(s, "all") || str_eq(s, "etc")) { for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) if(is_backup_mem(p, (m = ldata(lm)))) umemlist[nm++] = m; @@ -660,7 +668,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat int allsize, len, maxrlen = 0, ns = 0; - if(str_eq(umstr, "all") || str_eq(umstr, "etc") || strchr(umstr, ',') || strchr(umstr, '\\')) { + if(str_eq(umstr, "ALL") || str_eq(umstr, "all") || str_eq(umstr, "etc") || strpbrk(umstr, ",\\")) { umemlist = memory_list(umstr, p, &ns, &rwvsoftfail, NULL); if(!ns) { // ns is number of memories listed From 23324622d9818cccacc1c6b962916966171625e0 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 22 Jun 2024 00:33:26 +0100 Subject: [PATCH 181/422] Formalise multi-memory address layout --- src/fileio.c | 122 +++++++++++++++++++++++++++++++---------------- src/libavrdude.h | 5 +- src/update.c | 2 +- 3 files changed, 84 insertions(+), 45 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 35bea6a4..fc942385 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -327,44 +327,84 @@ static int ihex_readrec(struct ihexsrec *ihex, char * rec) { } +// Multi-memory file flat address space layout (also used by avr-gcc's elf) + +enum { + MULTI_FLASH, MULTI_DATA, MULTI_EEPROM, + MULTI_FUSES, MULTI_LOCK, + MULTI_SIGROW, MULTI_USERROW, MULTI_BOOTROW, + MULTI_N, +}; + +static const struct { + unsigned base, size; + char *name; +} mulmem[] = { + { 0, 0x800000, "flash"}, // rjmp/call can only address 8 MiB in AVR8 architectures + {0x800000, 0x10000, "data"}, // IO/SRAM + {0x810000, 0x10000, "eeprom"}, + {0x820000, 0x10000, "fuses"}, + {0x830000, 0x10000, "lock"}, + {0x840000, 0x10000, "sigrow"}, + {0x850000, 0x10000, "userrow"}, + {0x860000, 0x10000, "bootrow"}, +}; + +#define ANY_MEM_SIZE (mulmem[MULTI_N-1].base + mulmem[MULTI_N-1].size) + +#define MBASE(n) (mulmem[MULTI_ ## n].base) +#define MSIZE(n) (mulmem[MULTI_ ## n].size) +#define MEND(n) (MBASE(n) + MSIZE(n) - 1) + + +// Memory that holds all possible multi-memories as laid out above +AVRMEM *fileio_any_memory(const char *name) { + return avr_new_memory(name, ANY_MEM_SIZE); +} + +#define boffset(p, basemem) baseoffset((p), avr_locate_ ## basemem(p), # basemem) + +static int baseoffset(const AVRPART *p, const AVRMEM *base, const char *memname) { + if(!base) + pmsg_error("failed to locate %s memory in %s\n", memname, p->desc); + return base? base->offset: 0; +} + // Extends where memory is put in flat address space of .elf files unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { - AVRMEM *base; - - if(mem->type == 0 && mem->size == ANY_MEM_SIZE) + if(mem->type == 0 && mem->size == (int) ANY_MEM_SIZE) return 0; unsigned location = - mem_is_in_flash(mem) && (base = avr_locate_flash(p))? mem->offset - base->offset: - mem_is_io(mem) || mem_is_sram(mem)? MAX_FLASH_SIZE + mem->offset: - mem_is_eeprom(mem)? 0x810000: - mem_is_in_fuses(mem)? 0x820000 + mem_fuse_offset(mem): - mem_is_lock(mem)? 0x830000: + mem_is_in_flash(mem)? MBASE(FLASH) + mem->offset - boffset(p, flash): + mem_is_io(mem) || mem_is_sram(mem)? MBASE(DATA) + mem->offset: + mem_is_eeprom(mem)? MBASE(EEPROM): + mem_is_in_fuses(mem)? MBASE(FUSES) + mem_fuse_offset(mem): + mem_is_lock(mem)? MBASE(LOCK): // Classic parts intersperse signature and calibration bytes, this code places them together - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_signature(mem)? 0x840000: - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_calibration(mem)? 0x840003: - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_sigrow(mem)? 0x840010: // Few parts, eg m328pb + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_signature(mem)? MBASE(SIGROW): + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_calibration(mem)? MBASE(SIGROW)+3: + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_sigrow(mem)? MBASE(SIGROW)+0x10: // Eg, m328pb // XMEGA parts have signature separate from prodsig, place prodsig at +0x10 as above - (p->prog_modes & PM_PDI) && mem_is_signature(mem)? 0x840000: - (p->prog_modes & PM_PDI) && mem_is_in_sigrow(mem) && (base = avr_locate_sigrow(p))? - 0x840010 + mem->offset - base->offset: - mem_is_in_sigrow(mem) && (base = avr_locate_sigrow(p))? 0x840000 + mem->offset - base->offset: - mem_is_sib(mem)? 0x841000: // Arbitrary 0x1000 offset in signature section for sib - mem_is_userrow(mem)? 0x850000: - mem_is_bootrow(mem)? 0x860000: + (p->prog_modes & PM_PDI) && mem_is_signature(mem)? MBASE(SIGROW): + (p->prog_modes & PM_PDI) && mem_is_in_sigrow(mem)? MBASE(SIGROW)+0x10 + mem->offset - boffset(p, sigrow): + mem_is_in_sigrow(mem)? MBASE(SIGROW) + mem->offset - boffset(p, sigrow): // UPDI + rare classic + mem_is_sib(mem)? MBASE(SIGROW) + 0x1000: // Arbitrary 0x1000 offset in signature section for sib + mem_is_userrow(mem)? MBASE(USERROW): + mem_is_bootrow(mem)? MBASE(BOOTROW): -1U; if(location == -1U) pmsg_error("unable to locate %s's %s in multi-memory address space\n", p->desc, mem->desc); - else if(location >= ANY_MEM_SIZE || location + mem->size > ANY_MEM_SIZE) { // Consider overflow + else if(location >= ANY_MEM_SIZE || location + mem->size > ANY_MEM_SIZE) { // Overflow pmsg_error("%s's %s location [0x%06x, 0x%06x] outside flat address space [0, 0x%06x]\n", p->desc, mem->desc, location, location + mem->size-1, ANY_MEM_SIZE-1); location = -1U; - } else if(location < MAX_FLASH_SIZE && location + mem->size > MAX_FLASH_SIZE) { + } else if(location <= MEND(FLASH) && location + mem->size > MEND(FLASH)+1) { pmsg_error("%s's %s location [0x%06x, 0x%06x] straddles flash section boundary 0x%06x\n", - p->desc, mem->desc, location, location + mem->size-1, MAX_FLASH_SIZE); + p->desc, mem->desc, location, location + mem->size-1, MEND(FLASH)+1); location = -1U; - } else if(location >= MAX_FLASH_SIZE && location/0x10000 != (location + mem->size-1)/0x10000) { + } else if(location > MEND(FLASH) && location/0x10000 != (location + mem->size-1)/0x10000) { pmsg_error("%s's %s memory location [0x%06x, 0x%06x] straddles memory section boundary 0x%02x0000\n", p->desc, mem->desc, location, location + mem->size-1, 1+location/0x10000); location = -1U; @@ -378,7 +418,7 @@ static int any2mem(const AVRPART *p, const AVRMEM *mem, const Segment *segp, const AVRMEM *any, unsigned maxsize) { // Compute location for multi-memory file input - unsigned location = maxsize > MAX_FLASH_SIZE? fileio_mem_offset(p, mem): 0; + unsigned location = maxsize > MEND(FLASH)+1? fileio_mem_offset(p, mem): 0; if(location == -1U) return -1; @@ -421,7 +461,7 @@ static int ihex2b(const char *infile, FILE *inf, const AVRPART *p, const AVRMEM nextaddr = 0; rewind(inf); - AVRMEM *any = avr_new_memory("any", ANY_MEM_SIZE); + AVRMEM *any = fileio_any_memory("any"); for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) { lineno++; @@ -726,7 +766,7 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, reccount = 0; rewind(inf); - AVRMEM *any = avr_new_memory("any", ANY_MEM_SIZE); + AVRMEM *any = fileio_any_memory("any"); for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) { lineno++; @@ -903,36 +943,36 @@ static int elf_mem_limits(const AVRMEM *mem, const AVRPART *p, } } else { if (mem_is_in_flash(mem)) { - *lowbound = 0; - *highbound = 0x7Fffff; // Max 8 MiB + *lowbound = MBASE(FLASH); + *highbound = MEND(FLASH); // Max 8 MiB *fileoff = 0; } else if (mem_is_io(mem) || mem_is_sram(mem)) { // IO & SRAM in data space - *lowbound = 0x800000 + mem->offset; - *highbound = 0x80ffff; + *lowbound = MBASE(DATA) + mem->offset; + *highbound = MEND(DATA); *fileoff = 0; } else if (mem_is_eeprom(mem)) { - *lowbound = 0x810000; - *highbound = 0x81ffff; // Max 64 KiB + *lowbound = MBASE(EEPROM); + *highbound = MEND(EEPROM); // Max 64 KiB *fileoff = 0; } else if (mem_is_a_fuse(mem) || mem_is_fuses(mem)) { - *lowbound = 0x820000; - *highbound = 0x82ffff; + *lowbound = MBASE(FUSES); + *highbound = MEND(FUSES); *fileoff = mem_is_a_fuse(mem)? mem_fuse_offset(mem): 0; } else if (mem_is_lock(mem)) { // Lock or lockbits - *lowbound = 0x830000; - *highbound = 0x83ffff; + *lowbound = MBASE(LOCK); + *highbound = MEND(LOCK); *fileoff = 0; } else if (mem_is_signature(mem)) { // Read only - *lowbound = 0x840000; - *highbound = 0x84ffff; + *lowbound = MBASE(SIGROW); + *highbound = MEND(SIGROW); *fileoff = 0; } else if (mem_is_userrow(mem)) { // usersig or userrow - *lowbound = 0x850000; - *highbound = 0x85ffff; + *lowbound = MBASE(USERROW); + *highbound = MEND(USERROW); *fileoff = 0; } else if (mem_is_bootrow(mem)) { - *lowbound = 0x860000; - *highbound = 0x86ffff; + *lowbound = MBASE(BOOTROW); + *highbound = MEND(BOOTROW); *fileoff = 0; } else { rv = -1; diff --git a/src/libavrdude.h b/src/libavrdude.h index 1eec1ba5..bfb99f60 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1221,9 +1221,6 @@ enum { FIO_READ_FOR_VERIFY, }; -#define ANY_MEM_SIZE 0x870000 // Max size of multi-memory input file, see fileio_mem_offset() -#define MAX_FLASH_SIZE 0x800000 // rjmp/call can only address 8 MiB in AVR8 architectures - #ifdef __cplusplus extern "C" { #endif @@ -1234,6 +1231,8 @@ char *fileio_fmtstr(FILEFMT format); int fileio_fmtchr(FILEFMT format); +AVRMEM *fileio_any_memory(const char *name); + unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem); FILE *fileio_fopenr(const char *fname); diff --git a/src/update.c b/src/update.c index 1934c51e..3536136d 100644 --- a/src/update.c +++ b/src/update.c @@ -685,7 +685,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat seglist = mmt_malloc(ns*sizeof*seglist); } - mem = umemlist? avr_new_memory("multi", ANY_MEM_SIZE): avr_locate_mem(p, umstr); + mem = umemlist? fileio_any_memory("any"): avr_locate_mem(p, umstr); if(mem == NULL) { pmsg_warning("skipping -U %s:... as memory not defined for part %s\n", umstr, p->desc); return LIBAVRDUDE_SOFTFAIL; From eb412304eeaae4fcbc4665450fff675ec1d32651 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 22 Jun 2024 12:31:59 +0100 Subject: [PATCH 182/422] Provide avr_locate_uP() --- src/avrpart.c | 11 ++++++++++- src/libavrdude.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/avrpart.c b/src/avrpart.c index 31314422..973392b9 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -543,6 +543,14 @@ int avr_locate_upidx(const AVRPART *p) { return idx; } +// Return pointer to uP_table entry for part p +const Avrintel *avr_locate_uP(const AVRPART *p) { + int idx = avr_locate_upidx(p); + + return idx < 0? NULL: uP_table + idx; +} + + // Return pointer to config table for the part and set number of config bitfields const Configitem *avr_locate_configitems(const AVRPART *p, int *ncp) { int idx = avr_locate_upidx(p); @@ -768,7 +776,8 @@ int avr_get_config_value(const PROGRAMMER *pgm, const AVRPART *p, const char *cn if(!avr_locate_config_mem_c_value(pgm, p, cname, &c, &fusel)) return -1; - *valuep = (fusel & c->mask) >> c->lsh; + if(valuep) + *valuep = (fusel & c->mask) >> c->lsh; return 0; } diff --git a/src/libavrdude.h b/src/libavrdude.h index bfb99f60..bbc5d18e 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1442,6 +1442,7 @@ extern "C" { #endif int avr_locate_upidx(const AVRPART *p); +const Avrintel *avr_locate_uP(const AVRPART *p); const Configitem *avr_locate_configitems(const AVRPART *p, int *ncp); const char * const *avr_locate_isrtable(const AVRPART *p, int *nip); const Register_file *avr_locate_register_file(const AVRPART *p, int *nrp); From 9bf11fd67af559518c226a78577e0fb772c341a8 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 23 Jun 2024 20:38:20 +0100 Subject: [PATCH 183/422] Make sigs argument of str_mcunames_signature() const --- src/libavrdude.h | 2 +- src/strutil.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index bbc5d18e..98f3970f 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1514,7 +1514,7 @@ char *str_nexttok(char *buf, const char *delim, char **next); const char *str_ccfrq(double f, int n); int str_levenshtein(const char *str1, const char *str2, int swap, int subst, int add, int del); size_t str_weighted_damerau_levenshtein(const char *str1, const char *str2); -int str_mcunames_signature(uint8_t *sigs, char *p, size_t n); +int str_mcunames_signature(const unsigned char *sigs, char *p, size_t n); int led_set(const PROGRAMMER *pgm, int led); int led_clr(const PROGRAMMER *pgm, int led); diff --git a/src/strutil.c b/src/strutil.c index d959ef1d..a5c8b01e 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1304,7 +1304,7 @@ size_t str_weighted_damerau_levenshtein(const char *s1, const char *s2) { // Puts a comma-separated list of matching MCU names into array p with n chars space -int str_mcunames_signature(uint8_t *sigs, char *p, size_t n) { +int str_mcunames_signature(const unsigned char *sigs, char *p, size_t n) { int matching = 0; for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++) { From 1a2ac74a7bd47d8ede4be7668393b9d700da0991 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 23 Jun 2024 20:50:31 +0100 Subject: [PATCH 184/422] Label segments with memory names in .hex:I output files --- src/fileio.c | 219 +++++++++++++++++++++++++++++---------------------- 1 file changed, 124 insertions(+), 95 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index fc942385..ef332507 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -150,6 +150,108 @@ FILEFMT fileio_format(char c) { } } + +// Multi-memory file flat address space layout (also used by avr-gcc's elf) + +enum { + MULTI_FLASH, MULTI_DATA, MULTI_EEPROM, + MULTI_FUSES, MULTI_LOCK, + MULTI_SIGROW, MULTI_USERROW, MULTI_BOOTROW, + MULTI_N, +}; + +static const struct { + unsigned base, size; + const char *name; +} mulmem[] = { + { 0, 0x800000, "flash"}, // rjmp/call can only address 8 MiB in AVR8 architectures + {0x800000, 0x10000, "data"}, // IO/SRAM + {0x810000, 0x10000, "EEPROM"}, + {0x820000, 0x10000, "fuses"}, + {0x830000, 0x10000, "lock"}, + {0x840000, 0x10000, "sigrow"}, + {0x850000, 0x10000, "userrow"}, + {0x860000, 0x10000, "bootrow"}, +}; + +#define ANY_MEM_SIZE (mulmem[MULTI_N-1].base + mulmem[MULTI_N-1].size) + +#define MBASE(n) (mulmem[MULTI_ ## n].base) +#define MSIZE(n) (mulmem[MULTI_ ## n].size) +#define MEND(n) (MBASE(n) + MSIZE(n) - 1) + +// Memory that holds all possible multi-memories as laid out above +AVRMEM *fileio_any_memory(const char *name) { + return avr_new_memory(name, ANY_MEM_SIZE); +} + +#define boffset(p, basemem) baseoffset((p), avr_locate_ ## basemem(p), # basemem) + +static int baseoffset(const AVRPART *p, const AVRMEM *base, const char *memname) { + if(!base) + pmsg_error("failed to locate %s memory in %s\n", memname, p->desc); + return base? base->offset: 0; +} + +// Extends where memory is put in flat address space of .elf files +unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { + if(mem->type == 0 && mem->size == (int) ANY_MEM_SIZE) + return 0; + + unsigned location = + mem_is_in_flash(mem)? MBASE(FLASH) + mem->offset - boffset(p, flash): + mem_is_io(mem) || mem_is_sram(mem)? MBASE(DATA) + mem->offset: + mem_is_eeprom(mem)? MBASE(EEPROM): + mem_is_in_fuses(mem)? MBASE(FUSES) + mem_fuse_offset(mem): + mem_is_lock(mem)? MBASE(LOCK): + // Classic parts intersperse signature and calibration bytes, this code places them together + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_signature(mem)? MBASE(SIGROW): + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_calibration(mem)? MBASE(SIGROW)+3: + !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_sigrow(mem)? MBASE(SIGROW)+0x10: // Eg, m328pb + // XMEGA parts have signature separate from prodsig, place prodsig at +0x10 as above + (p->prog_modes & PM_PDI) && mem_is_signature(mem)? MBASE(SIGROW): + (p->prog_modes & PM_PDI) && mem_is_in_sigrow(mem)? MBASE(SIGROW)+0x10 + mem->offset - boffset(p, sigrow): + mem_is_in_sigrow(mem)? MBASE(SIGROW) + mem->offset - boffset(p, sigrow): // UPDI + rare classic + mem_is_sib(mem)? MBASE(SIGROW) + 0x1000: // Arbitrary 0x1000 offset in signature section for sib + mem_is_userrow(mem)? MBASE(USERROW): + mem_is_bootrow(mem)? MBASE(BOOTROW): + -1U; + + if(location == -1U) + pmsg_error("unable to locate %s's %s in multi-memory address space\n", p->desc, mem->desc); + else if(location >= ANY_MEM_SIZE || location + mem->size > ANY_MEM_SIZE) { // Overflow + pmsg_error("%s's %s location [0x%06x, 0x%06x] outside flat address space [0, 0x%06x]\n", + p->desc, mem->desc, location, location + mem->size-1, ANY_MEM_SIZE-1); + location = -1U; + } else if(location <= MEND(FLASH) && location + mem->size > MEND(FLASH)+1) { + pmsg_error("%s's %s location [0x%06x, 0x%06x] straddles flash section boundary 0x%06x\n", + p->desc, mem->desc, location, location + mem->size-1, MEND(FLASH)+1); + location = -1U; + } else if(location > MEND(FLASH) && location/0x10000 != (location + mem->size-1)/0x10000) { + pmsg_error("%s's %s memory location [0x%06x, 0x%06x] straddles memory section boundary 0x%02x0000\n", + p->desc, mem->desc, location, location + mem->size-1, 1+location/0x10000); + location = -1U; + } + + return location; +} + +static const char *memlabel(const AVRPART *p, const AVRMEM *m, unsigned addr, int n) { + if(m->size < (int) ANY_MEM_SIZE) // Ordinary (single) memory + return addr? NULL: m->desc; + + // Inverse lookup of which memory could have been mapped to this address + for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) + if(fileio_mem_offset(p, (m = ldata(lm))) == addr && n == m->size) + return avr_mem_name(p, m); + + for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) + if(fileio_mem_offset(p, (m = ldata(lm))) == addr) + return avr_mem_name(p, m); + + return NULL; +} + // Tells lower level .hex/.srec routines whether to write intros/outros typedef enum { FIRST_SEG = 1, @@ -164,6 +266,8 @@ static void print_ihex_extended_addr(int n_64k, FILE *outf) { fprintf(outf, ":02000004%02X%02X%02X\n", hi, lo, cksum); } + + /* * Binary buffer to Intel Hex, see https://en.wikipedia.org/wiki/Intel_HEX * @@ -177,10 +281,10 @@ static void print_ihex_extended_addr(int n_64k, FILE *outf) { * Return the maximum memory address within mem->buf that was read from * plus one. If an error occurs, return -1. */ -static int b2ihex(const unsigned char *buf, const Segment *segp, Segorder where, - int recsize, int startaddr, const char *outfile_unused, FILE *outf, - FILEFMT ffmt) { +static int b2ihex(const AVRPART *p, const AVRMEM *mem, const Segment *segp, Segorder where, + int recsize, int startaddr, const char *outfile_unused, FILE *outf, FILEFMT ffmt) { + const unsigned char *buf = mem->buf; int bufsize = segp->len; unsigned int nextaddr; int n, hiaddr, n_64k; @@ -209,7 +313,7 @@ static int b2ihex(const unsigned char *buf, const Segment *segp, Segorder where, if (n) { fprintf(outf, ":%02X%04X00", n, nextaddr); - unsigned char cksum = n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff); + unsigned char c, cksum = n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff); for(int i=0; i ", n_64k*0x10000 + nextaddr); - for(int i=0; idesc); - return base? base->offset: 0; -} - -// Extends where memory is put in flat address space of .elf files -unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { - if(mem->type == 0 && mem->size == (int) ANY_MEM_SIZE) - return 0; - - unsigned location = - mem_is_in_flash(mem)? MBASE(FLASH) + mem->offset - boffset(p, flash): - mem_is_io(mem) || mem_is_sram(mem)? MBASE(DATA) + mem->offset: - mem_is_eeprom(mem)? MBASE(EEPROM): - mem_is_in_fuses(mem)? MBASE(FUSES) + mem_fuse_offset(mem): - mem_is_lock(mem)? MBASE(LOCK): - // Classic parts intersperse signature and calibration bytes, this code places them together - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_signature(mem)? MBASE(SIGROW): - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_calibration(mem)? MBASE(SIGROW)+3: - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_sigrow(mem)? MBASE(SIGROW)+0x10: // Eg, m328pb - // XMEGA parts have signature separate from prodsig, place prodsig at +0x10 as above - (p->prog_modes & PM_PDI) && mem_is_signature(mem)? MBASE(SIGROW): - (p->prog_modes & PM_PDI) && mem_is_in_sigrow(mem)? MBASE(SIGROW)+0x10 + mem->offset - boffset(p, sigrow): - mem_is_in_sigrow(mem)? MBASE(SIGROW) + mem->offset - boffset(p, sigrow): // UPDI + rare classic - mem_is_sib(mem)? MBASE(SIGROW) + 0x1000: // Arbitrary 0x1000 offset in signature section for sib - mem_is_userrow(mem)? MBASE(USERROW): - mem_is_bootrow(mem)? MBASE(BOOTROW): - -1U; - - if(location == -1U) - pmsg_error("unable to locate %s's %s in multi-memory address space\n", p->desc, mem->desc); - else if(location >= ANY_MEM_SIZE || location + mem->size > ANY_MEM_SIZE) { // Overflow - pmsg_error("%s's %s location [0x%06x, 0x%06x] outside flat address space [0, 0x%06x]\n", - p->desc, mem->desc, location, location + mem->size-1, ANY_MEM_SIZE-1); - location = -1U; - } else if(location <= MEND(FLASH) && location + mem->size > MEND(FLASH)+1) { - pmsg_error("%s's %s location [0x%06x, 0x%06x] straddles flash section boundary 0x%06x\n", - p->desc, mem->desc, location, location + mem->size-1, MEND(FLASH)+1); - location = -1U; - } else if(location > MEND(FLASH) && location/0x10000 != (location + mem->size-1)/0x10000) { - pmsg_error("%s's %s memory location [0x%06x, 0x%06x] straddles memory section boundary 0x%02x0000\n", - p->desc, mem->desc, location, location + mem->size-1, 1+location/0x10000); - location = -1U; - } - - return location; -} - // Extract correct memory from large any memory assuming multi-memory model static int any2mem(const AVRPART *p, const AVRMEM *mem, const Segment *segp, const AVRMEM *any, unsigned maxsize) { @@ -1265,7 +1294,7 @@ static int fileio_ihex(struct fioparms *fio, const char *filename, FILE *f, switch (fio->op) { case FIO_WRITE: - rc = b2ihex(mem->buf, segp, where, 32, fio->fileoffset, filename, f, ffmt); + rc = b2ihex(p, mem, segp, where, 32, fio->fileoffset, filename, f, ffmt); break; case FIO_READ: From f3fbb2eb1d81b8173b40b9c310374c7b64636766 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 24 Jun 2024 00:24:29 +0100 Subject: [PATCH 185/422] Default -U multi-memory backups to Intel Hex with comments --- src/update.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/update.c b/src/update.c index 3536136d..81e98992 100644 --- a/src/update.c +++ b/src/update.c @@ -36,6 +36,11 @@ #include "libavrdude.h" +// Is s a multi-memory string (comma-separates list, all, ALL, etc or list subtraction)? +static int is_multimem(const char *s) { + return str_eq(s, "ALL") || str_eq(s, "all") || str_eq(s, "etc") || strpbrk(s, ",\\"); +} + /* * Parsing of [::[:] | [:]] * @@ -70,8 +75,9 @@ UPDATE *parse_op(const char *s) { fn = fc+3; } - // Default to AUTO for write and verify, and to raw binary for read - upd->format = upd->op == DEVICE_READ? FMT_RBIN: FMT_AUTO; + // Autodetect for file reads, and hex (multi-mem)/raw (single mem) for file writes + upd->format = upd->op != DEVICE_READ? FMT_AUTO: + is_multimem(upd->memstr)? FMT_IHXC: FMT_RBIN; // Filename: last char is format if the penultimate char is a colon size_t len = strlen(fn); @@ -668,7 +674,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat int allsize, len, maxrlen = 0, ns = 0; - if(str_eq(umstr, "ALL") || str_eq(umstr, "all") || str_eq(umstr, "etc") || strpbrk(umstr, ",\\")) { + if(is_multimem(umstr)) { umemlist = memory_list(umstr, p, &ns, &rwvsoftfail, NULL); if(!ns) { // ns is number of memories listed From d4d6835bdf1ecd393c3c578fd025286fd26a0489 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 24 Jun 2024 17:28:22 +0100 Subject: [PATCH 186/422] Fix dryrun's paged write to XMEGA overlapping flash memories --- src/dryrun.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index d24f4838..6c0ec8dd 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -326,19 +326,13 @@ static int dryrun_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR // Copy chunk to overlapping XMEGA's apptable, application, boot and flash memories if(mchr == 'F') { - if(mem_is_flash(dmem)) { - for(LNODEID ln=lfirst(dry.dp->mem); ln; ln=lnext(ln)) { - dm2 = ldata(ln); - if(mem_is_in_flash(dm2) && !mem_is_flash(dm2)) { // Overlapping region? - unsigned int cpaddr = addr + dmem->offset - dm2->offset; - if(cpaddr < (unsigned int) dm2->size && cpaddr + chunk <= (unsigned int) dm2->size) - memcpy(dm2->buf+cpaddr, dmem->buf+addr, chunk); - } + for(LNODEID ln=lfirst(dry.dp->mem); ln; ln=lnext(ln)) { + dm2 = ldata(ln); + if(mem_is_in_flash(dm2) && dmem != dm2) { // Overlapping region? + unsigned int cpaddr = addr + dmem->offset - dm2->offset; + if(cpaddr < (unsigned int) dm2->size && cpaddr + chunk <= (unsigned int) dm2->size) + memmove(dm2->buf+cpaddr, dmem->buf+addr, chunk); } - } else if((dm2 = avr_locate_flash(dry.dp))) { - unsigned int cpaddr = addr + dmem->offset - dm2->offset; - if(cpaddr < (unsigned int) dm2->size && cpaddr + chunk <= (unsigned int) dm2->size) - memcpy(dm2->buf+cpaddr, dmem->buf+addr, chunk); } } } From f06b3dd5b90c554b6a2c5c0fdd07282754226cf6 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 25 Jun 2024 00:08:54 +0100 Subject: [PATCH 187/422] Fix boot_section_size for AVR-Ex parts --- src/avrdude.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index a638d038..f816ec19 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -24555,6 +24555,7 @@ part parent "32du14" # 32du32 part parent ".avrdx" # .avrex desc = "AVR-Ex family common values"; id = ".avrex"; + boot_section_size = 256; # Shared UPDI pin, HV on _RESET hvupdi_variant = 2; factory_fcpu = 20000000; From ad312b985afe6bc7989374ea9a4a6061134fe4c4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 25 Jun 2024 01:04:05 +0100 Subject: [PATCH 188/422] Fix boot_section_size for x128a4 --- src/avrdude.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index f816ec19..3ffeec2c 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -18385,6 +18385,7 @@ part parent ".xmega" # x128a4 "ATxmega128A4: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; prog_modes = PM_SPM | PM_PDI | PM_XMEGAJTAG; mcuid = 263; + boot_section_size = 8192; signature = 0x1e 0x97 0x46; memory "eeprom" From 41eacd0eedfd24800cde40a49daf1f6d8c43404f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 25 Jun 2024 01:12:17 +0100 Subject: [PATCH 189/422] Fix flash page size for x128a4 --- src/avrdude.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 3ffeec2c..035dd141 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -18397,7 +18397,7 @@ part parent ".xmega" # x128a4 memory "flash" size = 0x22000; - page_size = 512; + page_size = 256; offset = 0x800000; readsize = 256; ; From 9a834c37c7e0f4fa37d0320b0ac392f2569ea84e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 25 Jun 2024 01:18:52 +0100 Subject: [PATCH 190/422] Update avrintel.c --- src/avrintel.c | 329 ++++++++++++++++++++------------------ src/libavrdude-avrintel.h | 6 +- 2 files changed, 180 insertions(+), 155 deletions(-) diff --git a/src/avrintel.c b/src/avrintel.c index 81860442..1128b0e7 100644 --- a/src/avrintel.c +++ b/src/avrintel.c @@ -8,8 +8,8 @@ * Published under GNU General Public License, version 3 (GPL-3.0) * Meta-author Stefan Rueger * - * v 1.3 - * 20.05.2024 + * v 1.39 + * 25.06.2024 * */ @@ -98,11 +98,36 @@ int upmatchingsig(uint8_t sigs[3], char *p, size_t n) { } +/* + * const Avrintel uP_table[] contains important MCU properties that were + * curated from different sources such as ATDF files, their predecessor xml + * files and avr-libc with manual corrections verified by data sheets. Even + * though this table is independent from avrdude.conf, virtually all basic + * values such as flash size, eeprom size and the size of the smallest boot + * sector (if any) etc coincide. With respect to flash page sizes only + * ATtiny20's entries differ between here and avrdude.conf (but then, ATDF, + * avr-libc, avrdude and the datasheet all have pairwise different values). For + * EEPROM page sizes only ATtiny12, ATtiny15, ATtiny26, ATmega8515 and + * ATmega8535 show different values. Note that flashoffset here models a + * completely different entity than avrdude.conf's flash offset. + * + * Crucially, however, this table contains information about interrupt names, + * MCU configuration (named bitfields in the fuses with lists of admissible + * symbolic names and their values) and I/O register variable names with their + * addresses. The terminal commands config and regfile make good use of these + * tables. Putting all of this intelligence into avrdude.conf would blow that + * up beyond recognition. + * + * Pro tip: for a quick overview of where the information for an entry came + * from grep //.Source avrintel.c. Similarly, for memory info grep //.Mem. + */ + const Avrintel uP_table[] = { // Value of -1 typically means unknown - //mcu_name // Sources + //mcu_name // Sources //{mcu_name, mcuid, family, {sig, na, ture}, // ID //mcu_name flstart, flsize, pgsiz, nb, bootsz, eestart, eesize, ep, rambeg, ramsiz, // Mem - //mcu_naame nf, nl, ni, isr_names, nc, cfg_table}, // Config and ISRs + //mcu_name nf, nl, ni, isr_names, nc, cfg_table, // ISRs, Config + //mcu_name nr, rgftab_table, // Register file //ATtiny4 atdf, avr-gcc 12.2.0, avrdude, boot size (manual) // Sources {"ATtiny4", 0, F_AVR8L, {0x1E, 0x8F, 0x0A}, // ID @@ -155,7 +180,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATtiny11 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny11", 8, F_AVR8, {0x1E, 0x90, 0x04}, // ID - /*ATtiny11*/ 0, 0x00400, 0x001, 0, 0, 0, 0x0040, 1, 0x0060, 0x0020, // Mem + /*ATtiny11*/ 0, 0x00400, 0x001, 0, 0, 0, 0, 1, 0x0060, 0x0020, // Mem /*ATtiny11*/ 1, 1, 5, vtab_attiny11, 4, cfgtab_attiny11, // ISRs, Config /*ATtiny11*/ 14, rgftab_attiny11}, // Register file @@ -437,7 +462,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATmega16HVA2 xml, avr-gcc 12.2.0 // Sources {"ATmega16HVA2", 55, F_AVR8, {0x1E, 0x94, 0x0E}, // ID - /*ATmega16HVA2*/ 0, 0x04000, 0x080, -1, -1, -1, -1, -1, 0x0100, 0x0400, // Mem + /*ATmega16HVA2*/ 0, 0x04000, 0x080, -1, -1, 0, 0x0100, -1, 0x0100, 0x0400, // Mem /*ATmega16HVA2*/ 2, 1, 22, vtab_atmega16hva2, 9, cfgtab_atmega16hva2, // ISRs, Config /*ATmega16HVA2*/ 0, NULL}, // Register file @@ -509,7 +534,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATmega32U6 xml, avr-gcc 12.2.0, boot size (manual) // Sources {"ATmega32U6", 66, F_AVR8, {0x1E, 0x95, 0x88}, // ID - /*ATmega32U6*/ 0, 0x08000, 0x080, 4, 0x0200, -1, -1, -1, 0x0100, 0x0a00, // Mem + /*ATmega32U6*/ 0, 0x08000, 0x080, 4, 0x0200, 0, 0x0400, -1, 0x0100, 0x0a00, // Mem /*ATmega32U6*/ 3, 1, 38, vtab_atmega32u6, 15, cfgtab_atmega32u6, // ISRs, Config /*ATmega32U6*/ 0, NULL}, // Register file @@ -557,7 +582,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATmega64HVE xml, avr-gcc 12.2.0, boot size (manual) // Sources {"ATmega64HVE", 74, F_AVR8, {0x1E, 0x96, 0x10}, // ID - /*ATmega64HVE*/ 0, 0x10000, 0x080, 4, 0x0400, -1, -1, -1, 0x0100, 0x1000, // Mem + /*ATmega64HVE*/ 0, 0x10000, 0x080, 4, 0x0400, 0, 0x0400, -1, 0x0100, 0x1000, // Mem /*ATmega64HVE*/ 2, 1, 25, vtab_atmega64hve2, 13, cfgtab_atmega64hve, // ISRs, Config /*ATmega64HVE*/ 0, NULL}, // Register file @@ -779,7 +804,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATmega323 xml, avr-gcc 12.2.0, boot size (manual) // Sources {"ATmega323", 109, F_AVR8, {0x1E, 0x95, 0x01}, // ID - /*ATmega323*/ 0, 0x08000, 0x080, 4, 0x0200, -1, -1, -1, 0x0060, 0x0800, // Mem + /*ATmega323*/ 0, 0x08000, 0x080, 4, 0x0200, 0, 0x0400, -1, 0x0060, 0x0800, // Mem /*ATmega323*/ 2, 1, 21, vtab_atmega323, 12, cfgtab_atmega323, // ISRs, Config /*ATmega323*/ 0, NULL}, // Register file @@ -1097,37 +1122,37 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //AT43USB320 avr-gcc 12.2.0 // Sources {"AT43USB320", 162, F_AVR8, {0xff, -1, -1}, // ID - /*AT43USB320*/ 0, 0x10000, -1, -1, -1, -1, -1, -1, 0x0060, 0x0200, // Mem + /*AT43USB320*/ 0, 0x10000, -1, -1, -1, 0, 0, -1, 0x0060, 0x0200, // Mem /*AT43USB320*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AT43USB320*/ 0, NULL}, // Register file //AT43USB355 avr-gcc 12.2.0 // Sources {"AT43USB355", 163, F_AVR8, {0xff, -1, -1}, // ID - /*AT43USB355*/ 0, 0x06000, -1, -1, -1, -1, -1, -1, 0x0060, 0x0400, // Mem + /*AT43USB355*/ 0, 0x06000, -1, -1, -1, 0, 0, -1, 0x0060, 0x0400, // Mem /*AT43USB355*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AT43USB355*/ 0, NULL}, // Register file //AT76C711 avr-gcc 12.2.0 // Sources {"AT76C711", 164, F_AVR8, {0xff, -1, -1}, // ID - /*AT76C711*/ 0, 0x04000, -1, -1, -1, -1, -1, -1, 0x0060, 0x07a0, // Mem + /*AT76C711*/ 0, 0x04000, -1, -1, -1, 0, 0, -1, 0x0060, 0x07a0, // Mem /*AT76C711*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AT76C711*/ 0, NULL}, // Register file //AT86RF401 avr-gcc 12.2.0 // Sources {"AT86RF401", 165, F_AVR8, {0x1E, 0x91, 0x81}, // ID - /*AT86RF401*/ 0, 0x00800, -1, -1, -1, -1, -1, -1, 0x0060, 0x0080, // Mem + /*AT86RF401*/ 0, 0x00800, -1, -1, -1, 0, 0x0080, -1, 0x0060, 0x0080, // Mem /*AT86RF401*/ 0, 1, 3, vtab_at86rf401, 0, NULL, // ISRs, Config /*AT86RF401*/ 0, NULL}, // Register file //AT89S51 avrdude // Sources {"AT89S51", 372, F_AVR8, {0x1E, 0x51, 0x06}, // ID - /*AT89S51*/ 0, 0x01000, 0x001, -1, -1, 0, 0, 0, -1, -1, // Mem + /*AT89S51*/ 0, 0x01000, 0x001, 0, 0, 0, 0, 0, -1, -1, // Mem /*AT89S51*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AT89S51*/ 0, NULL}, // Register file //AT89S52 avrdude // Sources {"AT89S52", 373, F_AVR8, {0x1E, 0x52, 0x06}, // ID - /*AT89S52*/ 0, 0x02000, 0x001, -1, -1, 0, 0, 0, -1, -1, // Mem + /*AT89S52*/ 0, 0x02000, 0x001, 0, 0, 0, 0, 0, -1, -1, // Mem /*AT89S52*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AT89S52*/ 0, NULL}, // Register file @@ -1187,13 +1212,13 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //AT90SCR100 avr-gcc 12.2.0, boot size (manual) // Sources {"AT90SCR100", 175, F_AVR8, {0x1E, 0x96, 0xC1}, // ID - /*AT90SCR100*/ 0, 0x10000, 0x100, 4, 0x0200, -1, -1, -1, 0x0100, 0x1000, // Mem + /*AT90SCR100*/ 0, 0x10000, 0x100, 4, 0x0200, 0, 0x0800, -1, 0x0100, 0x1000, // Mem /*AT90SCR100*/ 3, 1, 38, vtab_at90scr100h, 13, cfgtab_at90scr100h, // ISRs, Config /*AT90SCR100*/ 0, NULL}, // Register file //AT90SCR100H xml, from AT90SCR100 // Sources {"AT90SCR100H", 376, F_AVR8, {0x1E, 0x96, 0xC1}, // ID - /*AT90SCR100H*/ -1, -1, -1, 4, 0x0200, -1, -1, -1, 0x0100, 0x1000, // Mem + /*AT90SCR100H*/ -1, 0x10000, 0x100, 4, 0x0200, 0, 0x0800, -1, 0x0100, 0x1000, // Mem /*AT90SCR100H*/ 3, 1, 38, vtab_at90scr100h, 13, cfgtab_at90scr100h, // ISRs, Config /*AT90SCR100H*/ 0, NULL}, // Register file @@ -1313,7 +1338,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //AT90C8534 avr-gcc 12.2.0 // Sources {"AT90C8534", 194, F_AVR8, {0xff, -1, -1}, // ID - /*AT90C8534*/ 0, 0x02000, -1, -1, -1, -1, -1, -1, 0x0060, 0x0100, // Mem + /*AT90C8534*/ 0, 0x02000, -1, -1, -1, 0, 0x0200, -1, 0x0060, 0x0100, // Mem /*AT90C8534*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AT90C8534*/ 0, NULL}, // Register file @@ -1331,7 +1356,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //AT94K avr-gcc 12.2.0 // Sources {"AT94K", 196, F_AVR8, {0xff, -1, -1}, // ID - /*AT94K*/ 0, 0x08000, -1, -1, -1, -1, -1, -1, 0x0060, 0x0fa0, // Mem + /*AT94K*/ 0, 0x08000, -1, -1, -1, 0, 0, -1, 0x0060, 0x0fa0, // Mem /*AT94K*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AT94K*/ 0, NULL}, // Register file @@ -1445,7 +1470,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATA6289 xml, avr-gcc 12.2.0, boot size (manual) // Sources {"ATA6289", 215, F_AVR8, {0x1E, 0x93, 0x82}, // ID - /*ATA6289*/ 0, 0x02000, 0x040, 4, 0x0100, -1, -1, -1, 0x0100, 0x0200, // Mem + /*ATA6289*/ 0, 0x02000, 0x040, 4, 0x0100, 0x00040, 0x0100, -1, 0x0100, 0x0200, // Mem /*ATA6289*/ 2, 1, 27, vtab_ata6289, 17, cfgtab_ata6289, // ISRs, Config /*ATA6289*/ 0, NULL}, // Register file @@ -1511,7 +1536,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //M3000 avr-gcc 12.2.0 // Sources {"M3000", 226, F_AVR8, {0xff, -1, -1}, // ID - /*M3000*/ 0, 0x10000, -1, -1, -1, -1, -1, -1, 0x1000, 0x1000, // Mem + /*M3000*/ 0, 0x10000, -1, -1, -1, 0, 0, -1, 0x1000, 0x1000, // Mem /*M3000*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*M3000*/ 0, NULL}, // Register file @@ -1662,7 +1687,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATxmega64A4 avrdude // Sources {"ATxmega64A4", 251, F_XMEGA, {0x1E, 0x96, 0x46}, // ID - /*ATxmega64A4*/ 0, 0x11000, 0x100, -1, -1, 0, 0x0800, 32, -1, -1, // Mem + /*ATxmega64A4*/ 0, 0x11000, 0x100, 1, 0x1000, 0, 0x0800, 32, 0x2000, 0x1000, // Mem /*ATxmega64A4*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*ATxmega64A4*/ 0, NULL}, // Register file @@ -1734,7 +1759,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATxmega128A4 avrdude // Sources {"ATxmega128A4", 263, F_XMEGA, {0x1E, 0x97, 0x46}, // ID - /*ATxmega128A4*/ 0, 0x22000, 0x200, -1, -1, 0, 0x0800, 32, -1, -1, // Mem + /*ATxmega128A4*/ 0, 0x22000, 0x100, 1, 0x2000, 0, 0x0800, 32, 0x2000, 0x2000, // Mem /*ATxmega128A4*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*ATxmega128A4*/ 0, NULL}, // Register file @@ -1752,7 +1777,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATxmega192A1 avrdude // Sources {"ATxmega192A1", 266, F_XMEGA, {0x1E, 0x97, 0x4E}, // ID - /*ATxmega192A1*/ 0, 0x32000, 0x200, -1, -1, 0, 0x0800, 32, -1, -1, // Mem + /*ATxmega192A1*/ 0, 0x32000, 0x200, 1, 0x2000, 0, 0x0800, 32, 0x2000, 0x4000, // Mem /*ATxmega192A1*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*ATxmega192A1*/ 0, NULL}, // Register file @@ -1782,7 +1807,7 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATxmega256A1 avrdude // Sources {"ATxmega256A1", 271, F_XMEGA, {0x1E, 0x98, 0x46}, // ID - /*ATxmega256A1*/ 0, 0x42000, 0x200, -1, -1, 0, 0x1000, 32, -1, -1, // Mem + /*ATxmega256A1*/ 0, 0x42000, 0x200, 1, 0x2000, 0, 0x1000, 32, 0x2000, 0x4000, // Mem /*ATxmega256A1*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*ATxmega256A1*/ 0, NULL}, // Register file @@ -1837,199 +1862,199 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATtiny202 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny202", 280, F_AVR8X, {0x1E, 0x91, 0x23}, // ID - /*ATtiny202*/ 0, 0x00800, 0x040, 1, 0, 0x01400, 0x0040, 32, 0x3f80, 0x0080, // Mem + /*ATtiny202*/ 0, 0x00800, 0x040, 1, 0x0100, 0x01400, 0x0040, 32, 0x3f80, 0x0080, // Mem /*ATtiny202*/ 10, 1, 26, vtab_attiny402, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny202*/ 217, rgftab_attiny202}, // Register file //ATtiny204 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny204", 281, F_AVR8X, {0x1E, 0x91, 0x22}, // ID - /*ATtiny204*/ 0, 0x00800, 0x040, 1, 0, 0x01400, 0x0040, 32, 0x3f80, 0x0080, // Mem + /*ATtiny204*/ 0, 0x00800, 0x040, 1, 0x0100, 0x01400, 0x0040, 32, 0x3f80, 0x0080, // Mem /*ATtiny204*/ 10, 1, 26, vtab_attiny404, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny204*/ 235, rgftab_attiny204}, // Register file //ATtiny212 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny212", 282, F_AVR8X, {0x1E, 0x91, 0x21}, // ID - /*ATtiny212*/ 0, 0x00800, 0x040, 1, 0, 0x01400, 0x0040, 32, 0x3f80, 0x0080, // Mem + /*ATtiny212*/ 0, 0x00800, 0x040, 1, 0x0100, 0x01400, 0x0040, 32, 0x3f80, 0x0080, // Mem /*ATtiny212*/ 10, 1, 26, vtab_attiny412, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny212*/ 247, rgftab_attiny212}, // Register file //ATtiny214 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny214", 283, F_AVR8X, {0x1E, 0x91, 0x20}, // ID - /*ATtiny214*/ 0, 0x00800, 0x040, 1, 0, 0x01400, 0x0040, 32, 0x3f80, 0x0080, // Mem + /*ATtiny214*/ 0, 0x00800, 0x040, 1, 0x0100, 0x01400, 0x0040, 32, 0x3f80, 0x0080, // Mem /*ATtiny214*/ 10, 1, 26, vtab_attiny814, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny214*/ 265, rgftab_attiny214}, // Register file //ATtiny402 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny402", 284, F_AVR8X, {0x1E, 0x92, 0x27}, // ID - /*ATtiny402*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem + /*ATtiny402*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem /*ATtiny402*/ 10, 1, 26, vtab_attiny402, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny402*/ 217, rgftab_attiny202}, // Register file //ATtiny404 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny404", 285, F_AVR8X, {0x1E, 0x92, 0x26}, // ID - /*ATtiny404*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem + /*ATtiny404*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem /*ATtiny404*/ 10, 1, 26, vtab_attiny404, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny404*/ 235, rgftab_attiny204}, // Register file //ATtiny406 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny406", 286, F_AVR8X, {0x1E, 0x92, 0x25}, // ID - /*ATtiny406*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem + /*ATtiny406*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem /*ATtiny406*/ 10, 1, 26, vtab_attiny406, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny406*/ 253, rgftab_attiny406}, // Register file //ATtiny412 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny412", 287, F_AVR8X, {0x1E, 0x92, 0x23}, // ID - /*ATtiny412*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem + /*ATtiny412*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem /*ATtiny412*/ 10, 1, 26, vtab_attiny412, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny412*/ 247, rgftab_attiny212}, // Register file //ATtiny414 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny414", 288, F_AVR8X, {0x1E, 0x92, 0x22}, // ID - /*ATtiny414*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem + /*ATtiny414*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem /*ATtiny414*/ 10, 1, 26, vtab_attiny814, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny414*/ 265, rgftab_attiny214}, // Register file //ATtiny416 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny416", 289, F_AVR8X, {0x1E, 0x92, 0x21}, // ID - /*ATtiny416*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem + /*ATtiny416*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem /*ATtiny416*/ 10, 1, 26, vtab_attiny817, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny416*/ 283, rgftab_attiny416}, // Register file //ATtiny416auto atdf, avrdude // Sources {"ATtiny416auto", 290, F_AVR8X, {0x1E, 0x92, 0x28}, // ID - /*ATtiny416auto*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem + /*ATtiny416auto*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem /*ATtiny416auto*/ 10, 1, 26, vtab_attiny817, 23, cfgtab_attiny416auto, // ISRs, Config /*ATtiny416auto*/ 283, rgftab_attiny416auto}, // Register file //ATtiny417 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny417", 291, F_AVR8X, {0x1E, 0x92, 0x20}, // ID - /*ATtiny417*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem + /*ATtiny417*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3f00, 0x0100, // Mem /*ATtiny417*/ 10, 1, 26, vtab_attiny817, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny417*/ 283, rgftab_attiny417}, // Register file //ATtiny424 atdf, avrdude // Sources {"ATtiny424", 292, F_AVR8X, {0x1E, 0x92, 0x2C}, // ID - /*ATtiny424*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny424*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny424*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny424*/ 307, rgftab_attiny1624}, // Register file //ATtiny426 atdf, avrdude // Sources {"ATtiny426", 293, F_AVR8X, {0x1E, 0x92, 0x2B}, // ID - /*ATtiny426*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny426*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny426*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny426*/ 308, rgftab_attiny426}, // Register file //ATtiny427 atdf, avrdude // Sources {"ATtiny427", 294, F_AVR8X, {0x1E, 0x92, 0x2A}, // ID - /*ATtiny427*/ 0, 0x01000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny427*/ 0, 0x01000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny427*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny427*/ 308, rgftab_attiny426}, // Register file //ATtiny804 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny804", 295, F_AVR8X, {0x1E, 0x93, 0x25}, // ID - /*ATtiny804*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny804*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny804*/ 10, 1, 31, vtab_attiny1607, 15, cfgtab_attiny804, // ISRs, Config /*ATtiny804*/ 255, rgftab_attiny804}, // Register file //ATtiny806 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny806", 296, F_AVR8X, {0x1E, 0x93, 0x24}, // ID - /*ATtiny806*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny806*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny806*/ 10, 1, 31, vtab_attiny1607, 15, cfgtab_attiny804, // ISRs, Config /*ATtiny806*/ 255, rgftab_attiny804}, // Register file //ATtiny807 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny807", 297, F_AVR8X, {0x1E, 0x93, 0x23}, // ID - /*ATtiny807*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny807*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny807*/ 10, 1, 31, vtab_attiny1607, 15, cfgtab_attiny804, // ISRs, Config /*ATtiny807*/ 255, rgftab_attiny804}, // Register file //ATtiny814 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny814", 298, F_AVR8X, {0x1E, 0x93, 0x22}, // ID - /*ATtiny814*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny814*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny814*/ 10, 1, 26, vtab_attiny814, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny814*/ 265, rgftab_attiny814}, // Register file //ATtiny816 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny816", 299, F_AVR8X, {0x1E, 0x93, 0x21}, // ID - /*ATtiny816*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny816*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny816*/ 10, 1, 26, vtab_attiny817, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny816*/ 283, rgftab_attiny417}, // Register file //ATtiny817 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny817", 300, F_AVR8X, {0x1E, 0x93, 0x20}, // ID - /*ATtiny817*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem + /*ATtiny817*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3e00, 0x0200, // Mem /*ATtiny817*/ 10, 1, 26, vtab_attiny817, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny817*/ 283, rgftab_attiny417}, // Register file //ATtiny824 atdf, avrdude // Sources {"ATtiny824", 301, F_AVR8X, {0x1E, 0x93, 0x29}, // ID - /*ATtiny824*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3c00, 0x0400, // Mem + /*ATtiny824*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3c00, 0x0400, // Mem /*ATtiny824*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny824*/ 307, rgftab_attiny1624}, // Register file //ATtiny826 atdf, avrdude // Sources {"ATtiny826", 302, F_AVR8X, {0x1E, 0x93, 0x28}, // ID - /*ATtiny826*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3c00, 0x0400, // Mem + /*ATtiny826*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3c00, 0x0400, // Mem /*ATtiny826*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny826*/ 308, rgftab_attiny426}, // Register file //ATtiny827 atdf, avrdude // Sources {"ATtiny827", 303, F_AVR8X, {0x1E, 0x93, 0x27}, // ID - /*ATtiny827*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0080, 32, 0x3c00, 0x0400, // Mem + /*ATtiny827*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0080, 32, 0x3c00, 0x0400, // Mem /*ATtiny827*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny827*/ 308, rgftab_attiny426}, // Register file //ATtiny1604 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny1604", 304, F_AVR8X, {0x1E, 0x94, 0x25}, // ID - /*ATtiny1604*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem + /*ATtiny1604*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem /*ATtiny1604*/ 10, 1, 31, vtab_attiny1607, 15, cfgtab_attiny804, // ISRs, Config /*ATtiny1604*/ 255, rgftab_attiny804}, // Register file //ATtiny1606 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny1606", 305, F_AVR8X, {0x1E, 0x94, 0x24}, // ID - /*ATtiny1606*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem + /*ATtiny1606*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem /*ATtiny1606*/ 10, 1, 31, vtab_attiny1607, 15, cfgtab_attiny804, // ISRs, Config /*ATtiny1606*/ 255, rgftab_attiny804}, // Register file //ATtiny1607 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny1607", 306, F_AVR8X, {0x1E, 0x94, 0x23}, // ID - /*ATtiny1607*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem + /*ATtiny1607*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem /*ATtiny1607*/ 10, 1, 31, vtab_attiny1607, 15, cfgtab_attiny804, // ISRs, Config /*ATtiny1607*/ 255, rgftab_attiny804}, // Register file //ATtiny1614 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny1614", 307, F_AVR8X, {0x1E, 0x94, 0x22}, // ID - /*ATtiny1614*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem + /*ATtiny1614*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem /*ATtiny1614*/ 10, 1, 31, vtab_attiny1614, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny1614*/ 308, rgftab_attiny1614}, // Register file //ATtiny1616 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny1616", 308, F_AVR8X, {0x1E, 0x94, 0x21}, // ID - /*ATtiny1616*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem + /*ATtiny1616*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem /*ATtiny1616*/ 10, 1, 31, vtab_attiny3217, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny1616*/ 326, rgftab_attiny1616}, // Register file //ATtiny1617 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny1617", 309, F_AVR8X, {0x1E, 0x94, 0x20}, // ID - /*ATtiny1617*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem + /*ATtiny1617*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem /*ATtiny1617*/ 10, 1, 31, vtab_attiny3217, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny1617*/ 326, rgftab_attiny1616}, // Register file //ATtiny1624 atdf, avrdude // Sources {"ATtiny1624", 310, F_AVR8X, {0x1E, 0x94, 0x2A}, // ID - /*ATtiny1624*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem + /*ATtiny1624*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem /*ATtiny1624*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny1624*/ 307, rgftab_attiny1624}, // Register file //ATtiny1626 atdf, avrdude // Sources {"ATtiny1626", 311, F_AVR8X, {0x1E, 0x94, 0x29}, // ID - /*ATtiny1626*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem + /*ATtiny1626*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem /*ATtiny1626*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny1626*/ 308, rgftab_attiny426}, // Register file //ATtiny1627 atdf, avrdude // Sources {"ATtiny1627", 312, F_AVR8X, {0x1E, 0x94, 0x28}, // ID - /*ATtiny1627*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem + /*ATtiny1627*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem /*ATtiny1627*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny1627*/ 308, rgftab_attiny426}, // Register file @@ -2041,433 +2066,433 @@ const Avrintel uP_table[] = { // Value of -1 typically means unknown //ATtiny3216 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny3216", 314, F_AVR8X, {0x1E, 0x95, 0x21}, // ID - /*ATtiny3216*/ 0, 0x08000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x3800, 0x0800, // Mem + /*ATtiny3216*/ 0, 0x08000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x3800, 0x0800, // Mem /*ATtiny3216*/ 10, 1, 31, vtab_attiny3217, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny3216*/ 326, rgftab_attiny3216}, // Register file //ATtiny3217 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATtiny3217", 315, F_AVR8X, {0x1E, 0x95, 0x22}, // ID - /*ATtiny3217*/ 0, 0x08000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x3800, 0x0800, // Mem + /*ATtiny3217*/ 0, 0x08000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x3800, 0x0800, // Mem /*ATtiny3217*/ 10, 1, 31, vtab_attiny3217, 23, cfgtab_attiny204, // ISRs, Config /*ATtiny3217*/ 326, rgftab_attiny3216}, // Register file //ATtiny3224 atdf, avrdude // Sources {"ATtiny3224", 316, F_AVR8X, {0x1E, 0x95, 0x28}, // ID - /*ATtiny3224*/ 0, 0x08000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x3400, 0x0c00, // Mem + /*ATtiny3224*/ 0, 0x08000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x3400, 0x0c00, // Mem /*ATtiny3224*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny3224*/ 307, rgftab_attiny1624}, // Register file //ATtiny3226 atdf, avrdude // Sources {"ATtiny3226", 317, F_AVR8X, {0x1E, 0x95, 0x27}, // ID - /*ATtiny3226*/ 0, 0x08000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x3400, 0x0c00, // Mem + /*ATtiny3226*/ 0, 0x08000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x3400, 0x0c00, // Mem /*ATtiny3226*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny3226*/ 308, rgftab_attiny426}, // Register file //ATtiny3227 atdf, avrdude // Sources {"ATtiny3227", 318, F_AVR8X, {0x1E, 0x95, 0x26}, // ID - /*ATtiny3227*/ 0, 0x08000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x3400, 0x0c00, // Mem + /*ATtiny3227*/ 0, 0x08000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x3400, 0x0c00, // Mem /*ATtiny3227*/ 10, 1, 30, vtab_attiny3227, 16, cfgtab_attiny1624, // ISRs, Config /*ATtiny3227*/ 308, rgftab_attiny426}, // Register file //ATmega808 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATmega808", 319, F_AVR8X, {0x1E, 0x93, 0x26}, // ID - /*ATmega808*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem + /*ATmega808*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem /*ATmega808*/ 10, 1, 36, vtab_atmega4808, 15, cfgtab_atmega808, // ISRs, Config /*ATmega808*/ 406, rgftab_atmega808}, // Register file //ATmega809 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATmega809", 320, F_AVR8X, {0x1E, 0x93, 0x2A}, // ID - /*ATmega809*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem + /*ATmega809*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3c00, 0x0400, // Mem /*ATmega809*/ 10, 1, 40, vtab_atmega4809, 15, cfgtab_atmega808, // ISRs, Config /*ATmega809*/ 432, rgftab_atmega809}, // Register file //ATmega1608 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATmega1608", 321, F_AVR8X, {0x1E, 0x94, 0x27}, // ID - /*ATmega1608*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem + /*ATmega1608*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem /*ATmega1608*/ 10, 1, 36, vtab_atmega4808, 15, cfgtab_atmega808, // ISRs, Config /*ATmega1608*/ 406, rgftab_atmega808}, // Register file //ATmega1609 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATmega1609", 322, F_AVR8X, {0x1E, 0x94, 0x26}, // ID - /*ATmega1609*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem + /*ATmega1609*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0100, 32, 0x3800, 0x0800, // Mem /*ATmega1609*/ 10, 1, 40, vtab_atmega4809, 15, cfgtab_atmega808, // ISRs, Config /*ATmega1609*/ 432, rgftab_atmega809}, // Register file //ATmega3208 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATmega3208", 323, F_AVR8X, {0x1E, 0x95, 0x30}, // ID - /*ATmega3208*/ 0, 0x08000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x3000, 0x1000, // Mem + /*ATmega3208*/ 0, 0x08000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x3000, 0x1000, // Mem /*ATmega3208*/ 10, 1, 36, vtab_atmega4808, 15, cfgtab_atmega808, // ISRs, Config /*ATmega3208*/ 406, rgftab_atmega3208}, // Register file //ATmega3209 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATmega3209", 324, F_AVR8X, {0x1E, 0x95, 0x31}, // ID - /*ATmega3209*/ 0, 0x08000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x3000, 0x1000, // Mem + /*ATmega3209*/ 0, 0x08000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x3000, 0x1000, // Mem /*ATmega3209*/ 10, 1, 40, vtab_atmega4809, 15, cfgtab_atmega808, // ISRs, Config /*ATmega3209*/ 432, rgftab_atmega3209}, // Register file //ATmega4808 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATmega4808", 325, F_AVR8X, {0x1E, 0x96, 0x50}, // ID - /*ATmega4808*/ 0, 0x0c000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x2800, 0x1800, // Mem + /*ATmega4808*/ 0, 0x0c000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x2800, 0x1800, // Mem /*ATmega4808*/ 10, 1, 36, vtab_atmega4808, 15, cfgtab_atmega808, // ISRs, Config /*ATmega4808*/ 406, rgftab_atmega3208}, // Register file //ATmega4809 atdf, avr-gcc 12.2.0, avrdude // Sources {"ATmega4809", 326, F_AVR8X, {0x1E, 0x96, 0x51}, // ID - /*ATmega4809*/ 0, 0x0c000, 0x080, 1, 0, 0x01400, 0x0100, 64, 0x2800, 0x1800, // Mem + /*ATmega4809*/ 0, 0x0c000, 0x080, 1, 0x0100, 0x01400, 0x0100, 64, 0x2800, 0x1800, // Mem /*ATmega4809*/ 10, 1, 40, vtab_atmega4809, 15, cfgtab_atmega808, // ISRs, Config /*ATmega4809*/ 432, rgftab_atmega3209}, // Register file //AVR8EA28 avrdude // Sources {"AVR8EA28", 327, F_AVR8X, {0x1E, 0x93, 0x2C}, // ID - /*AVR8EA28*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0200, 8, -1, -1, // Mem + /*AVR8EA28*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, -1, -1, // Mem /*AVR8EA28*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AVR8EA28*/ 0, NULL}, // Register file //AVR8EA32 avrdude // Sources {"AVR8EA32", 328, F_AVR8X, {0x1E, 0x93, 0x2B}, // ID - /*AVR8EA32*/ 0, 0x02000, 0x040, 1, 0, 0x01400, 0x0200, 8, -1, -1, // Mem + /*AVR8EA32*/ 0, 0x02000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, -1, -1, // Mem /*AVR8EA32*/ -1, -1, 0, NULL, 0, NULL, // ISRs, Config /*AVR8EA32*/ 0, NULL}, // Register file //AVR16DD14 atdf, avrdude // Sources {"AVR16DD14", 329, F_AVR8X, {0x1E, 0x94, 0x34}, // ID - /*AVR16DD14*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DD14*/ 0, 0x04000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DD14*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD14*/ 401, rgftab_avr32dd14}, // Register file //AVR16DU14 atdf, avrdude // Sources {"AVR16DU14", 386, F_AVR8X, {0x1E, 0x94, 0x3B}, // ID - /*AVR16DU14*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DU14*/ 0, 0x04000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DU14*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR16DU14*/ 371, rgftab_avr16du14}, // Register file //AVR16EB14 atdf, avrdude // Sources {"AVR16EB14", 380, F_AVR8X, {0x1E, 0x94, 0x49}, // ID - /*AVR16EB14*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem + /*AVR16EB14*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem /*AVR16EB14*/ 16, 4, 31, vtab_avr16eb32, 18, cfgtab_avr16eb14, // ISRs, Config /*AVR16EB14*/ 391, rgftab_avr16eb14}, // Register file //AVR16DD20 atdf, avrdude // Sources {"AVR16DD20", 330, F_AVR8X, {0x1E, 0x94, 0x33}, // ID - /*AVR16DD20*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DD20*/ 0, 0x04000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DD20*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD20*/ 401, rgftab_avr32dd14}, // Register file //AVR16DU20 atdf, avrdude // Sources {"AVR16DU20", 387, F_AVR8X, {0x1E, 0x94, 0x3A}, // ID - /*AVR16DU20*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DU20*/ 0, 0x04000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DU20*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR16DU20*/ 372, rgftab_avr16du20}, // Register file //AVR16EB20 atdf, avrdude // Sources {"AVR16EB20", 381, F_AVR8X, {0x1E, 0x94, 0x40}, // ID - /*AVR16EB20*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem + /*AVR16EB20*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem /*AVR16EB20*/ 16, 4, 31, vtab_avr16eb32, 18, cfgtab_avr16eb14, // ISRs, Config /*AVR16EB20*/ 393, rgftab_avr16eb20}, // Register file //AVR16DD28 atdf, avrdude // Sources {"AVR16DD28", 331, F_AVR8X, {0x1E, 0x94, 0x32}, // ID - /*AVR16DD28*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DD28*/ 0, 0x04000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DD28*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD28*/ 401, rgftab_avr32dd14}, // Register file //AVR16DU28 atdf, avrdude // Sources {"AVR16DU28", 388, F_AVR8X, {0x1E, 0x94, 0x39}, // ID - /*AVR16DU28*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DU28*/ 0, 0x04000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR16DU28*/ 372, rgftab_avr16du20}, // Register file //AVR16EA28 atdf, avrdude // Sources {"AVR16EA28", 332, F_AVR8X, {0x1E, 0x94, 0x37}, // ID - /*AVR16EA28*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem + /*AVR16EA28*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem /*AVR16EA28*/ 16, 4, 37, vtab_avr64ea32, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR16EA28*/ 402, rgftab_avr16ea28}, // Register file //AVR16EB28 atdf, avrdude // Sources {"AVR16EB28", 382, F_AVR8X, {0x1E, 0x94, 0x3F}, // ID - /*AVR16EB28*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem + /*AVR16EB28*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem /*AVR16EB28*/ 16, 4, 31, vtab_avr16eb32, 18, cfgtab_avr16eb14, // ISRs, Config /*AVR16EB28*/ 393, rgftab_avr16eb20}, // Register file //AVR16DD32 atdf, avrdude // Sources {"AVR16DD32", 333, F_AVR8X, {0x1E, 0x94, 0x31}, // ID - /*AVR16DD32*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DD32*/ 0, 0x04000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DD32*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR16DD32*/ 401, rgftab_avr32dd14}, // Register file //AVR16DU32 atdf, avrdude // Sources {"AVR16DU32", 389, F_AVR8X, {0x1E, 0x94, 0x38}, // ID - /*AVR16DU32*/ 0, 0x04000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem + /*AVR16DU32*/ 0, 0x04000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7800, 0x0800, // Mem /*AVR16DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR16DU32*/ 372, rgftab_avr16du20}, // Register file //AVR16EA32 atdf, avrdude // Sources {"AVR16EA32", 334, F_AVR8X, {0x1E, 0x94, 0x36}, // ID - /*AVR16EA32*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem + /*AVR16EA32*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem /*AVR16EA32*/ 16, 4, 37, vtab_avr64ea32, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR16EA32*/ 402, rgftab_avr16ea28}, // Register file //AVR16EB32 atdf, avrdude // Sources {"AVR16EB32", 383, F_AVR8X, {0x1E, 0x94, 0x3E}, // ID - /*AVR16EB32*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem + /*AVR16EB32*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem /*AVR16EB32*/ 16, 4, 31, vtab_avr16eb32, 18, cfgtab_avr16eb14, // ISRs, Config /*AVR16EB32*/ 393, rgftab_avr16eb20}, // Register file //AVR16EA48 atdf, avrdude // Sources {"AVR16EA48", 335, F_AVR8X, {0x1E, 0x94, 0x35}, // ID - /*AVR16EA48*/ 0, 0x04000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem + /*AVR16EA48*/ 0, 0x04000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7800, 0x0800, // Mem /*AVR16EA48*/ 16, 4, 45, vtab_avr64ea48, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR16EA48*/ 502, rgftab_avr64ea48}, // Register file //AVR32DD14 atdf, avrdude // Sources {"AVR32DD14", 336, F_AVR8X, {0x1E, 0x95, 0x3B}, // ID - /*AVR32DD14*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DD14*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DD14*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD14*/ 401, rgftab_avr32dd14}, // Register file //AVR32DU14 atdf, avrdude // Sources {"AVR32DU14", 390, F_AVR8X, {0x1E, 0x95, 0x4F}, // ID - /*AVR32DU14*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DU14*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DU14*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR32DU14*/ 371, rgftab_avr16du14}, // Register file //AVR32DD20 atdf, avrdude // Sources {"AVR32DD20", 337, F_AVR8X, {0x1E, 0x95, 0x3A}, // ID - /*AVR32DD20*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DD20*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DD20*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD20*/ 401, rgftab_avr32dd14}, // Register file //AVR32DU20 atdf, avrdude // Sources {"AVR32DU20", 391, F_AVR8X, {0x1E, 0x95, 0x4E}, // ID - /*AVR32DU20*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DU20*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DU20*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR32DU20*/ 372, rgftab_avr16du20}, // Register file //AVR32DA28 atdf, avrdude // Sources {"AVR32DA28", 338, F_AVR8X, {0x1E, 0x95, 0x34}, // ID - /*AVR32DA28*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem + /*AVR32DA28*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem /*AVR32DA28*/ 16, 4, 41, vtab_avr128da28, 15, cfgtab_avr32da28, // ISRs, Config /*AVR32DA28*/ 432, rgftab_avr32da28}, // Register file //AVR32DB28 atdf, avrdude // Sources {"AVR32DB28", 339, F_AVR8X, {0x1E, 0x95, 0x37}, // ID - /*AVR32DB28*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem + /*AVR32DB28*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem /*AVR32DB28*/ 16, 4, 42, vtab_avr128db28, 16, cfgtab_avr32db28, // ISRs, Config /*AVR32DB28*/ 462, rgftab_avr32db28}, // Register file //AVR32DD28 atdf, avrdude // Sources {"AVR32DD28", 340, F_AVR8X, {0x1E, 0x95, 0x39}, // ID - /*AVR32DD28*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DD28*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DD28*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD28*/ 401, rgftab_avr32dd14}, // Register file //AVR32DU28 atdf, avrdude // Sources {"AVR32DU28", 392, F_AVR8X, {0x1E, 0x95, 0x40}, // ID - /*AVR32DU28*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DU28*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR32DU28*/ 372, rgftab_avr16du20}, // Register file //AVR32EA28 atdf, avrdude // Sources {"AVR32EA28", 341, F_AVR8X, {0x1E, 0x95, 0x3E}, // ID - /*AVR32EA28*/ 0, 0x08000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7000, 0x1000, // Mem + /*AVR32EA28*/ 0, 0x08000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7000, 0x1000, // Mem /*AVR32EA28*/ 16, 4, 37, vtab_avr64ea32, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR32EA28*/ 402, rgftab_avr16ea28}, // Register file //AVR32DA32 atdf, avrdude // Sources {"AVR32DA32", 342, F_AVR8X, {0x1E, 0x95, 0x33}, // ID - /*AVR32DA32*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem + /*AVR32DA32*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem /*AVR32DA32*/ 16, 4, 44, vtab_avr128da32, 15, cfgtab_avr32da28, // ISRs, Config /*AVR32DA32*/ 447, rgftab_avr32da32}, // Register file //AVR32DB32 atdf, avrdude // Sources {"AVR32DB32", 343, F_AVR8X, {0x1E, 0x95, 0x36}, // ID - /*AVR32DB32*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem + /*AVR32DB32*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem /*AVR32DB32*/ 16, 4, 44, vtab_avr128db32, 16, cfgtab_avr32db28, // ISRs, Config /*AVR32DB32*/ 477, rgftab_avr32db32}, // Register file //AVR32DD32 atdf, avrdude // Sources {"AVR32DD32", 344, F_AVR8X, {0x1E, 0x95, 0x38}, // ID - /*AVR32DD32*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DD32*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DD32*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR32DD32*/ 401, rgftab_avr32dd14}, // Register file //AVR32DU32 atdf, avrdude // Sources {"AVR32DU32", 393, F_AVR8X, {0x1E, 0x95, 0x3F}, // ID - /*AVR32DU32*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem + /*AVR32DU32*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x7000, 0x1000, // Mem /*AVR32DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR32DU32*/ 372, rgftab_avr16du20}, // Register file //AVR32EA32 atdf, avrdude // Sources {"AVR32EA32", 345, F_AVR8X, {0x1E, 0x95, 0x3D}, // ID - /*AVR32EA32*/ 0, 0x08000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7000, 0x1000, // Mem + /*AVR32EA32*/ 0, 0x08000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7000, 0x1000, // Mem /*AVR32EA32*/ 16, 4, 37, vtab_avr64ea32, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR32EA32*/ 402, rgftab_avr16ea28}, // Register file //AVR32DA48 atdf, avrdude // Sources {"AVR32DA48", 346, F_AVR8X, {0x1E, 0x95, 0x32}, // ID - /*AVR32DA48*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem + /*AVR32DA48*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem /*AVR32DA48*/ 16, 4, 58, vtab_avr128da48, 15, cfgtab_avr32da28, // ISRs, Config /*AVR32DA48*/ 600, rgftab_avr32da48}, // Register file //AVR32DB48 atdf, avrdude // Sources {"AVR32DB48", 347, F_AVR8X, {0x1E, 0x95, 0x35}, // ID - /*AVR32DB48*/ 0, 0x08000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem + /*AVR32DB48*/ 0, 0x08000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x7000, 0x1000, // Mem /*AVR32DB48*/ 16, 4, 61, vtab_avr128db48, 16, cfgtab_avr32db28, // ISRs, Config /*AVR32DB48*/ 643, rgftab_avr32db48}, // Register file //AVR32EA48 atdf, avrdude // Sources {"AVR32EA48", 348, F_AVR8X, {0x1E, 0x95, 0x3C}, // ID - /*AVR32EA48*/ 0, 0x08000, 0x040, 1, 0, 0x01400, 0x0200, 8, 0x7000, 0x1000, // Mem + /*AVR32EA48*/ 0, 0x08000, 0x040, 1, 0x0100, 0x01400, 0x0200, 8, 0x7000, 0x1000, // Mem /*AVR32EA48*/ 16, 4, 45, vtab_avr64ea48, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR32EA48*/ 502, rgftab_avr64ea48}, // Register file //AVR64DD14 atdf, avrdude // Sources {"AVR64DD14", 349, F_AVR8X, {0x1E, 0x96, 0x1D}, // ID - /*AVR64DD14*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem + /*AVR64DD14*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem /*AVR64DD14*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR64DD14*/ 401, rgftab_avr32dd14}, // Register file //AVR64DD20 atdf, avrdude // Sources {"AVR64DD20", 350, F_AVR8X, {0x1E, 0x96, 0x1C}, // ID - /*AVR64DD20*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem + /*AVR64DD20*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem /*AVR64DD20*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR64DD20*/ 401, rgftab_avr32dd14}, // Register file //AVR64DA28 atdf, avrdude // Sources {"AVR64DA28", 351, F_AVR8X, {0x1E, 0x96, 0x15}, // ID - /*AVR64DA28*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem + /*AVR64DA28*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem /*AVR64DA28*/ 16, 4, 41, vtab_avr128da28, 15, cfgtab_avr32da28, // ISRs, Config /*AVR64DA28*/ 433, rgftab_avr64da28}, // Register file //AVR64DB28 atdf, avrdude // Sources {"AVR64DB28", 352, F_AVR8X, {0x1E, 0x96, 0x19}, // ID - /*AVR64DB28*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem + /*AVR64DB28*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem /*AVR64DB28*/ 16, 4, 42, vtab_avr128db28, 16, cfgtab_avr32db28, // ISRs, Config /*AVR64DB28*/ 462, rgftab_avr32db28}, // Register file //AVR64DD28 atdf, avrdude // Sources {"AVR64DD28", 353, F_AVR8X, {0x1E, 0x96, 0x1B}, // ID - /*AVR64DD28*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem + /*AVR64DD28*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem /*AVR64DD28*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR64DD28*/ 401, rgftab_avr32dd14}, // Register file //AVR64DU28 atdf, avrdude // Sources {"AVR64DU28", 384, F_AVR8X, {0x1E, 0x96, 0x22}, // ID - /*AVR64DU28*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem + /*AVR64DU28*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem /*AVR64DU28*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR64DU28*/ 372, rgftab_avr16du20}, // Register file //AVR64EA28 atdf, avrdude // Sources {"AVR64EA28", 354, F_AVR8X, {0x1E, 0x96, 0x20}, // ID - /*AVR64EA28*/ 0, 0x10000, 0x080, 1, 0, 0x01400, 0x0200, 8, 0x6800, 0x1800, // Mem + /*AVR64EA28*/ 0, 0x10000, 0x080, 1, 0x0100, 0x01400, 0x0200, 8, 0x6800, 0x1800, // Mem /*AVR64EA28*/ 16, 4, 37, vtab_avr64ea32, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR64EA28*/ 402, rgftab_avr16ea28}, // Register file //AVR64DA32 atdf, avrdude // Sources {"AVR64DA32", 355, F_AVR8X, {0x1E, 0x96, 0x14}, // ID - /*AVR64DA32*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem + /*AVR64DA32*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem /*AVR64DA32*/ 16, 4, 44, vtab_avr128da32, 15, cfgtab_avr32da28, // ISRs, Config /*AVR64DA32*/ 448, rgftab_avr64da32}, // Register file //AVR64DB32 atdf, avrdude // Sources {"AVR64DB32", 356, F_AVR8X, {0x1E, 0x96, 0x18}, // ID - /*AVR64DB32*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem + /*AVR64DB32*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem /*AVR64DB32*/ 16, 4, 44, vtab_avr128db32, 16, cfgtab_avr32db28, // ISRs, Config /*AVR64DB32*/ 477, rgftab_avr32db32}, // Register file //AVR64DD32 atdf, avrdude // Sources {"AVR64DD32", 357, F_AVR8X, {0x1E, 0x96, 0x1A}, // ID - /*AVR64DD32*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem + /*AVR64DD32*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem /*AVR64DD32*/ 16, 4, 36, vtab_avr64dd32, 17, cfgtab_avr32dd14, // ISRs, Config /*AVR64DD32*/ 401, rgftab_avr32dd14}, // Register file //AVR64DU32 atdf, avrdude // Sources {"AVR64DU32", 385, F_AVR8X, {0x1E, 0x96, 0x21}, // ID - /*AVR64DU32*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem + /*AVR64DU32*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0100, 1, 0x6000, 0x2000, // Mem /*AVR64DU32*/ 16, 4, 34, vtab_avr64du32, 20, cfgtab_avr16du14, // ISRs, Config /*AVR64DU32*/ 372, rgftab_avr16du20}, // Register file //AVR64EA32 atdf, avrdude // Sources {"AVR64EA32", 358, F_AVR8X, {0x1E, 0x96, 0x1F}, // ID - /*AVR64EA32*/ 0, 0x10000, 0x080, 1, 0, 0x01400, 0x0200, 8, 0x6800, 0x1800, // Mem + /*AVR64EA32*/ 0, 0x10000, 0x080, 1, 0x0100, 0x01400, 0x0200, 8, 0x6800, 0x1800, // Mem /*AVR64EA32*/ 16, 4, 37, vtab_avr64ea32, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR64EA32*/ 402, rgftab_avr16ea28}, // Register file //AVR64DA48 atdf, avrdude // Sources {"AVR64DA48", 359, F_AVR8X, {0x1E, 0x96, 0x13}, // ID - /*AVR64DA48*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem + /*AVR64DA48*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem /*AVR64DA48*/ 16, 4, 58, vtab_avr128da48, 15, cfgtab_avr32da28, // ISRs, Config /*AVR64DA48*/ 601, rgftab_avr64da48}, // Register file //AVR64DB48 atdf, avrdude // Sources {"AVR64DB48", 360, F_AVR8X, {0x1E, 0x96, 0x17}, // ID - /*AVR64DB48*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem + /*AVR64DB48*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem /*AVR64DB48*/ 16, 4, 61, vtab_avr128db48, 16, cfgtab_avr32db28, // ISRs, Config /*AVR64DB48*/ 643, rgftab_avr32db48}, // Register file //AVR64EA48 atdf, avrdude // Sources {"AVR64EA48", 361, F_AVR8X, {0x1E, 0x96, 0x1E}, // ID - /*AVR64EA48*/ 0, 0x10000, 0x080, 1, 0, 0x01400, 0x0200, 8, 0x6800, 0x1800, // Mem + /*AVR64EA48*/ 0, 0x10000, 0x080, 1, 0x0100, 0x01400, 0x0200, 8, 0x6800, 0x1800, // Mem /*AVR64EA48*/ 16, 4, 45, vtab_avr64ea48, 16, cfgtab_avr64ea48, // ISRs, Config /*AVR64EA48*/ 502, rgftab_avr64ea48}, // Register file //AVR64DA64 atdf, avrdude // Sources {"AVR64DA64", 362, F_AVR8X, {0x1E, 0x96, 0x12}, // ID - /*AVR64DA64*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem + /*AVR64DA64*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem /*AVR64DA64*/ 16, 4, 64, vtab_avr128da64, 15, cfgtab_avr32da28, // ISRs, Config /*AVR64DA64*/ 659, rgftab_avr64da64}, // Register file //AVR64DB64 atdf, avrdude // Sources {"AVR64DB64", 363, F_AVR8X, {0x1E, 0x96, 0x16}, // ID - /*AVR64DB64*/ 0, 0x10000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem + /*AVR64DB64*/ 0, 0x10000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x6000, 0x2000, // Mem /*AVR64DB64*/ 16, 4, 65, vtab_avr128db64, 16, cfgtab_avr32db28, // ISRs, Config /*AVR64DB64*/ 698, rgftab_avr64db64}, // Register file //AVR128DA28 atdf, avrdude // Sources {"AVR128DA28", 364, F_AVR8X, {0x1E, 0x97, 0x0A}, // ID - /*AVR128DA28*/ 0, 0x20000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem + /*AVR128DA28*/ 0, 0x20000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem /*AVR128DA28*/ 16, 4, 41, vtab_avr128da28, 15, cfgtab_avr32da28, // ISRs, Config /*AVR128DA28*/ 433, rgftab_avr64da28}, // Register file //AVR128DB28 atdf, avrdude // Sources {"AVR128DB28", 365, F_AVR8X, {0x1E, 0x97, 0x0E}, // ID - /*AVR128DB28*/ 0, 0x20000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem + /*AVR128DB28*/ 0, 0x20000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem /*AVR128DB28*/ 16, 4, 42, vtab_avr128db28, 16, cfgtab_avr32db28, // ISRs, Config /*AVR128DB28*/ 462, rgftab_avr32db28}, // Register file //AVR128DA32 atdf, avrdude // Sources {"AVR128DA32", 366, F_AVR8X, {0x1E, 0x97, 0x09}, // ID - /*AVR128DA32*/ 0, 0x20000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem + /*AVR128DA32*/ 0, 0x20000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem /*AVR128DA32*/ 16, 4, 44, vtab_avr128da32, 15, cfgtab_avr32da28, // ISRs, Config /*AVR128DA32*/ 448, rgftab_avr64da32}, // Register file //AVR128DB32 atdf, avrdude // Sources {"AVR128DB32", 367, F_AVR8X, {0x1E, 0x97, 0x0D}, // ID - /*AVR128DB32*/ 0, 0x20000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem + /*AVR128DB32*/ 0, 0x20000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem /*AVR128DB32*/ 16, 4, 44, vtab_avr128db32, 16, cfgtab_avr32db28, // ISRs, Config /*AVR128DB32*/ 477, rgftab_avr32db32}, // Register file //AVR128DA48 atdf, avrdude // Sources {"AVR128DA48", 368, F_AVR8X, {0x1E, 0x97, 0x08}, // ID - /*AVR128DA48*/ 0, 0x20000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem + /*AVR128DA48*/ 0, 0x20000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem /*AVR128DA48*/ 16, 4, 58, vtab_avr128da48, 15, cfgtab_avr32da28, // ISRs, Config /*AVR128DA48*/ 601, rgftab_avr64da48}, // Register file //AVR128DB48 atdf, avrdude // Sources {"AVR128DB48", 369, F_AVR8X, {0x1E, 0x97, 0x0C}, // ID - /*AVR128DB48*/ 0, 0x20000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem + /*AVR128DB48*/ 0, 0x20000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem /*AVR128DB48*/ 16, 4, 61, vtab_avr128db48, 16, cfgtab_avr32db28, // ISRs, Config /*AVR128DB48*/ 643, rgftab_avr32db48}, // Register file //AVR128DA64 atdf, avrdude // Sources {"AVR128DA64", 370, F_AVR8X, {0x1E, 0x97, 0x07}, // ID - /*AVR128DA64*/ 0, 0x20000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem + /*AVR128DA64*/ 0, 0x20000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem /*AVR128DA64*/ 16, 4, 64, vtab_avr128da64, 15, cfgtab_avr32da28, // ISRs, Config /*AVR128DA64*/ 659, rgftab_avr64da64}, // Register file //AVR128DB64 atdf, avrdude // Sources {"AVR128DB64", 371, F_AVR8X, {0x1E, 0x97, 0x0B}, // ID - /*AVR128DB64*/ 0, 0x20000, 0x200, 1, 0, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem + /*AVR128DB64*/ 0, 0x20000, 0x200, 1, 0x0200, 0x01400, 0x0200, 1, 0x4000, 0x4000, // Mem /*AVR128DB64*/ 16, 4, 65, vtab_avr128db64, 16, cfgtab_avr32db28, // ISRs, Config /*AVR128DB64*/ 698, rgftab_avr64db64}, // Register file }; @@ -11430,8 +11455,8 @@ const Configitem cfgtab_attiny204[23] = { {"rstpincfg", 3, _values_rstpincfg_attiny204, "syscfg0", 5, 0x0c, 2, 1, "reset pin configuration"}, {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 7, "startup time"}, - {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of pages]"}, - {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of pages]"}, + {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of blocks]"}, + {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of blocks]"}, {"lb", 2, _values_lb_attiny204, "lock", 0, 0xff, 0, 0xc5, "lock bits"}, }; @@ -11453,8 +11478,8 @@ const Configitem cfgtab_attiny1624[16] = { {"toutdis", 2, _values_toutdis_attiny1624, "syscfg0", 5, 0x10, 4, 1, "timeout"}, {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 7, "startup time"}, - {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of pages]"}, - {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of pages]"}, + {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of blocks]"}, + {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of blocks]"}, {"lb", 2, _values_lb_attiny204, "lock", 0, 0xff, 0, 0xc5, "lock bits"}, }; @@ -11477,8 +11502,8 @@ const Configitem cfgtab_avr32dd14[17] = { {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 0, "startup time"}, {"mvsyscfg", 2, _values_mvsyscfg_avr32dd14, "syscfg1", 6, 0x18, 3, 1, "MVIO system configuration"}, - {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, - {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, + {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of blocks]"}, + {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of blocks]"}, {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, }; @@ -11497,8 +11522,8 @@ const Configitem cfgtab_avr64ea48[16] = { {"crcsel", 2, _values_crcsel_avr32dd14, "syscfg0", 5, 0x20, 5, 0, "CRC select"}, {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 7, "startup time"}, - {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, - {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, + {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of blocks]"}, + {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of blocks]"}, {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, }; @@ -12924,8 +12949,8 @@ const Configitem cfgtab_attiny416auto[23] = { {"rstpincfg", 3, _values_rstpincfg_attiny204, "syscfg0", 5, 0x0c, 2, 1, "reset pin configuration"}, {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 7, "startup time"}, - {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of pages]"}, - {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of pages]"}, + {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of blocks]"}, + {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of blocks]"}, {"lb", 2, _values_lb_attiny204, "lock", 0, 0xff, 0, 0xc5, "lock bits"}, }; @@ -12943,8 +12968,8 @@ const Configitem cfgtab_attiny804[15] = { {"rstpincfg", 3, _values_rstpincfg_attiny204, "syscfg0", 5, 0x0c, 2, 1, "reset pin configuration"}, {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 7, "startup time"}, - {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of pages]"}, - {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of pages]"}, + {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of blocks]"}, + {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of blocks]"}, {"lb", 2, _values_lb_attiny204, "lock", 0, 0xff, 0, 0xc5, "lock bits"}, }; @@ -12962,8 +12987,8 @@ const Configitem cfgtab_atmega808[15] = { {"rstpincfg", 2, _values_rstpincfg_avr32dd14, "syscfg0", 5, 0x08, 3, 0, "reset pin configuration"}, {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 7, "startup time"}, - {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of pages]"}, - {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of pages]"}, + {"append", 0, NULL, "append", 7, 0xff, 0, 0x00, "application code section end [# of blocks]"}, + {"bootend", 0, NULL, "bootend", 8, 0xff, 0, 0x00, "boot section end [# of blocks]"}, {"lb", 2, _values_lb_attiny204, "lock", 0, 0xff, 0, 0xc5, "lock bits"}, }; @@ -12987,8 +13012,8 @@ const Configitem cfgtab_avr16du14[20] = { {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 0, "startup time"}, {"usbsink", 2, _values_usbsink_avr16du14, "syscfg1", 6, 0x08, 3, 1, "USB Voltage Regulator Current Sink Enable"}, - {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, - {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, + {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of blocks]"}, + {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of blocks]"}, {"nvmlevel", 2, _values_nvmlevel_avr16du14, "pdicfg", 10, 0x03, 0, 3, "NVM protection level"}, {"nvmkey", 2, _values_nvmkey_avr16du14, "pdicfg", 10, 0xfff0, 4, 0x00, "NVM protection activation key"}, {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, @@ -13009,8 +13034,8 @@ const Configitem cfgtab_avr16eb14[18] = { {"crcsel", 2, _values_crcsel_avr32dd14, "syscfg0", 5, 0x20, 5, 0, "CRC select"}, {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 7, "startup time"}, - {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, - {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, + {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of blocks]"}, + {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of blocks]"}, {"nvmlevel", 2, _values_nvmlevel_avr16eb14, "pdicfg", 10, 0x03, 0, 3, "NVM protection level"}, {"nvmkey", 2, _values_nvmkey_avr16du14, "pdicfg", 10, 0xfff0, 4, 0x00, "NVM protection activation key"}, {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, @@ -13033,8 +13058,8 @@ const Configitem cfgtab_avr32da28[15] = { {"crcsel", 2, _values_crcsel_avr32dd14, "syscfg0", 5, 0x20, 5, 0, "CRC select"}, {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 0, "startup time"}, - {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, - {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, + {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of blocks]"}, + {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of blocks]"}, {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, }; @@ -13056,8 +13081,8 @@ const Configitem cfgtab_avr32db28[16] = { {"crcsrc", 4, _values_crcsrc_attiny204, "syscfg0", 5, 0xc0, 6, 3, "CRC source"}, {"sut", 8, _values_sut_attiny204, "syscfg1", 6, 0x07, 0, 0, "startup time"}, {"mvsyscfg", 2, _values_mvsyscfg_avr32dd14, "syscfg1", 6, 0x18, 3, 1, "MVIO system configuration"}, - {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of pages]"}, - {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of pages]"}, + {"codesize", 0, NULL, "codesize", 7, 0xff, 0, 0x00, "code section size [# of blocks]"}, + {"bootsize", 0, NULL, "bootsize", 8, 0xff, 0, 0x00, "boot section size [# of blocks]"}, {"key", 2, _values_key_avr32dd14, "lock", 0, 0xffffffff, 0, 0x5cc5c55c, "lock key"}, }; diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index a7732ef1..463fbd6b 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -11,8 +11,8 @@ * Published under GNU General Public License, version 3 (GPL-3.0) * Meta-author Stefan Rueger * - * v 1.3 - * 20.05.2024 + * v 1.39 + * 25.06.2024 * */ @@ -55,7 +55,7 @@ typedef struct { // Value of -1 typically means unknown uint16_t mcuid; // ID of MCU in 0..2039 uint8_t avrarch; // F_AVR8L, F_AVR8, F_XMEGA or F_AVR8X uint8_t sigs[3]; // Signature bytes - int32_t flashoffset; // Flash offset + int32_t flashoffset; // Flash offset in dual-chip MCUs (not flash->offset) int32_t flashsize; // Flash size int16_t pagesize; // Flash page size int8_t nboots; // Number of supported boot sections From 76353b8218c153578bdb2f1aad07576ca57fd8f4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 25 Jun 2024 01:25:33 +0100 Subject: [PATCH 191/422] Provide str_is_in_list() --- src/libavrdude.h | 1 + src/strutil.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index 98f3970f..65b5459e 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1474,6 +1474,7 @@ int str_casematch(const char *pattern, const char *string); int str_matched_by(const char *string, const char *pattern); int str_casematched_by(const char *string, const char *pattern); int str_is_pattern(const char *str); +int str_is_in_list(const char *s, const char **l, size_t nl, int (*f)(const char *, const char*)); char *str_sprintf(const char *fmt, ...) #if defined(__GNUC__) // Ask gcc to check whether format and parameters match __attribute__ ((format (printf, 1, 2))) diff --git a/src/strutil.c b/src/strutil.c index a5c8b01e..41971116 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -228,6 +228,14 @@ int str_is_pattern(const char *str) { } } +// Is the string s in the list l of strings as matched by f(s, l[i])? +int str_is_in_list(const char *s, const char **l, size_t nl, int (*f)(const char *, const char*)) { + for(size_t i=0; i Date: Tue, 25 Jun 2024 23:02:43 +0100 Subject: [PATCH 192/422] Initialise memories on -c dryrun -xinit or -xrandom $ avrdude -c dryrun -xhelp avrdude -c dryrun extended options: -xinit Initialise memories with human-readable patterns (1, 2, 3) -xrandom Initialise memories with random code/values (1, 3) -xseed= Seed random number generator with , default time(NULL) -xhelp Show this help menu and exit Notes: (1) -xinit and -xrandom randomly configure flash wrt boot/data/code length (2) Patterns can best be seen with fixed-width font on -U flash:r:-:I (3) Choose, eg, -xseed=1 for reproducible flash configuration and output For example: $ avrdude -c dryrun -p 16eb28 -xinit -xseed=7 -UALL:r:backup-dry.hex:I backup-dry.hex will be a human-readable multi-memory .hex file for testing that has memories initialised with non-trivial contents. Great care has been taken that the generated flash code is valid and benign, ie, it won't touch I/O peripherals, SRAM or flash. Can be restored with $ avrdude -cdryrun -p 16eb28 -U ALL:w:backup-dry.hex --- src/dryrun.c | 721 +++++++++++++++++++++++++++++++++++++++-------- src/libavrdude.h | 1 + 2 files changed, 601 insertions(+), 121 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index 6c0ec8dd..4da51982 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -1,6 +1,6 @@ /* * AVRDUDE - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2022 Stefan Rueger + * Copyright (C) 2022- Stefan Rueger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,13 +52,21 @@ typedef enum { typedef struct { AVRPART *dp; Dry_prog bl; // Bootloader and, if so, at top/bottom of flash? - int blsize; // Bootloader size min(flash size/4, 512) + int init; // Initialise memories with something interesting + int random; // Random initialisation of memories + int seed; // Seed for random number generator + // Flash configuration irrespective of -c programming is bootloading or not + int appstart, appsize; // Start and size of application section + int datastart, datasize; // Start and size of application data section (if any) + int bootstart, bootsize; // Start and size of boot section (if any) } Dryrun_data; // Use private programmer data as if they were a global structure dry #define dry (*(Dryrun_data *)(pgm->cookie)) #define Return(...) do { pmsg_error(__VA_ARGS__); msg_error("\n"); return -1; } while (0) +#define Retwarning(...) do { pmsg_warning(__VA_ARGS__); \ + msg_warning("; not initialising %s memories\n", p->desc); return -1; } while (0) static int dryrun_readonly(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned int addr); @@ -119,114 +127,561 @@ static int dryrun_program_enable(const PROGRAMMER *pgm, const AVRPART *p_unused) return 0; } +// Randomly set configuration values for bootloading, bootloader size and codesize, if any +static void randflashconfig(const PROGRAMMER *pgm, const AVRPART *p, + const Avrintel *up, const Configitem *cp, int nc) { + + if(up && p->prog_modes & PM_UPDI) { + int sectorsize = up->bootsize > 0? up->bootsize: 256; + int nsectors = up->flashsize/sectorsize; + int bootsize = random() % (nsectors > 4? nsectors/4: nsectors); + int codesize = !bootsize || random()%3? 0: bootsize + random()%(nsectors - bootsize); + + int size = !!avr_locate_config(cp, nc, "bootsize", str_eq); + avr_set_config_value(pgm, p, size? "bootsize": "bootend", bootsize); + avr_set_config_value(pgm, p, size? "codesize": "append", codesize); + } else if(up && up->nboots >0 && (p->prog_modes & (PM_Classic | PM_PDI))) { + avr_set_config_value(pgm, p, "bootrst", random() % 2); + if(up->nboots == 4) + avr_set_config_value(pgm, p, "bootsz", random() % 4); + } +} + +// Compute app, data and boot start/size +static int flashlayout(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *flm, + const Avrintel *up, const Configitem *cp, int nc) { + + AVRMEM *m; + + if(p->prog_modes & PM_UPDI) { + int nbootsec = 0, ncodesec = 0; + + int size = !!avr_locate_config(cp, nc, "bootsize", str_eq); + avr_get_config_value(pgm, p, size? "bootsize": "bootend", &nbootsec); + avr_get_config_value(pgm, p, size? "codesize": "append", &ncodesec); + if(nbootsec == 0 || (ncodesec && ncodesec <= nbootsec)) { // Treat boot section for code + dry.bootstart = 0, dry.bootsize = 0; + dry.appstart = 0, dry.appsize = nbootsec? nbootsec*up->bootsize: up->flashsize; + } else { // Distinct boot and application section + dry.bootstart = 0, dry.bootsize = nbootsec*up->bootsize; + dry.appstart = dry.bootsize; + dry.appsize = ncodesec? (ncodesec - nbootsec) * up->bootsize: up->flashsize - dry.appstart; + } + dry.datasize = up->flashsize - dry.bootsize - dry.appsize; // Remainder is apptable + dry.datastart = dry.datasize? dry.bootsize + dry.appsize: 0; + } else if(p->prog_modes & (PM_Classic | PM_PDI)) { + dry.bootstart = 0, dry.bootsize = 0; + if(up->nboots) { + int bootrst = 1; + avr_get_config_value(pgm, p, "bootrst", &bootrst); + if(bootrst == 0) { // Jump to bootloader on reset + if((p->prog_modes & PM_PDI) && (m = avr_locate_boot(p)) && m->size > 0) { + dry.bootstart = m->offset - flm->offset; + dry.bootsize = m->size; + } else if(p->prog_modes & PM_Classic) { + if(up->nboots == 4) { + int bootsz = 0; + avr_get_config_value(pgm, p, "bootsz", &bootsz); + dry.bootsize = (8>>bootsz) * up->bootsize; + } else + dry.bootsize = up->bootsize; + dry.bootstart = up->flashsize - dry.bootsize; + } + } + } + dry.datastart = 0, dry.datasize = 0; + if((p->prog_modes & PM_PDI) && (m = avr_locate_apptable(p)) && m->size > 0) { + dry.datastart = m->offset - flm->offset; + dry.datasize = up->flashsize - dry.datastart - dry.bootsize; + } + dry.appstart = 0, dry.appsize = up->flashsize - dry.datasize - dry.bootsize; + } + + // Sanity checks + if(dry.appsize < 0) + Retwarning("negative application size"); + if(dry.appstart < 0 || dry.appstart+dry.appsize > up->flashsize) + Retwarning("application section %s outside flash [0, 0x%04x]", + str_ccinterval(dry.appstart, dry.appstart+dry.appsize-1), up->flashsize-1); + + if(dry.datasize < 0) + Retwarning("negative apptable size"); + if(dry.datastart < 0 || dry.datastart+dry.datasize > up->flashsize) + Retwarning("apptable section %s outside flash [0, 0x%04x]", + str_ccinterval(dry.datastart, dry.datastart+dry.datasize-1), up->flashsize-1); + + if(dry.bootsize < 0) + Retwarning("negative boot section size"); + if(dry.bootstart < 0 || dry.bootstart+dry.bootsize > up->flashsize) + Retwarning("boot section %s outside flassh [0, 0x%04x]", + str_ccinterval(dry.bootstart, dry.bootstart+dry.bootsize-1), up->flashsize-1); + + if(dry.appsize + dry.datasize + dry.bootsize != up->flashsize) + Retwarning("section sizes do not add up (0x%x) to flash size 0x%x", + dry.appsize + dry.datasize + dry.bootsize, up->flashsize); + + if(!dry.appsize) + Retwarning("no application section"); + + if(p->prog_modes & PM_UPDI) { + if(dry.bootsize && dry.appstart != dry.bootsize) + Retwarning("application section %s does not touch boot section %s", + str_ccinterval(dry.appstart, dry.appstart+dry.appsize-1), + str_ccinterval(dry.bootstart, dry.bootstart+dry.bootsize-1)); + if(dry.datasize && dry.datastart != dry.bootsize + dry.appsize) + Retwarning("apptable section %s does not touch code section %s", + str_ccinterval(dry.datastart, dry.datastart+dry.appsize-1), + str_ccinterval(0, dry.bootsize+dry.appsize-1)); + } else { + if(dry.datasize && dry.datastart != dry.appsize && dry.appstart !=0) + Retwarning("apptable section %s does not touch application section %s", + str_ccinterval(dry.datastart, dry.datastart+dry.appsize-1), + str_ccinterval(dry.appstart, dry.appstart+dry.appsize-1)); + if(dry.datasize && dry.bootsize && dry.bootstart != dry.appsize + dry.datasize) + Retwarning("apptable section %s does not touch boot section %s", + str_ccinterval(dry.datastart, dry.datastart+dry.appsize-1), + str_ccinterval(dry.bootstart, dry.bootstart+dry.bootsize-1)); + } + + return 0; +} + +// Write a vector table to flash addr and return number of bytes written +static int putvectortable(const AVRPART *p, const AVRMEM *flm, int addr) { + int vecsz = flm->size <= 8192? 2: 4, ret = p->n_interrupts * vecsz; + + for(int i = 0; i < ret; i += vecsz) { // First store rjmps + flm->buf[addr + i] = 255-i/2; + flm->buf[addr + i + 1] = 0xcf; // rjmp .-2, rjmp .-6, ... + } + // Then round up to multiples of 32 + while(ret%32) + flm->buf[ret++] = ' '; + + return ret; +} + +// Human-readable messages in flash shown with, eg, avrdude -c dryrun -p m168 -xinit -Uflash:r:-:I +static const int u384[] = { + 0x00000800, 0x08000800, 0x1c4218ca, 0x08a5284a, 0x1842184e, 0x00000000, 0x00000000, 0x08010000, + 0x08010000, 0x08c53086, 0x00430942, 0x08653082, +}, u512[] = { + 0x20000800, 0x20000800, 0xf71c7b51, 0x28a288d1, 0x28a28851, 0x28a28859, 0xc71c7856, 0x00000000, + 0x80020000, 0x80020000, 0x8f22f1cd, 0x80920a23, 0x870e0a21, 0x08120a21, 0x87a2f1c1, 0x00000000, +}, bdata[] = { + 0x00000000, 0x00000001, 0x00000001, 0x08000001, 0x08000001, 0xfe381c1d, 0x08442223, 0x08824121, + 0x08824121, 0x08824121, 0x08442223, 0xf0381c1d, 0x00000000, 0x00000000, 0x00400000, 0x00400000, + 0x00400000, 0x00400000, 0x785c0e3c, 0x88621102, 0x84422081, 0xfc422081, 0x04422081, 0x04621102, + 0xf85c0e3c, 0x00000000, 0x00000000, 0x00000000, +}, adata[] = { + 0x00000020, 0x00000020, 0x00040020, 0x00040020, 0x3c7f1e2e, 0x40042031, 0x40042021, 0x7c043e21, + 0x42042121, 0x42042131, 0xfc787e2e, 0x00000000, 0x00000000, 0x00000000, +}, rocks[] = { + 0x00000004, 0x0000003c, 0x000000fc, 0x000007fc, 0x00001ffc, 0x0000ffe0, 0x0003ff00, 0x001ffc00, + 0x007fc000, 0x03fe0000, 0x07f00000, 0x07800000, 0x07e00000, 0x07fc0000, 0x03ff0000, 0x007fe000, + 0x001ffc00, 0x0003ff00, 0x0000ffe0, 0x00001ffc, 0x000007fc, 0x000000fc, 0x0000003c, 0x00000004, + 0x04000000, 0x07800000, 0x07e00000, 0x07fc0000, 0x07ff0000, 0x00ffe000, 0x003ff800, 0x0007ff00, + 0x0001ffc0, 0x00003ff8, 0x00000ffc, 0x000001fc, 0x0000007c, 0x000003fc, 0x00001ff8, 0x0000ffc0, + 0x0003ff00, 0x001ff800, 0x00ffe000, 0x03ff0000, 0x07fc0000, 0x07e00000, 0x07800000, 0x04000000, + 0x00000000, 0x00000000, 0x00000000, 0x07fffffc, 0x07fffffc, 0x07fffffc, 0x07007000, 0x07007000, + 0x07007c00, 0x0700fe00, 0x0700ff00, 0x0781ffc0, 0x07c3cfe0, 0x03ffc3f0, 0x03ff81fc, 0x01ff00fc, + 0x007c003c, 0x0000001c, 0x0000000c, 0x00000000, 0x00000000, 0x00000000, 0x07fffffc, 0x07fffffc, + 0x07fffffc, 0x0700001c, 0x0700001c, 0x0700001c, 0x0700003c, 0x03800038, 0x03c00078, 0x03e000f0, + 0x01f803f0, 0x00ffffe0, 0x003fff00, 0x0007f800, 0x00000000, 0x00000000, 0x00000000, 0x07ffff00, + 0x07ffffc0, 0x07fffff0, 0x000000f8, 0x00000038, 0x0000003c, 0x0000001c, 0x0000003c, 0x00000078, + 0x000000f8, 0x07fffff0, 0x07ffffc0, 0x07ffff00, 0x00000000, 0x00000000, 0x00000000, 0x07fffffc, + 0x07fffffc, 0x07fffffc, 0x0700001c, 0x0700001c, 0x0700001c, 0x0700003c, 0x03800038, 0x03c00078, + 0x03e000f0, 0x01f803f0, 0x00ffffe0, 0x003fff00, 0x0007f800, 0x00000000, 0x00000000, 0x00000000, + 0x07fffffc, 0x07fffffc, 0x07fffffc, 0x0700e01c, 0x0700e01c, 0x0700e01c, 0x0700e01c, 0x0700e01c, + 0x0700e01c, 0x0700e01c, 0x0700001c, 0x0700001c, 0x0000001c, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x007ffffc, 0x007ffffc, 0x007ffffc, 0x00070000, + 0x000e0000, 0x001c0000, 0x00380000, 0x00380000, 0x00700000, 0x00700000, 0x007f0000, 0x007f0000, + 0x00000000, 0x00000000, 0x00000000, 0x0000fe00, 0x0007ffc0, 0x000fffe0, 0x003f01f8, 0x003c0078, + 0x0078003c, 0x0070001c, 0x0070001c, 0x0078003c, 0x003c0078, 0x003f01f8, 0x000fffe0, 0x0007ffc0, + 0x0000fe00, 0x00000000, 0x00000000, 0x00000000, 0x0000fe00, 0x0003ffc0, 0x000fffe0, 0x001f01f0, + 0x003c0078, 0x0078003c, 0x0070001c, 0x0070001c, 0x0070001c, 0x0078003c, 0x00380038, 0x00380038, + 0x00000000, 0x00000000, 0x00000000, 0xfffffffc, 0xfffffffc, 0xfffffffc, 0x00003000, 0x00007800, + 0x0000fc00, 0x0003fe00, 0x0007ff00, 0x000fcf80, 0x001f87c0, 0x007f03f0, 0x007e01f8, 0x007800fc, + 0x0070007c, 0x0060003c, 0x0040001c, 0x0000000c, 0x00000004, 0x00000000, 0x00000000, 0x00000000, + 0x00000078, 0x000f8038, 0x001fc038, 0x003fe03c, 0x003fe01c, 0x0038f01c, 0x0078f01c, 0x0070701c, + 0x0070381c, 0x00703c1c, 0x00703c3c, 0x00701e78, 0x00781ff8, 0x00380fe0, 0x000003c0, 0x00000000, + 0x00000000, 0x00000000, 0x7ffffc3c, 0x7ffffc3c, 0x7ffffc3c, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +const struct { const int *bits, n32; } banner[] = { + {u384, sizeof u384/sizeof*u384}, + {u512, sizeof u512/sizeof*u512}, + {bdata, sizeof bdata/sizeof*bdata}, + {adata, sizeof adata/sizeof*adata}, + {rocks, sizeof rocks/sizeof*rocks}, + {rocks, sizeof rocks/sizeof*rocks}, // Sic, dummy entry for RND +}; + +enum { U384, U512, BDATA, ADATA, ROCKS, RND }; + +/* + * Given a bit stream, put a sequence of '@' or ' ' into flash; note they are + * all benign opcodes that do not touch memory or the I/O area: + * " ": and r2, r0 + * "@ ": and r4, r0 + * " @": sbci r18, 0 + * "@@": sbci r20, 0 + */ +static void putbanner(const AVRMEM *flm, int addr, int n, int bi) { + const int *bp = banner[bi].bits, len = n/10 + random()%(9*n/10); + + for(int i=0; ibuf[addr++] = scan & 1? '@': ' '; + scan >>= 1; + if(++i == n) + break; + } + if(++bp == banner[bi].bits + banner[bi].n32) { + bp = banner[bi].bits; + if(i > len) // Stop repeating banner after some threshold + break; + } + } +} + +// Is the opcode of benign nature, ie, not touching SRAM, I/O regs or flash? +static int is_benign_opcode(int op) { + static const struct { int mask, result; } benign[] = { + {0xfc00, 0x0c00}, // 0000 11rd dddd rrrr: add Rd, Rr + {0xfc00, 0x1c00}, // 0001 11rd dddd rrrr: adc Rd, Rr + {0xff00, 0x9600}, // 1001 0110 KKdd KKKK: adiw Rd, K + {0xfc00, 0x1800}, // 0001 10rd dddd rrrr: sub Rd, Rr + {0xf000, 0x5000}, // 0101 KKKK dddd KKKK: subi Rd, K + {0xfc00, 0x0800}, // 0000 10rd dddd rrrr: sbc Rd, Rr + {0xf000, 0x4000}, // 0100 KKKK dddd KKKK: sbci Rd, K + {0xff00, 0x9700}, // 1001 0111 KKdd KKKK: sbiw Rd, K + {0xfc00, 0x2000}, // 0010 00rd dddd rrrr: and Rd, Rr + {0xf000, 0x7000}, // 0111 KKKK dddd KKKK: andi Rd, K + {0xfc00, 0x2800}, // 0010 10rd dddd rrrr: or Rd, Rr + {0xf000, 0x6000}, // 0110 KKKK dddd KKKK: ori Rd, K + {0xfc00, 0x2400}, // 0010 01rd dddd rrrr: eor Rd, Rr + {0xfe0f, 0x9400}, // 1001 010d dddd 0000: com Rd + {0xfe0f, 0x9401}, // 1001 010d dddd 0001: neg Rd + {0xfe0f, 0x9403}, // 1001 010d dddd 0011: inc Rd + {0xfe0f, 0x940a}, // 1001 010d dddd 1010: dec Rd + {0xfc00, 0x9c00}, // 1001 11rd dddd rrrr: mul Rd, Rr + {0xff00, 0x0200}, // 0000 0010 dddd rrrr: muls Rd, Rr + {0xff88, 0x0300}, // 0000 0011 0ddd 0rrr: mulsu Rd, Rr + {0xff88, 0x0308}, // 0000 0011 0ddd 1rrr: fmul Rd, Rr + {0xff88, 0x0380}, // 0000 0011 1ddd 0rrr: fmuls Rd, Rr + {0xff88, 0x0388}, // 0000 0011 1ddd 1rrr: fmulsu Rd, Rr + // {0xff0f, 0x940b}, // 1001 0100 KKKK 1011: des K + {0xfc00, 0x1000}, // 0001 00rd dddd rrrr: cpse Rd, Rr + {0xfc00, 0x1400}, // 0001 01rd dddd rrrr: cp Rd, Rr + {0xfc00, 0x0400}, // 0000 01rd dddd rrrr: cpc Rd, Rr + {0xf000, 0x3000}, // 0011 KKKK dddd KKKK: cpi Rd, K + {0xfe08, 0xfc00}, // 1111 110r rrrr 0bbb: sbrc Rr, b + {0xfe08, 0xfe00}, // 1111 111r rrrr 0bbb: sbrs Rr, b + {0xfc00, 0x2c00}, // 0010 11rd dddd rrrr: mov Rd, Rr + {0xff00, 0x0100}, // 0000 0001 dddd rrrr: movw Rd, Rr + {0xf000, 0xe000}, // 1110 KKKK dddd KKKK: ldi Rd, K + {0xfe0f, 0x9406}, // 1001 010d dddd 0110: lsr Rd + {0xfe0f, 0x9407}, // 1001 010d dddd 0111: ror Rd + {0xfe0f, 0x9405}, // 1001 010d dddd 0101: asr Rd + {0xfe0f, 0x9402}, // 1001 010d dddd 0010: swap Rd + {0xfe08, 0xfa00}, // 1111 101d dddd 0bbb: bst Rr, b + {0xfe08, 0xf800}, // 1111 100d dddd 0bbb: bld Rd, b + {0xffff, 0x9408}, // 1001 0100 0000 1000: sec + {0xffff, 0x9488}, // 1001 0100 1000 1000: clc + {0xffff, 0x9428}, // 1001 0100 0010 1000: sen + {0xffff, 0x94a8}, // 1001 0100 1010 1000: cln + {0xffff, 0x9418}, // 1001 0100 0001 1000: sez + {0xffff, 0x9498}, // 1001 0100 1001 1000: clz + {0xffff, 0x94f8}, // 1001 0100 1111 1000: cli + {0xffff, 0x9448}, // 1001 0100 0100 1000: ses + {0xffff, 0x94c8}, // 1001 0100 1100 1000: cls + {0xffff, 0x9438}, // 1001 0100 0011 1000: sev + {0xffff, 0x94b8}, // 1001 0100 1011 1000: clv + {0xffff, 0x9468}, // 1001 0100 0110 1000: set + {0xffff, 0x94e8}, // 1001 0100 1110 1000: clt + {0xffff, 0x9458}, // 1001 0100 0101 1000: seh + {0xffff, 0x94d8}, // 1001 0100 1101 1000: clh + {0xffff, 0x95a8}, // 1001 0101 1010 1000: wdr + {0xffff, 0x0000}, // 0000 0000 0000 0000: nop + }; + + for(size_t i = 0; i < sizeof benign/sizeof*benign; i++) + if((op & benign[i].mask) == benign[i].result) + return 1; + return 0; +} + +// Put n/2 random benign opcodes into memory at addr +static void putcode(const AVRMEM *flm, int addr, int n) { + int i = 0, op; + + if(n < 2) + return; + if(n < 4) + goto endless; + + for(; i < n/2 - 2; i++) { + do { + op = random() & 0xffff; + } while(!is_benign_opcode(op)); + flm->buf[addr + 2*i] = op; // FIXME: relying on little endian here (and below) + flm->buf[addr + 2*i + 1] = op>>8; + } + + flm->buf[addr+2*i] = 0; + flm->buf[addr+2*i+1] = 0; // nop (in case last opcode was of skip-next-instruction type + i++; + +endless: + flm->buf[addr+2*i] = 255; + flm->buf[addr+2*i+1] = 0xcf; // rjmp .-2 (endless loop) +} + + +// Write valid opcodes to flash (banners for -xinit, random code for -xrandom) +static void putflash(const PROGRAMMER *pgm, const AVRMEM *flm, int addr, int n, int bi) { + if(dry.random) { + switch(bi) { + case U384: case U512: case BDATA: // Bootloader stuff, reduce code length a little + n -= random()%(n/8); + break; + case ADATA: case ROCKS: // Set random code length in [n/4, n] + n -= random()%(3*n/4); + } + if(bi != ADATA) { + putcode(flm, addr, n); + return; + } + bi = RND; // Make apptable data random @/space sequences + } + putbanner(flm, addr, n, bi); +} + +// Initialise a user writable memory other than flash or fuses +static void putother(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, const char *str) { + const char *name = avr_mem_name(p, m); + int len = strlen(str); + + if(len > m->size) + len = m->size; + if(len <= 0) + return; + + memset(m->buf, 0xff, m->size); + + if(dry.random) + putbanner(m, 0, m->size, RND); + else + for(int i = 0; i < m->size/3; i += len) + if(m->size - i > len) + memcpy(m->buf + i, str, len); + + if((len = strlen(name)) > m->size) + len = m->size; + memcpy(m->buf+m->size-len, name, len); + if(len < m->size) + m->buf[m->size-len-1] = ' '; +} + +// Copy chunk in one flash memory to other overlapping flash memories (think XMEGA) +static void sharedflash(const PROGRAMMER *pgm, const AVRMEM *fm, unsigned addr, int chunk) { + for(LNODEID ln=lfirst(dry.dp->mem); ln; ln=lnext(ln)) { + AVRMEM *m = ldata(ln); + if(mem_is_in_flash(m) && fm != m) { // Overlapping region? + unsigned int cpaddr = addr + fm->offset - m->offset; + if(cpaddr < (unsigned int) m->size && cpaddr + chunk <= (unsigned int) m->size) + memmove(m->buf+cpaddr, fm->buf+addr, chunk); + } + } +} static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { pmsg_debug("%s()\n", __func__); - AVRMEM *flm = avr_locate_flash(p); - if(flm && flm->size >= 1024) { - if(pgm->prog_modes & PM_SPM) - dry.bl = (p->prog_modes & PM_UPDI)? DRY_BOTTOM: DRY_TOP; - dry.blsize = flm->size/4; - if(dry.blsize > 512) - dry.blsize = 512; - } + if(dry.dp) // Already configured + return; - if(!dry.dp) { - unsigned char inifuses[16]; // For fuses, which is made up from fuse0, fuse1, ... - AVRMEM *fusesm = NULL, *prodsigm = NULL, *calm; - dry.dp = avr_dup_part(p); // Allocate dryrun part + unsigned char inifuses[16]; // For fuses: made up from fuse0, fuse1, ... + AVRMEM *m, *fusesm = NULL, *prodsigm = NULL, *calm; + AVRPART *q = dry.dp = avr_dup_part(p); // Allocate dryrun part and abbreviate with q - memset(inifuses, 0xff, sizeof inifuses); - // Initialise the device with factory setting and erase flash/EEPROM to 0xff - for (LNODEID ln=lfirst(dry.dp->mem); ln; ln=lnext(ln)) { - AVRMEM *m = ldata(ln); - if(mem_is_in_flash(m) || mem_is_eeprom(m)) { + srandom(dry.seed? dry.seed: time(NULL)); + + // Initialise the device with factory setting and erase flash/EEPROM to 0xff + for (LNODEID ln=lfirst(q->mem); ln; ln=lnext(ln)) { + m = ldata(ln); + if(mem_is_in_flash(m) || mem_is_eeprom(m)) { + memset(m->buf, 0xff, m->size); + } else if(mem_is_fuses(m)) { + fusesm = m; + } else if(mem_is_a_fuse(m) || mem_is_lock(m)) { + // Lock, eg, can have 4 bytes: still allow initialisation from initval + if(m->initval != -1 && m->size >=1 && m->size <= (int) sizeof(m->initval)) { + memcpy(m->buf, &m->initval, m->size); // FIXME: relying on little endian here + if(mem_is_a_fuse(m)) { + int fno = mem_fuse_offset(m); + for(int i = 0; i < m->size && fno+i < (int) sizeof inifuses; i++) // pdicfg has 2 bytes + inifuses[fno+i] = m->initval >> 8*i; + } + } else { memset(m->buf, 0xff, m->size); - // Overwrite ficticious bootloader section with block of endless loops - if(dry.bl && (mem_is_boot(m) || mem_is_flash(m))) - for(int i = dry.bl == DRY_TOP? m->size-dry.blsize: 0, end = i+dry.blsize, n = 0; i+1 < end; i+=2, n++) - m->buf[i] = 255-n, m->buf[i+1] = 0xcf; // rjmp .-2, rjmp .-4, ... - } else if(mem_is_fuses(m)) { - fusesm = m; - } else if(mem_is_a_fuse(m) || mem_is_lock(m)) { - // Lock, eg, can have 4 bytes: still allow initialisation from initval - if(m->initval != -1 && m->size >=1 && m->size <= (int) sizeof(m->initval)) { - memcpy(m->buf, &m->initval, m->size); // FIXME: relying on little endian here - if(mem_is_a_fuse(m)) { - int fno = mem_fuse_offset(m); - for(int i = 0; i < m->size && fno+i < (int) sizeof inifuses; i++) // pdicfg has 2 bytes - inifuses[fno+i] = m->initval >> 8*i; - } - } else { - memset(m->buf, 0xff, m->size); - } - } else if(mem_is_signature(m) && (int) sizeof(dry.dp->signature) == m->size) { - memcpy(m->buf, dry.dp->signature, m->size); - } else if(mem_is_calibration(m)) { - memset(m->buf, 'U', m->size); // 'U' for uncalibrated or unknown :) - } else if(mem_is_osc16err(m)) { - memset(m->buf, 'e', m->size); - } else if(mem_is_osc20err(m)) { - memset(m->buf, 'E', m->size); - } else if(mem_is_osccal16(m)) { - memset(m->buf, 'o', m->size); - } else if(mem_is_osccal20(m)) { - memset(m->buf, 'O', m->size); - } else if(mem_is_sib(m)) { - memset(m->buf, 'S', m->size); - } else if( mem_is_tempsense(m)) { - memset(m->buf, 'T', m->size); // 'T' for temperature calibration values - } else if(mem_is_sernum(m)) { - for(int i = 0; i < m->size; i++) // Set serial number UTSRQPONM... - m->buf[i] = 'U'-i >= 'A'? 'U'-i: 0xff; - } else if(mem_is_sigrow(m) && m->size >= 6) { - prodsigm = m; - memset(m->buf, 0xff, m->size); - if(p->prog_modes & PM_PDI) { - m->buf[0] = m->buf[1] = 'U'; - } else if(!(p->prog_modes & PM_UPDI)) { // Classic parts: signature at even addresses - for(int i=0; i<3; i++) - m->buf[2*i] = dry.dp->signature[i]; - } - } else if(mem_is_io(m)) { // Initialise reset values (if known) - int nr; - const Register_file *rf = avr_locate_register_file(p, &nr); - if(rf) - for(int i = 0; i < nr; i++) - if(rf[i].initval != -1 && rf[i].size > 0 && rf[i].size < 5) - if(rf[i].addr >= 0 && rf[i].addr+rf[i].size <= m->size) - for(int k = 0; k < rf[i].size; k++) // FIXME: Assume little endian compiler - m->buf[rf[i].addr+k] = ((unsigned char *) &rf[i].initval)[k]; } - } - if(prodsigm) { - if(p->prog_modes & PM_UPDI) { - for (LNODEID ln=lfirst(dry.dp->mem); ln; ln=lnext(ln)) { - AVRMEM *m = ldata(ln); - if(m->buf == prodsigm->buf) // Skip prodsig memory - continue; - int off = m->offset - prodsigm->offset; - int cpy = m->size; - // Submemory of prodsig, eg, signature and tempsense? Copy into prodsig - if(off >= 0 && off+cpy <= prodsigm->size) - memcpy(prodsigm->buf + off, m->buf, cpy); - } + } else if(mem_is_signature(m) && (int) sizeof(q->signature) == m->size) { + memcpy(m->buf, q->signature, m->size); + } else if(mem_is_calibration(m)) { + memset(m->buf, 'U', m->size); // 'U' for uncalibrated or unknown :) + } else if(mem_is_osc16err(m)) { + memset(m->buf, 'e', m->size); + } else if(mem_is_osc20err(m)) { + memset(m->buf, 'E', m->size); + } else if(mem_is_osccal16(m)) { + memset(m->buf, 'o', m->size); + } else if(mem_is_osccal20(m)) { + memset(m->buf, 'O', m->size); + } else if(mem_is_sib(m)) { + memset(m->buf, 'S', m->size); + } else if( mem_is_tempsense(m)) { + memset(m->buf, 'T', m->size); // 'T' for temperature calibration values + } else if(mem_is_sernum(m)) { + for(int i = 0; i < m->size; i++) // Set serial number UTSRQPONM... + m->buf[i] = dry.random? 'A'+random()%26: 'U'-i >= 'A'? 'U'-i: 0xff; + } else if(mem_is_sigrow(m) && m->size >= 6) { + prodsigm = m; + memset(m->buf, 0xff, m->size); + if(q->prog_modes & PM_PDI) { + m->buf[0] = m->buf[1] = 'U'; + } else if(q->prog_modes & PM_Classic) { // Signature at even addresses + for(int i=0; i<3; i++) + m->buf[2*i] = q->signature[i]; } - if(!(p->prog_modes & (PM_PDI|PM_UPDI)) && (calm = avr_locate_calibration(dry.dp))) { - // Calibration bytes of classic parts are interspersed with signature - for(int i=0; isize; i++) - if(2*i+1 < prodsigm->size) - prodsigm->buf[2*i+1] = 'U'; - } - } - if(fusesm) { - size_t fusz = fusesm->size; - memcpy(fusesm->buf, inifuses, fusz < sizeof inifuses? fusz: sizeof inifuses); + } else if(mem_is_io(m)) { // Initialise reset values (if known) + int nr; + const Register_file *rf = avr_locate_register_file(q, &nr); + if(rf) + for(int i = 0; i < nr; i++) + if(rf[i].initval != -1 && rf[i].size > 0 && rf[i].size < 5) + if(rf[i].addr >= 0 && rf[i].addr+rf[i].size <= m->size) + for(int k = 0; k < rf[i].size; k++) // FIXME: Assume little endian compiler + m->buf[rf[i].addr+k] = ((unsigned char *) &rf[i].initval)[k]; } } + if(prodsigm) { + if(q->prog_modes & PM_UPDI) { + for (LNODEID ln=lfirst(q->mem); ln; ln=lnext(ln)) { + AVRMEM *m = ldata(ln); + if(m->buf == prodsigm->buf) // Skip prodsig memory + continue; + int off = m->offset - prodsigm->offset; + int cpy = m->size; + // Submemory of prodsig, eg, signature and tempsense? Copy into prodsig + if(off >= 0 && off+cpy <= prodsigm->size) + memcpy(prodsigm->buf + off, m->buf, cpy); + } + } + if((q->prog_modes & PM_Classic) && (calm = avr_locate_calibration(q))) { + // Calibration bytes of classic parts are interspersed with signature + for(int i=0; isize; i++) + if(2*i+1 < prodsigm->size) + prodsigm->buf[2*i+1] = 'U'; + } + } + if(fusesm) { + size_t fusz = fusesm->size; + memcpy(fusesm->buf, inifuses, fusz < sizeof inifuses? fusz: sizeof inifuses); + } - return; + // Is the programmer a bootloader? + if((m = avr_locate_flash(q)) && m->size >= 1024 && (pgm->prog_modes & PM_SPM)) + dry.bl = (q->prog_modes & PM_UPDI)? DRY_BOTTOM: DRY_TOP; + + if(!dry.random && !dry.init) // OK, no further initialisation needed + return; + + int nc, bakverb = verbose; + verbose = -123; // Silently retrieve uP_table[] entry and config list + const Avrintel *up = avr_locate_uP(q); + const Configitem *cp = avr_locate_configitems(q, &nc); + verbose = bakverb; + AVRMEM *flm = avr_locate_flash(q); + AVRMEM *ee = avr_locate_eeprom(q); + int incons = flm && up && ( + up->flashsize != flm->size || flm->size <= 0 || + (ee && (up->eeprompagesize != ee->page_size || ee->page_size <= 0)) || + up->nboots != q->n_boot_sections || up->nboots < 0 || + up->bootsize != q->boot_section_size || up->bootsize < 0 || + memcmp(up->sigs, q->signature, 3) + ); + + // Ensure can use up and cp with impunity + if(!flm || !up || incons || !cp) { + pmsg_warning("%s for %s; not initialising memories beyond factory settings\n", !flm? "no flash": + !up? "no uP_table[] entry": incons? "inconsistent upP_table[] entry": "no config table", q->desc); + return; + } + + randflashconfig(pgm, q, up, cp, nc); + if(flashlayout(pgm, q, flm, up, cp, nc) < 0) + return; + +#if 0 // Only a dryrun device, but what if saved random fuses are stored to a real device? + if(dry.random) { + const char *exempt[] = { + "rstdisbl", "selfprgen", "spien", // Here be dragons? + "rstpincfg", "updipincfg", "nvmkey", "nvmlevel", + "ap", "blb0", "blb1", "blba", "blbat", "blbb", "blp", "key", "lb", // lockbits + "crcsel", "crcsrc", // Not emulating CRCs in code/boot sections (yet) + "bootsize", "bootend", "codesize", "append", "bootrst", "bootsz", // Already randomly set + }; + for(int i=0; i 0 && cp[i].vlist? + cp[i].vlist[random() % cp[i].nvalues].value: // Have existing list of values, pick one + (random() & cp[i].mask) >> cp[i].lsh; // "free" value, shift mask into position + set_config_values(pgm, q, cp[i].name, v); + } + } + } +#endif + + int vtb = putvectortable(q, flm, dry.appstart), urbtsz = 0; + + int urboot = random()%3 && dry.bootsize <= 512 && flm->size >= 1024 && + flm->size >= 4*dry.bootsize && (q->prog_modes & PM_Classic) && (q->prog_modes & PM_SPM); + if(urboot) { // Give some classic parts a small bootloader + int ps = flm->page_size; + urbtsz = dry.bootsize? dry.bootsize: flm->size > 32768? 512: flm->size < 16384? 256: 384; + urbtsz = (urbtsz + ps-1)/ps*ps; + int ubaddr = dry.bootsize? dry.bootstart: flm->size - urbtsz; + putflash(pgm, flm, ubaddr, urbtsz, urbtsz==384? U384: U512); + flm->buf[ubaddr] = 0xff; flm->buf[ubaddr+1] = 0xcf; // rjmp .-2 + } else if(dry.bootsize) { + int btb = 0; + if(dry.bootsize >= 2048) + btb = putvectortable(q, flm, dry.bootstart); + putflash(pgm, flm, dry.bootstart + btb, dry.bootsize - btb, BDATA); + flm->buf[dry.bootstart] = 0xff; flm->buf[dry.bootstart+1] = 0xcf; // rjmp .-2 + } + + if(dry.datasize) { + putflash(pgm, flm, dry.datastart, dry.datasize, ADATA); + } + + putflash(pgm, flm, dry.appstart+vtb, dry.appsize-vtb-urbtsz, ROCKS); + + for(int i = 0; i < flm->size; i += flm->page_size) + sharedflash(pgm, flm, i, flm->page_size); + + if((m = avr_locate_eeprom(q))) + putother(pgm, q, m, "The quick brown fox jumps over the lazy dog. "); + if((m = avr_locate_userrow(q))) + putother(pgm, q, m, "The five boxing wizards jump quickly. "); + if((m = avr_locate_bootrow(q))) + putother(pgm, q, m, "Lorem ipsum dolor sit amet. "); } @@ -290,7 +745,7 @@ static int dryrun_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR Return("no dryrun device?"); if(n_bytes) { - AVRMEM *dmem, *dm2; + AVRMEM *dmem; int mchr, chunk; unsigned int end; @@ -314,27 +769,14 @@ static int dryrun_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR for(; addr < end; addr += chunk) { chunk = end-addr < page_size? end-addr: page_size; - // Return write error for protected bootloader region - if(dry.bl && (mem_is_boot(m) || mem_is_flash(m))) - if(dryrun_readonly(pgm, p, m, addr)) - if(memcmp(dmem->buf+addr, m->buf+addr, chunk)) - Return("Write error on protected bootloader region %s [0x%04x, 0x%04x]\n", m->desc, - dry.bl == DRY_TOP? m->size-dry.blsize: 0, dry.bl == DRY_TOP? m->size-1: dry.blsize-1); + // @@@ Check for bootloader write protection here // Unless it is a bootloader flash looks like NOR-memory (mchr == 'F' && !dry.bl? memand: memcpy)(dmem->buf+addr, m->buf+addr, chunk); // Copy chunk to overlapping XMEGA's apptable, application, boot and flash memories - if(mchr == 'F') { - for(LNODEID ln=lfirst(dry.dp->mem); ln; ln=lnext(ln)) { - dm2 = ldata(ln); - if(mem_is_in_flash(dm2) && dmem != dm2) { // Overlapping region? - unsigned int cpaddr = addr + dmem->offset - dm2->offset; - if(cpaddr < (unsigned int) dm2->size && cpaddr + chunk <= (unsigned int) dm2->size) - memmove(dm2->buf+cpaddr, dmem->buf+addr, chunk); - } - } - } + if(mchr == 'F') + sharedflash(pgm, dmem, addr, chunk); } } @@ -409,7 +851,7 @@ int dryrun_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, Return("cannot write byte to %s %s as address 0x%04lx outside range [0, 0x%04x]", dry.dp->desc, dmem->desc, addr, dmem->size-1); - if(!(p->prog_modes & (PM_UPDI | PM_aWire))) { // Initialise unused bits in classic & XMEGA parts + if(p->prog_modes & (PM_Classic | PM_PDI)) { // Initialise unused bits in classic & XMEGA parts int bitmask = avr_mem_bitmask(dry.dp, dmem, addr); // Read-modify-write for bitmasked memory data = (data & bitmask) | (dmem->buf[addr] & ~bitmask); @@ -455,7 +897,7 @@ int dryrun_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, Return("cannot read byte %s %s as address 0x%04lx outside range [0, 0x%04x]", dry.dp->desc, dmem->desc, addr, dmem->size-1); - if(!dry.bl && (mem_is_io(dmem) || mem_is_sram(dmem)) && !(p->prog_modes & (PM_UPDI | PM_PDI))) + if(!dry.bl && (mem_is_io(dmem) || mem_is_sram(dmem)) && (p->prog_modes & PM_Classic)) Return("classic part io/sram memories cannot be read externally"); *value = dmem->buf[addr]; @@ -514,10 +956,7 @@ static int dryrun_readonly(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM return 0; } - // Bootloader restictions: emulate a bootloader for dryboot - if(mem_is_boot(mem) || mem_is_flash(mem)) - if(dry.bl == DRY_TOP? (int) addr >= mem->size-dry.blsize: (int) addr < dry.blsize) - return 1; + // @@@ check for bootloader write protection if(mem_is_in_fuses(mem) || mem_is_lock(mem)) return 1; @@ -540,6 +979,45 @@ static void dryrun_teardown(PROGRAMMER *pgm) { } +static int dryrun_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { + for(LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *xpara = ldata(ln); + + if(str_starts(xpara, "init")) { + dry.init = 1; + continue; + } else if(str_starts(xpara, "random")) { + dry.random = 1; + continue; + } else if(str_starts(xpara, "seed=")) { + const char *errptr; + int seed = str_int(strchr(xpara, '=')+1, STR_INT32, &errptr); + if(errptr) { + pmsg_error("cannot parse %s seed value: %s\n", xpara, errptr); + return -1; + } + dry.seed = seed; + continue; + } else if(str_eq(xpara, "help")) { + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xinit Initialise memories with human-readable patterns (1, 2, 3)\n"); + msg_error(" -xrandom Initialise memories with random code/values (1, 3)\n"); + msg_error(" -xseed= Seed random number generator with , default time(NULL)\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + msg_error("Notes:\n"); + msg_error(" (1) -xinit and -xrandom randomly configure flash wrt boot/data/code length\n"); + msg_error(" (2) Patterns can best be seen with fixed-width font on -U flash:r:-:I\n"); + msg_error(" (3) Choose, eg, -xseed=1 for reproducible flash configuration and output\n"); + return LIBAVRDUDE_EXIT; + } + + pmsg_error("invalid extended parameter '%s'\n", xpara); + return -1; + } + + return 0; +} + const char dryrun_desc[] = "Dryrun programmer for testing avrdude"; void dryrun_initpgm(PROGRAMMER *pgm) { @@ -573,4 +1051,5 @@ void dryrun_initpgm(PROGRAMMER *pgm) { pgm->teardown = dryrun_teardown; pgm->term_keep_alive = dryrun_term_keep_alive; pgm->readonly = dryrun_readonly; + pgm->parseextparams = dryrun_parseextparams; } diff --git a/src/libavrdude.h b/src/libavrdude.h index 65b5459e..e3354d84 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -232,6 +232,7 @@ typedef struct opcode { #define PM_XMEGAJTAG 1024 // JTAG, some XMEGA parts #define PM_AVR32JTAG 2048 // JTAG for 32-bit AVRs #define PM_aWire 4096 // For 32-bit AVRs +#define PM_Classic (PM_TPI | PM_ISP | PM_HVSP | PM_HVPP | PM_debugWIRE | PM_JTAG | PM_JTAGmkI) #define PM_ALL 0x1fff // All programming interfaces #define HV_UPDI_VARIANT_0 0 /* Shared UPDI/GPIO/RESET pin, HV on UPDI pin (tinyAVR0/1/2)*/ From bc0c1a0499f4c1dbd1635ae8181821f9d2b739ef Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Wed, 26 Jun 2024 16:49:10 +0000 Subject: [PATCH 193/422] Fix Windows complaint about missing random()/srandom() --- src/dryrun.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dryrun.c b/src/dryrun.c index 4da51982..6147a9b9 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -42,6 +42,9 @@ #include "dryrun.h" #include "dryrun_private.h" +#define random() rand() // For platform independence +#define srandom(n) srand(n) + // Context of the programmer typedef enum { DRY_NOBOOTLOADER, // No bootloader, taking to an ordinary programmer From 485ad6de91d751e6c74bc078b46eee3cf06cbeb5 Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Thu, 27 Jun 2024 17:15:01 +0000 Subject: [PATCH 194/422] Provide fileio_format_with_errmsg() --- src/fileio.c | 17 +++++++++++++++++ src/libavrdude.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/fileio.c b/src/fileio.c index ef332507..02fe793b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -151,6 +151,23 @@ FILEFMT fileio_format(char c) { } +// Same as fileio_format(ch) but show error message with originator who and list possible formats +FILEFMT fileio_format_with_errmsg(char ch, const char *who) { + FILEFMT format = fileio_format(ch); + if(format == FMT_ERROR) { + pmsg_error("%sinvalid file format :%c; known formats are\n", who? who: "", ch); + for(int f, c, i=0; i<62; i++) { + c = i<10? '0'+i: (i&1? 'A': 'a') + (i-10)/2; + f = fileio_format(c); + if(f != FMT_ERROR) + msg_error(" :%c %s\n", c, fileio_fmtstr(f)); + } + } + + return format; +} + + // Multi-memory file flat address space layout (also used by avr-gcc's elf) enum { diff --git a/src/libavrdude.h b/src/libavrdude.h index e3354d84..c1650b03 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1227,6 +1227,7 @@ extern "C" { #endif FILEFMT fileio_format(char c); +FILEFMT fileio_format_with_errmsg(char c, const char *who); char *fileio_fmtstr(FILEFMT format); From a02995749c85dca3bc2d3913e960d806e01a74ec Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Thu, 27 Jun 2024 17:20:23 +0000 Subject: [PATCH 195/422] Utilise fileio_format_with_errmsg() in parse_op() --- src/update.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/update.c b/src/update.c index 81e98992..8de19ba1 100644 --- a/src/update.c +++ b/src/update.c @@ -82,15 +82,8 @@ UPDATE *parse_op(const char *s) { // Filename: last char is format if the penultimate char is a colon size_t len = strlen(fn); if(len > 2 && fn[len-2] == ':') { // Assume format specified - upd->format = fileio_format(fn[len-1]); + upd->format = fileio_format_with_errmsg(fn[len-1], ""); if(upd->format == FMT_ERROR) { - pmsg_error("invalid file format :%c in -U %s; known formats are\n", fn[len-1], s); - for(int f, c, i=0; i<62; i++) { - c = i<10? '0'+i: (i&1? 'A': 'a') + (i-10)/2; - f = fileio_format(c); - if(f != FMT_ERROR) - imsg_error(" :%c %s\n", c, fileio_fmtstr(f)); - } mmt_free(upd->memstr); mmt_free(upd); return NULL; From dd2a40f81da8836ee5301d3999081d03940cdeac Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Thu, 27 Jun 2024 17:21:30 +0000 Subject: [PATCH 196/422] Provide terminal backup [:format] --- src/term.c | 55 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/src/term.c b/src/term.c index 06e7658d..2c74d99b 100644 --- a/src/term.c +++ b/src/term.c @@ -67,6 +67,7 @@ struct command { static int cmd_dump (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_write (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_save (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); +static int cmd_backup (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_flush (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_abort (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_erase (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); @@ -97,6 +98,7 @@ struct command cmd[] = { { "read", cmd_dump, _fo(read_byte_cached), "alias for dump" }, { "write", cmd_write, _fo(write_byte_cached), "write data to memory; flash and EEPROM are cached" }, { "save", cmd_save, _fo(write_byte_cached), "save memory data to file" }, + { "backup", cmd_backup, _fo(write_byte_cached), "backup memories to file" }, { "flush", cmd_flush, _fo(flush_cache), "synchronise flash and EEPROM cache with the device" }, { "abort", cmd_abort, _fo(reset_cache), "abort flash and EEPROM writes, ie, reset the r/w cache" }, { "erase", cmd_erase, _fo(chip_erase_cached), "perform a chip or memory erase" }, @@ -646,17 +648,8 @@ static int cmd_save(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha const char *fn = argv[argc-1]; size_t len = strlen(fn); if(len > 2 && fn[len-2] == ':') { // Assume format specified - format = fileio_format(fn[len-1]); - if(format == FMT_ERROR) { - pmsg_error("(save) invalid file format :%c; known formats are\n", fn[len-1]); - for(int f, c, i=0; i<62; i++) { - c = i<10? '0'+i: (i&1? 'A': 'a') + (i-10)/2; - f = fileio_format(c); - if(f != FMT_ERROR) - msg_error(" :%c %s\n", c, fileio_fmtstr(f)); - } + if((format = fileio_format_with_errmsg(fn[len-1], "(save) ")) == FMT_ERROR) return -1; - } len -= 2; } char *filename = memcpy(mmt_malloc(len+1), fn, len); @@ -728,6 +721,48 @@ static int cmd_save(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha return ret < 0? ret: 0; } + +static int cmd_backup(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { + if(argc != 3 || (argc > 1 && str_eq(argv[1], "-?"))) { + msg_error( + "Syntax: backup [:]\n" + "Function: save memories to file; default format :I Intel Hex + comments\n" + "Notes:\n" + " - Backup flushes the cache before reading memories\n" + " - can be a comma separated list of known memories, all, etc or ALL\n" + " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" + " - A single list subtraction \\ (without) is allowed, eg, all\\backup\n" + ); + return -1; + } + + FILEFMT format = FMT_IHXC; + const char *fn = argv[2]; + size_t len = strlen(fn); + if(len > 2 && fn[len-2] == ':') { // Assume format specified + if((format = fileio_format_with_errmsg(fn[len-1], "(backup) ")) == FMT_ERROR) + return -1; + len -= 2; + } + char *filename = memcpy(mmt_malloc(len+1), fn, len); + + UPDATE upd = { + .cmdline = NULL, + .memstr = mmt_strdup(argv[1]), + .op = DEVICE_READ, + .filename = filename, + .format = format, + }; + + pgm->flush_cache(pgm, p); // Flush cache before any device memory access + int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE|UF_VERIFY); // -U argv[1]:r:file (and no -V) + mmt_free(upd.filename); + mmt_free(upd.memstr); + + return ret <= 0? ret: 0; +} + + static int cmd_flush(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { if(argc > 1) { msg_error( From 5e846098c8506516d7701ed8a447c68cc1b8eab9 Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Thu, 27 Jun 2024 18:19:32 +0000 Subject: [PATCH 197/422] Provide terminal restore [:format] --- src/term.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/term.c b/src/term.c index 2c74d99b..3b0aed08 100644 --- a/src/term.c +++ b/src/term.c @@ -68,6 +68,7 @@ static int cmd_dump (const PROGRAMMER *pgm, const AVRPART *p, int argc, const static int cmd_write (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_save (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_backup (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); +static int cmd_restore(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_flush (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_abort (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_erase (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); @@ -99,6 +100,7 @@ struct command cmd[] = { { "write", cmd_write, _fo(write_byte_cached), "write data to memory; flash and EEPROM are cached" }, { "save", cmd_save, _fo(write_byte_cached), "save memory data to file" }, { "backup", cmd_backup, _fo(write_byte_cached), "backup memories to file" }, + { "restore", cmd_restore, _fo(write_byte_cached), "restore memories from file" }, { "flush", cmd_flush, _fo(flush_cache), "synchronise flash and EEPROM cache with the device" }, { "abort", cmd_abort, _fo(reset_cache), "abort flash and EEPROM writes, ie, reset the r/w cache" }, { "erase", cmd_erase, _fo(chip_erase_cached), "perform a chip or memory erase" }, @@ -721,7 +723,6 @@ static int cmd_save(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha return ret < 0? ret: 0; } - static int cmd_backup(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { if(argc != 3 || (argc > 1 && str_eq(argv[1], "-?"))) { msg_error( @@ -731,7 +732,7 @@ static int cmd_backup(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c " - Backup flushes the cache before reading memories\n" " - can be a comma separated list of known memories, all, etc or ALL\n" " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" - " - A single list subtraction \\ (without) is allowed, eg, all\\backup\n" + " - A single list subtraction \\ (without) is allowed, eg, all\\bootrow\n" ); return -1; } @@ -739,7 +740,7 @@ static int cmd_backup(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c FILEFMT format = FMT_IHXC; const char *fn = argv[2]; size_t len = strlen(fn); - if(len > 2 && fn[len-2] == ':') { // Assume format specified + if(len > 2 && fn[len-2] == ':') { // :format if((format = fileio_format_with_errmsg(fn[len-1], "(backup) ")) == FMT_ERROR) return -1; len -= 2; @@ -755,13 +756,57 @@ static int cmd_backup(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c }; pgm->flush_cache(pgm, p); // Flush cache before any device memory access - int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE|UF_VERIFY); // -U argv[1]:r:file (and no -V) + int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE); // -U argv[1]:r:file mmt_free(upd.filename); mmt_free(upd.memstr); return ret <= 0? ret: 0; } +static int cmd_restore(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { + if(argc != 3 || (argc > 1 && str_eq(argv[1], "-?"))) { + msg_error( + "Syntax: restore [:]\n" + "Function: restore memories from file\n" + "Notes:\n" + " - User should erase flash before using restore involving flash\n" + " - Restore flushes the cache before writing memories\n" + " - After writing memories restore resets the cache\n" + " - can be a comma separated list of known memories, all, etc or ALL\n" + " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" + " - A single list subtraction \\ (without) is allowed, eg, all\\bootrow\n" + " - Restoring a read-only memory verifies file contents with MUC memory\n" + ); + return -1; + } + + FILEFMT format = FMT_AUTO; + const char *fn = argv[2]; + size_t len = strlen(fn); + if(len > 2 && fn[len-2] == ':') { // :format + if((format = fileio_format_with_errmsg(fn[len-1], "(restore) ")) == FMT_ERROR) + return -1; + len -= 2; + } + char *filename = memcpy(mmt_malloc(len+1), fn, len); + + UPDATE upd = { + .cmdline = NULL, + .memstr = mmt_strdup(argv[1]), + .op = DEVICE_WRITE, + .filename = filename, + .format = format, + }; + + pgm->flush_cache(pgm, p); // Flush cache before any device memory access + int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE|UF_VERIFY); // -U argv[1]:w:file (no -V) + mmt_free(upd.filename); + mmt_free(upd.memstr); + pgm->reset_cache(pgm, p); // Reset cache after writing to memories + + return ret <= 0? ret: 0; +} + static int cmd_flush(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { if(argc > 1) { From b2ed09f73d932c46f226954735c348d8f2289f92 Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Thu, 27 Jun 2024 18:21:04 +0000 Subject: [PATCH 198/422] Provide terminal verify [:format] --- src/term.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/term.c b/src/term.c index 3b0aed08..01e13620 100644 --- a/src/term.c +++ b/src/term.c @@ -69,6 +69,7 @@ static int cmd_write (const PROGRAMMER *pgm, const AVRPART *p, int argc, const static int cmd_save (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_backup (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_restore(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); +static int cmd_verify (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_flush (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_abort (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_erase (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); @@ -101,6 +102,7 @@ struct command cmd[] = { { "save", cmd_save, _fo(write_byte_cached), "save memory data to file" }, { "backup", cmd_backup, _fo(write_byte_cached), "backup memories to file" }, { "restore", cmd_restore, _fo(write_byte_cached), "restore memories from file" }, + { "verify", cmd_verify, _fo(write_byte_cached), "compare memories with file" }, { "flush", cmd_flush, _fo(flush_cache), "synchronise flash and EEPROM cache with the device" }, { "abort", cmd_abort, _fo(reset_cache), "abort flash and EEPROM writes, ie, reset the r/w cache" }, { "erase", cmd_erase, _fo(chip_erase_cached), "perform a chip or memory erase" }, @@ -807,6 +809,46 @@ static int cmd_restore(const PROGRAMMER *pgm, const AVRPART *p, int argc, const return ret <= 0? ret: 0; } +static int cmd_verify(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { + if(argc != 3 || (argc > 1 && str_eq(argv[1], "-?"))) { + msg_error( + "Syntax: verify [:]\n" + "Function: compare memories with file\n" + "Notes:\n" + " - Verify flushes the cache before verifying memories\n" + " - can be a comma separated list of known memories, all, etc or ALL\n" + " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" + " - A single list subtraction \\ (without) is allowed, eg, all\\bootrow\n" + ); + return -1; + } + + FILEFMT format = FMT_AUTO; + const char *fn = argv[2]; + size_t len = strlen(fn); + if(len > 2 && fn[len-2] == ':') { // :format + if((format = fileio_format_with_errmsg(fn[len-1], "(verify) ")) == FMT_ERROR) + return -1; + len -= 2; + } + char *filename = memcpy(mmt_malloc(len+1), fn, len); + + UPDATE upd = { + .cmdline = NULL, + .memstr = mmt_strdup(argv[1]), + .op = DEVICE_VERIFY, + .filename = filename, + .format = format, + }; + + pgm->flush_cache(pgm, p); // Flush cache before any device memory access + int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE); // -V -U argv[1]:v:file + mmt_free(upd.filename); + mmt_free(upd.memstr); + + return ret <= 0? ret: 0; +} + static int cmd_flush(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { if(argc > 1) { From 13683c1546150c29253a0a5c3d680c3889724ea7 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 28 Jun 2024 11:52:49 +0100 Subject: [PATCH 199/422] Move developer options /c /r to /e /R --- src/developer_opts.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index fa8dd69c..db17d309 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -849,7 +849,7 @@ static int prog_modes_in_flags(int prog_modes, const char *flags) { return (prog_modes == 0 && quirky) || !pm || (prog_modes & pm); } -// -p /[cdoASsrw*tiBUPTIJWHQ] +// -p /[dsASReow*tiBUPTIJWHQ] void dev_output_part_defs(char *partdesc) { bool cmdok, waits, opspi, descs, astrc, strct, cmpst, injct, raw, all, tsv; char *flags; @@ -862,27 +862,27 @@ void dev_output_part_defs(char *partdesc) { if(!flags && str_eq(partdesc, "*")) // Treat -p * as if it was -p */s flags = "s"; - if(!*flags || !strchr("cdoASsrw*tiBUPTIJWHQ", *flags)) { + if(!*flags || !strchr("dsASReow*tiBUPTIJWHQ", *flags)) { dev_info("%s: flags for developer option -p / not recognised\n", progname); dev_info( "Wildcard examples (these need protecting in the shell through quoting):\n" - " * all known parts\n" - " ATtiny10 just this part\n" - " *32[0-9] matches ATmega329, ATmega325 and ATmega328\n" - " *32? matches ATmega329, ATmega32A, ATmega325 and ATmega328\n" + " * all known parts\n" + " ATtiny10 just this part\n" + " *32[0-9] matches ATmega329, ATmega325 and ATmega328\n" + " *32? matches ATmega329, ATmega32A, ATmega325 and ATmega328\n" "Flags (one or more of the characters below):\n" - " d description of core part features\n" - " A show entries of avrdude.conf parts with all values\n" - " S show entries of avrdude.conf parts with necessary values\n" - " s show short entries of avrdude.conf parts using parent\n" - " r show entries of avrdude.conf parts as raw dump\n" - " c check and report errors in address bits of SPI commands\n" - " o opcodes for SPI programming parts and memories\n" - " w wd_... constants for ISP parts\n" - " * as first character: all of the above except s and S\n" - " BUPTIJWHQ only Bootloader/UPDI/PDI/TPI/ISP/JTAG/debugWire/HV/quirky MUCs\n" - " t use tab separated values as much as possible\n" - " i inject assignments from source code table\n" + " d description of core part features\n" + " s show short entries of avrdude.conf parts using parent\n" + " A show entries of avrdude.conf parts with all values\n" + " S show entries of avrdude.conf parts with necessary values\n" + " R show entries of avrdude.conf parts as raw dump\n" + " e check and report errors in address bits of SPI commands\n" + " o opcodes for SPI programming parts and memories\n" + " w wd_... constants for ISP parts\n" + " * as first character: all of the above except s and S\n" + " BUPTIJWHQ only Bootloader/UPDI/PDI/TPI/ISP/JTAG/debugWire/HV/quirky MUCs\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" @@ -901,12 +901,12 @@ void dev_output_part_defs(char *partdesc) { } all = *flags == '*'; - cmdok = all || !!strchr(flags, 'c'); + cmdok = all || !!strchr(flags, 'e'); descs = all || !!strchr(flags, 'd'); opspi = all || !!strchr(flags, 'o'); waits = all || !!strchr(flags, 'w'); astrc = all || !!strchr(flags, 'A'); - raw = all || !!strchr(flags, 'r'); + raw = all || !!strchr(flags, 'R'); strct = !!strchr(flags, 'S'); cmpst = !!strchr(flags, 's'); tsv = !!strchr(flags, 't'); From 3990fdf84bf9108f8aec9ed7ba455f283748f380 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 28 Jun 2024 11:54:15 +0100 Subject: [PATCH 200/422] Add only classic parts developer options /C --- src/developer_opts.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index db17d309..580316b6 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -834,6 +834,7 @@ static int prog_modes_in_flags(int prog_modes, const char *flags) { for(const char *p = flags; *p; p++) switch(*p) { case 'B': pm |= PM_SPM; break; + case 'C': pm |= PM_TPI | PM_ISP | PM_HVSP | PM_HVPP | PM_debugWIRE | PM_JTAG | PM_JTAGmkI; break; case 'U': pm |= PM_UPDI; break; case 'P': pm |= PM_PDI; break; case 'T': pm |= PM_TPI; break; @@ -849,7 +850,7 @@ static int prog_modes_in_flags(int prog_modes, const char *flags) { return (prog_modes == 0 && quirky) || !pm || (prog_modes & pm); } -// -p /[dsASReow*tiBUPTIJWHQ] +// -p /[dsASReow*tiBCUPTIJWHQ] void dev_output_part_defs(char *partdesc) { bool cmdok, waits, opspi, descs, astrc, strct, cmpst, injct, raw, all, tsv; char *flags; @@ -862,7 +863,7 @@ void dev_output_part_defs(char *partdesc) { if(!flags && str_eq(partdesc, "*")) // Treat -p * as if it was -p */s flags = "s"; - if(!*flags || !strchr("dsASReow*tiBUPTIJWHQ", *flags)) { + if(!*flags || !strchr("dsASReow*tiBCUPTIJWHQ", *flags)) { dev_info("%s: flags for developer option -p / not recognised\n", progname); dev_info( "Wildcard examples (these need protecting in the shell through quoting):\n" @@ -880,7 +881,7 @@ void dev_output_part_defs(char *partdesc) { " o opcodes for SPI programming parts and memories\n" " w wd_... constants for ISP parts\n" " * as first character: all of the above except s and S\n" - " BUPTIJWHQ only Bootloader/UPDI/PDI/TPI/ISP/JTAG/debugWire/HV/quirky MUCs\n" + " BCUPTIJWHQ only Boot/Classic/UPDI/PDI/TPI/ISP/JTAG/debugWire/HV/quirky MUCs\n" " t use tab separated values as much as possible\n" " i inject assignments from source code table\n" "Examples:\n" From bcf88e13d7b4e3bd744c65a56876cdb353b3cc01 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 28 Jun 2024 12:32:37 +0100 Subject: [PATCH 201/422] Add developer option /v for listing interrupt vector names --- src/developer_opts.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index 580316b6..7fe483ca 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -850,9 +850,19 @@ static int prog_modes_in_flags(int prog_modes, const char *flags) { return (prog_modes == 0 && quirky) || !pm || (prog_modes & pm); } -// -p /[dsASReow*tiBCUPTIJWHQ] +// Return pointer to uP_table entry for part p +static const Avrintel *silent_locate_uP(const AVRPART *p) { + int bakverb = verbose, idx; + verbose = -123; + idx = avr_locate_upidx(p); + verbose = bakverb; + + return idx < 0? NULL: uP_table + idx; +} + +// -p /[dsASRveow*tiBCUPTIJWHQ] void dev_output_part_defs(char *partdesc) { - bool cmdok, waits, opspi, descs, astrc, strct, cmpst, injct, raw, all, tsv; + bool cmdok, waits, opspi, descs, vtabs, astrc, strct, cmpst, injct, raw, all, tsv; char *flags; int nprinted; AVRPART *nullpart = avr_new_part(); @@ -863,7 +873,7 @@ void dev_output_part_defs(char *partdesc) { if(!flags && str_eq(partdesc, "*")) // Treat -p * as if it was -p */s flags = "s"; - if(!*flags || !strchr("dsASReow*tiBCUPTIJWHQ", *flags)) { + if(!*flags || !strchr("dsASRveow*tiBCUPTIJWHQ", *flags)) { dev_info("%s: flags for developer option -p / not recognised\n", progname); dev_info( "Wildcard examples (these need protecting in the shell through quoting):\n" @@ -877,6 +887,7 @@ void dev_output_part_defs(char *partdesc) { " A show entries of avrdude.conf parts with all values\n" " S show entries of avrdude.conf parts with necessary values\n" " R show entries of avrdude.conf parts as raw dump\n" + " v show vector table list for parts\n" " e check and report errors in address bits of SPI commands\n" " o opcodes for SPI programming parts and memories\n" " w wd_... constants for ISP parts\n" @@ -902,8 +913,9 @@ void dev_output_part_defs(char *partdesc) { } all = *flags == '*'; - cmdok = all || !!strchr(flags, 'e'); descs = all || !!strchr(flags, 'd'); + vtabs = all || !!strchr(flags, 'v'); + cmdok = all || !!strchr(flags, 'e'); opspi = all || !!strchr(flags, 'o'); waits = all || !!strchr(flags, 'w'); astrc = all || !!strchr(flags, 'A'); @@ -979,6 +991,7 @@ void dev_output_part_defs(char *partdesc) { int ok, nfuses; AVRMEM *m; OPCODE *oc; + const Avrintel *up; ok = 2047; nfuses = 0; @@ -1112,6 +1125,10 @@ void dev_output_part_defs(char *partdesc) { p->config_file, p->lineno ); } + + if(vtabs && (up = silent_locate_uP(p)) && up->isrtable) + for(int i=0; i < up->ninterrupts; i++) + dev_info("%s\t%3d\t%s\n", p->desc, i, up->isrtable[i]); } if(opspi) { From e829a46a49660a9cff0cf4e9f8fc0eb2d3b24cc5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 28 Jun 2024 13:47:41 +0100 Subject: [PATCH 202/422] Add developer option /c for listing configuration options --- src/developer_opts.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index 7fe483ca..84ef3fb2 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -860,9 +860,9 @@ static const Avrintel *silent_locate_uP(const AVRPART *p) { return idx < 0? NULL: uP_table + idx; } -// -p /[dsASRveow*tiBCUPTIJWHQ] +// -p /[dsASRvceow*tiBCUPTIJWHQ] void dev_output_part_defs(char *partdesc) { - bool cmdok, waits, opspi, descs, vtabs, astrc, strct, cmpst, injct, raw, all, tsv; + bool cmdok, waits, opspi, descs, vtabs, confs, astrc, strct, cmpst, injct, raw, all, tsv; char *flags; int nprinted; AVRPART *nullpart = avr_new_part(); @@ -873,7 +873,7 @@ void dev_output_part_defs(char *partdesc) { if(!flags && str_eq(partdesc, "*")) // Treat -p * as if it was -p */s flags = "s"; - if(!*flags || !strchr("dsASRveow*tiBCUPTIJWHQ", *flags)) { + if(!*flags || !strchr("dsASRvceow*tiBCUPTIJWHQ", *flags)) { dev_info("%s: flags for developer option -p / not recognised\n", progname); dev_info( "Wildcard examples (these need protecting in the shell through quoting):\n" @@ -887,7 +887,8 @@ void dev_output_part_defs(char *partdesc) { " A show entries of avrdude.conf parts with all values\n" " S show entries of avrdude.conf parts with necessary values\n" " R show entries of avrdude.conf parts as raw dump\n" - " v show vector table list for parts\n" + " v list interrupt vector names for parts\n" + " c list configuration options for parts\n" " e check and report errors in address bits of SPI commands\n" " o opcodes for SPI programming parts and memories\n" " w wd_... constants for ISP parts\n" @@ -915,6 +916,7 @@ void dev_output_part_defs(char *partdesc) { all = *flags == '*'; descs = all || !!strchr(flags, 'd'); vtabs = all || !!strchr(flags, 'v'); + confs = all || !!strchr(flags, 'c'); cmdok = all || !!strchr(flags, 'e'); opspi = all || !!strchr(flags, 'o'); waits = all || !!strchr(flags, 'w'); @@ -1129,6 +1131,21 @@ void dev_output_part_defs(char *partdesc) { if(vtabs && (up = silent_locate_uP(p)) && up->isrtable) for(int i=0; i < up->ninterrupts; i++) dev_info("%s\t%3d\t%s\n", p->desc, i, up->isrtable[i]); + + if(confs && (up = silent_locate_uP(p)) && up->cfgtable) + for(int i=0; i < up->nconfigs; i++) { + const Configitem *cp = up->cfgtable+i; + unsigned c, n = cp->nvalues; + if(!n || !cp->vlist) { // Count bits set in mask + for(n = cp->mask, c=0; n; c++) + n &= n-1; + n = 1<desc, n, cp->name); + if(cp->vlist && verbose) + for(int k=0; k < cp->nvalues; k++) + dev_info("%s\t\tvalue\t%3d\t%s\n", p->desc, cp->vlist[k].value, cp->vlist[k].label); + } } if(opspi) { From 9a79a6866f168d3a55a3882e801540f7c73fbb72 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 28 Jun 2024 13:54:30 +0100 Subject: [PATCH 203/422] Check dev_info() format at gnuc compile time --- src/developer_opts.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index 84ef3fb2..618c4476 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -214,6 +214,9 @@ static char *dev_sprintf(const char *fmt, ...) { static int dev_nprinted; +#if defined(__GNUC__) + __attribute__ ((format (printf, 2, 3))) +#endif int dev_message(int msglvl, const char *fmt, ...) { va_list ap; int rc = 0; @@ -530,7 +533,7 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool if(!cp || !dev_has_subsstr_comms(cp->comms, del)) { dev_info("%s\n", del); - dev_info("# %.*s\n", strlen(descstr)-2, descstr+1); // Remove double quotes + dev_info("# %.*s\n", (int) strlen(descstr)-2, descstr+1); // Remove double quotes dev_info("%s\n\n", del); } if(cp) @@ -689,7 +692,7 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool bm = base? dev_locate_mem(base, avr_mem_order[mi].str): NULL; if(!m && bm && !tsv) - dev_info("\n memory \"%s\" %*s= NULL;\n", bm->desc, 13 > strlen(bm->desc)? 13-strlen(bm->desc): 0, ""); + dev_info("\n memory \"%s\" %*s= NULL;\n", bm->desc, 13 > strlen(bm->desc)? 13 - (int) strlen(bm->desc): 0, ""); if(!m) continue; @@ -1298,7 +1301,7 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas if(!firstid) dev_info("/"); firstid = 0; - dev_info("%s", ldata(ln)); + dev_info("%s", (char *) ldata(ln)); } dev_info("\n%s\n\n", del); } @@ -1307,9 +1310,9 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas const char *prog_sea = is_programmer(pgm)? "programmer": is_serialadapter(pgm)? "serialadapter": "programmer"; if(pgm->parent_id && *pgm->parent_id) - dev_info("%s parent \"%s\" # %s\n", prog_sea, pgm->parent_id, ldata(lfirst(pgm->id))); + dev_info("%s parent \"%s\" # %s\n", prog_sea, pgm->parent_id, (char *) ldata(lfirst(pgm->id))); else - dev_info("%s # %s\n", prog_sea, ldata(lfirst(pgm->id))); + dev_info("%s # %s\n", prog_sea, (char *) ldata(lfirst(pgm->id))); } if(tsv) From 95dac08ccd37a0f87965bef78457ea548e1eaa51 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 28 Jun 2024 16:34:24 +0100 Subject: [PATCH 204/422] Add developer option /r for listing registers --- src/developer_opts.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index 618c4476..b24c8a07 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -863,9 +863,9 @@ static const Avrintel *silent_locate_uP(const AVRPART *p) { return idx < 0? NULL: uP_table + idx; } -// -p /[dsASRvceow*tiBCUPTIJWHQ] +// -p /[dsASRvcreow*tiBCUPTIJWHQ] void dev_output_part_defs(char *partdesc) { - bool cmdok, waits, opspi, descs, vtabs, confs, astrc, strct, cmpst, injct, raw, all, tsv; + bool cmdok, waits, opspi, descs, vtabs, confs, regis, astrc, strct, cmpst, injct, raw, all, tsv; char *flags; int nprinted; AVRPART *nullpart = avr_new_part(); @@ -876,7 +876,7 @@ void dev_output_part_defs(char *partdesc) { if(!flags && str_eq(partdesc, "*")) // Treat -p * as if it was -p */s flags = "s"; - if(!*flags || !strchr("dsASRvceow*tiBCUPTIJWHQ", *flags)) { + if(!*flags || !strchr("dsASRvcreow*tiBCUPTIJWHQ", *flags)) { dev_info("%s: flags for developer option -p / not recognised\n", progname); dev_info( "Wildcard examples (these need protecting in the shell through quoting):\n" @@ -890,8 +890,9 @@ void dev_output_part_defs(char *partdesc) { " A show entries of avrdude.conf parts with all values\n" " S show entries of avrdude.conf parts with necessary values\n" " R show entries of avrdude.conf parts as raw dump\n" - " v list interrupt vector names for parts\n" - " c list configuration options for parts\n" + " v list interrupt vector names\n" + " c list configuration options in fuses\n" + " r list registers with I/O address and size\n" " e check and report errors in address bits of SPI commands\n" " o opcodes for SPI programming parts and memories\n" " w wd_... constants for ISP parts\n" @@ -910,7 +911,7 @@ void dev_output_part_defs(char *partdesc) { " Leaving no space after -p can be an OK substitute for quoting in shells\n" " /s, /S and /A outputs are designed to be used as input in avrdude.conf\n" " Sorted /r output should stay invariant when rearranging avrdude.conf\n" - " The /c, /o and /w flags are less generic and may be removed sometime\n" + " The /e, /o and /w flags are less generic and may be removed sometime\n" " These options are just to help development, so not further documented\n" ); return; @@ -920,6 +921,7 @@ void dev_output_part_defs(char *partdesc) { descs = all || !!strchr(flags, 'd'); vtabs = all || !!strchr(flags, 'v'); confs = all || !!strchr(flags, 'c'); + regis = all || !!strchr(flags, 'r'); cmdok = all || !!strchr(flags, 'e'); opspi = all || !!strchr(flags, 'o'); waits = all || !!strchr(flags, 'w'); @@ -1149,6 +1151,10 @@ void dev_output_part_defs(char *partdesc) { for(int k=0; k < cp->nvalues; k++) dev_info("%s\t\tvalue\t%3d\t%s\n", p->desc, cp->vlist[k].value, cp->vlist[k].label); } + + if(regis && (up = silent_locate_uP(p)) && up->regf) + for(int i=0; i < up->nregisters; i++) + dev_info("%s\t0x%02x\t%d\t%s\n", p->desc, up->regf[i].addr, up->regf[i].size, up->regf[i].reg); } if(opspi) { From e3da82b1ec952fa26d82f23b42e1e32737235bb3 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 28 Jun 2024 16:35:32 +0100 Subject: [PATCH 205/422] Mark output of /vcr dev options for automated processing --- src/developer_opts.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index b24c8a07..63bec49d 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -1135,7 +1135,7 @@ void dev_output_part_defs(char *partdesc) { if(vtabs && (up = silent_locate_uP(p)) && up->isrtable) for(int i=0; i < up->ninterrupts; i++) - dev_info("%s\t%3d\t%s\n", p->desc, i, up->isrtable[i]); + dev_info(".vtab\t%s\t%d\t%s\n", p->desc, i, up->isrtable[i]); if(confs && (up = silent_locate_uP(p)) && up->cfgtable) for(int i=0; i < up->nconfigs; i++) { @@ -1146,15 +1146,15 @@ void dev_output_part_defs(char *partdesc) { n &= n-1; n = 1<desc, n, cp->name); + dev_info(".cfgt\t%s\t%d\t%s\n", p->desc, n, cp->name); if(cp->vlist && verbose) for(int k=0; k < cp->nvalues; k++) - dev_info("%s\t\tvalue\t%3d\t%s\n", p->desc, cp->vlist[k].value, cp->vlist[k].label); + dev_info(".cfgv\t%s\t\tvalue\t%d\t%s\n", p->desc, cp->vlist[k].value, cp->vlist[k].label); } if(regis && (up = silent_locate_uP(p)) && up->regf) for(int i=0; i < up->nregisters; i++) - dev_info("%s\t0x%02x\t%d\t%s\n", p->desc, up->regf[i].addr, up->regf[i].size, up->regf[i].reg); + dev_info(".regf\t%s\t0x%02x\t%d\t%s\n", p->desc, up->regf[i].addr, up->regf[i].size, up->regf[i].reg); } if(opspi) { From 7d70d5406f4424b6c0dce2bb8a51ee501adbc562 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 29 Jun 2024 00:33:30 +0100 Subject: [PATCH 206/422] Change memory list syntax to mem0,mem1,-mem2,/mem3,... ... where -mem or /mem removes a memory from the list so far --- src/update.c | 66 +++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/src/update.c b/src/update.c index 8de19ba1..24ef6f3f 100644 --- a/src/update.c +++ b/src/update.c @@ -284,49 +284,47 @@ static int is_backup_mem(const AVRPART *p, const AVRMEM *mem) { is_interesting_mem(p, mem); } +// Add (not == 0) or subtract (not == 1) a memory from list +static int memadd(AVRMEM **mlist, int nm, int not, AVRMEM *m) { + for(int i = 0; i < nm; i++) + if(mlist[i] == m) { + if(not) + mlist[i] = NULL; + return nm; + } + if(!not) + mlist[nm++] = m; + return nm; +} + /* - * Generate memory list from string and put number of memories into *np; Memory - * list can be sth like ee,fl,all\cal,efuse. Exactly one without operator \ can - * be present: it removes the second list from first. Normal use is to pass - * NULL for dry and let the function write to *np (ie, the number of resulting - * memories) and *rwvsoftfail indicating unknown memories for this part. If dry - * is set then -1 will be written to *dry when a generally unknown memory is - * mentioned or the string has a syntax error. + * Generate a memory list from string mstr and put number of memories into *np. + * Memory list can be sth like ee,fl,all,-cal,efuse. -mem or /mem removes it + * from the list. Normal use is to pass NULL for dry and let the function write + * to *np and *rwvsoftfail indicating unknown memories for this part. If dry is + * set then -1 will be written to *dry when a generally unknown memory is used. */ static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rwvsoftp, int *dry) { - int nsub = 0, nm = (lsize(p->mem) + 1) * ((int) str_numc(mstr, ',') + 1); // Upper limit - AVRMEM *m, **sub = NULL, **umemlist = mmt_malloc(nm*sizeof*umemlist); + int not, nm = (lsize(p->mem) + 1) * ((int) str_numc(mstr, ',') + 1); // Upper limit + AVRMEM *m, **umemlist = mmt_malloc(nm*sizeof*umemlist); char *dstr = mmt_strdup(mstr), *s = dstr, *e; - switch(str_numc(dstr, '\\')) { - case 0: - break; - default: - pmsg_error("list subtracting another with \\ only allowed once: %s\n", mstr); - if(*dry) - *dry = LIBAVRDUDE_GENERAL_FAILURE; - mmt_free(dstr); - goto done; - case 1: - e = strchr(dstr, '\\'); - sub = memory_list(e+1, p, &nsub, rwvsoftp, dry); - *e = 0; - } - nm = 0; // Now count how many there really are mentioned // Parse comma-separated list of memories incl memory all for(e = strchr(s, ','); 1; e = strchr(s, ',')) { if(e) *e = 0; s = str_trim(s); + if((not = *s == '/' || *s =='-')) // /mem or -mem removes the memory + s++; if(str_eq(s, "ALL")) { for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) if(is_interesting_mem(p, (m = ldata(lm)))) - umemlist[nm++] = m; + nm = memadd(umemlist, nm, not, m); } else if(str_eq(s, "all") || str_eq(s, "etc")) { for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) if(is_backup_mem(p, (m = ldata(lm)))) - umemlist[nm++] = m; + nm = memadd(umemlist, nm, not, m); } else if(!*s) { // Ignore empty list elements } else { if(dry) { @@ -340,7 +338,7 @@ static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rw *dry = LIBAVRDUDE_SOFTFAIL; } if((m = avr_locate_mem(p, s))) - umemlist[nm++] = m; + nm = memadd(umemlist, nm, not, m); else if(rwvsoftp) { pmsg_warning("skipping unknown memory %s in list -U %s:...\n", s, mstr); *rwvsoftp = 1; @@ -352,19 +350,6 @@ static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rw } mmt_free(dstr); - if(sub) { // Subtract all memories of second list - for(int d=0; d Date: Sat, 29 Jun 2024 09:00:45 +0100 Subject: [PATCH 207/422] Use PM_Classic instead of !(PM_PDI | PM_UPDI) --- src/fileio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 02fe793b..49bad5f2 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -222,9 +222,9 @@ unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { mem_is_in_fuses(mem)? MBASE(FUSES) + mem_fuse_offset(mem): mem_is_lock(mem)? MBASE(LOCK): // Classic parts intersperse signature and calibration bytes, this code places them together - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_signature(mem)? MBASE(SIGROW): - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_calibration(mem)? MBASE(SIGROW)+3: - !(p->prog_modes & (PM_PDI|PM_UPDI)) && mem_is_sigrow(mem)? MBASE(SIGROW)+0x10: // Eg, m328pb + (p->prog_modes & PM_Classic) && mem_is_signature(mem)? MBASE(SIGROW): + (p->prog_modes & PM_Classic) && mem_is_calibration(mem)? MBASE(SIGROW)+3: + (p->prog_modes & PM_Classic) && mem_is_sigrow(mem)? MBASE(SIGROW)+0x10: // Eg, m328pb // XMEGA parts have signature separate from prodsig, place prodsig at +0x10 as above (p->prog_modes & PM_PDI) && mem_is_signature(mem)? MBASE(SIGROW): (p->prog_modes & PM_PDI) && mem_is_in_sigrow(mem)? MBASE(SIGROW)+0x10 + mem->offset - boffset(p, sigrow): From 5ac7c9695856e96d882c8ae06d261f8faccf0c7f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 29 Jun 2024 09:08:02 +0100 Subject: [PATCH 208/422] Explicitly test for part being UPDI rather than assuming default --- src/fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fileio.c b/src/fileio.c index 49bad5f2..19a05ea4 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -228,7 +228,7 @@ unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { // XMEGA parts have signature separate from prodsig, place prodsig at +0x10 as above (p->prog_modes & PM_PDI) && mem_is_signature(mem)? MBASE(SIGROW): (p->prog_modes & PM_PDI) && mem_is_in_sigrow(mem)? MBASE(SIGROW)+0x10 + mem->offset - boffset(p, sigrow): - mem_is_in_sigrow(mem)? MBASE(SIGROW) + mem->offset - boffset(p, sigrow): // UPDI + rare classic + (p->prog_modes & PM_UPDI) && mem_is_in_sigrow(mem)? MBASE(SIGROW) + mem->offset - boffset(p, sigrow): mem_is_sib(mem)? MBASE(SIGROW) + 0x1000: // Arbitrary 0x1000 offset in signature section for sib mem_is_userrow(mem)? MBASE(USERROW): mem_is_bootrow(mem)? MBASE(BOOTROW): From 3722abccd43987a616e51c6892ee74004258e499 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 30 Jun 2024 22:39:53 +0100 Subject: [PATCH 209/422] Provide str_ccmcunames_signature() --- src/libavrdude.h | 2 ++ src/strutil.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index c1650b03..11b0e584 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -583,6 +583,7 @@ AVRPART * locate_part(const LISTID parts, const char *partdesc); AVRPART * locate_part_by_avr910_devcode(const LISTID parts, int devcode); AVRPART * locate_part_by_signature(const LISTID parts, unsigned char *sig, int sigsize); AVRPART * locate_part_by_signature_pm(const LISTID parts, unsigned char *sig, int sigsize, int prog_modes); + char *avr_prog_modes(int pm), *str_prog_modes(int pm), *dev_prog_modes(int pm); void avr_display(FILE *f, const AVRPART *p, const char *prefix, int verbose); int avr_variants_display(FILE *f, const AVRPART *p, const char *prefix); @@ -1518,6 +1519,7 @@ const char *str_ccfrq(double f, int n); int str_levenshtein(const char *str1, const char *str2, int swap, int subst, int add, int del); size_t str_weighted_damerau_levenshtein(const char *str1, const char *str2); int str_mcunames_signature(const unsigned char *sigs, char *p, size_t n); +const char *str_ccmcunames_signature(const unsigned char *sigs); int led_set(const PROGRAMMER *pgm, int led); int led_clr(const PROGRAMMER *pgm, int led); diff --git a/src/strutil.c b/src/strutil.c index 41971116..6e01e464 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1330,3 +1330,11 @@ int str_mcunames_signature(const unsigned char *sigs, char *p, size_t n) { return matching; } + +// Returns a comma-separated list of matching MCU names in closed-circuit space +const char *str_ccmcunames_signature(const unsigned char *sigs) { + char names[1024] = {0}; + (void) str_mcunames_signature(sigs, names, sizeof names); + + return str_ccprintf("%s", names); +} From cfaee38275a121406cf2851f45d78b4559420c7c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 30 Jun 2024 23:53:52 +0100 Subject: [PATCH 210/422] Provide avr_sig_compatible() --- src/avrpart.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/libavrdude.h | 1 + 2 files changed, 43 insertions(+) diff --git a/src/avrpart.c b/src/avrpart.c index 973392b9..38f38a97 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -1086,6 +1086,48 @@ AVRPART *locate_part_by_signature(const LISTID parts, unsigned char *sig, int si return locate_part_by_signature_pm(parts, sig, sigsize, PM_ALL); } +// Return whether two signatures represent SW-compatible parts +int avr_sig_compatible(const unsigned char *sig1, const unsigned char *sig2) { + // SW-compatible parts (same memories, interrupts and regfiles) despite different signatures + static const struct { unsigned char sig[3], equ[3]; } compat[] = { + {{0x1e, 0x97, 0x06}, {0x1e, 0x97, 0x05}}, // ATmega1284 vs ATmega1284P + {{0x1e, 0xa7, 0x03}, {0x1e, 0xa7, 0x02}}, // ATmega1284RFR2 vs ATmega128RFR2 + {{0x1e, 0x94, 0x0f}, {0x1e, 0x94, 0x0a}}, // ATmega164A vs ATmega164P=ATmega164PA + {{0x1e, 0x94, 0x10}, {0x1e, 0x94, 0x07}}, // ATmega165A vs ATmega165=ATmega165=ATmega165PA + {{0x1e, 0x94, 0x06}, {0x1e, 0x94, 0x0b}}, // ATmega168=ATmega168A vs ATmega168P=ATmega168PA + {{0x1e, 0x94, 0x11}, {0x1e, 0x94, 0x05}}, // ATmega169A vs ATmega169=ATmega169P=ATmega169PA + {{0x1e, 0xa8, 0x03}, {0x1e, 0xa8, 0x02}}, // ATmega2564RFR2 vs ATmega256RFR2 + {{0x1e, 0x95, 0x15}, {0x1e, 0x95, 0x08}}, // ATmega324A vs ATmega324P + {{0x1e, 0x95, 0x15}, {0x1e, 0x95, 0x11}}, // ATmega324A vs ATmega324PA + {{0x1e, 0x95, 0x08}, {0x1e, 0x95, 0x11}}, // ATmega324P vs ATmega324PA + {{0x1e, 0x95, 0x06}, {0x1e, 0x95, 0x0e}}, // ATmega3250=ATmega3250A vs ATmega3250P=ATmega3250PA + {{0x1e, 0x95, 0x05}, {0x1e, 0x95, 0x0d}}, // ATmega325=ATmega325A vs ATmega325P=ATmega325PA + {{0x1e, 0x95, 0x04}, {0x1e, 0x95, 0x0c}}, // ATmega3290=ATmega3290A vs ATmega3290P=ATmega3290PA + {{0x1e, 0x95, 0x03}, {0x1e, 0x95, 0x0b}}, // ATmega329=ATmega329A vs ATmega329P=ATmega329PA + {{0x1e, 0x92, 0x05}, {0x1e, 0x92, 0x0a}}, // ATmega48=ATmega48A vs ATmega48P=ATmega48PA + {{0x1e, 0x92, 0x05}, {0x1e, 0x92, 0x0a}}, // ATmega48=ATmega48A vs ATmega48P=ATmega48PA + {{0x1e, 0x96, 0x09}, {0x1e, 0x96, 0x0a}}, // ATmega644=ATmega644A vs ATmega644P=ATmega644PA + {{0x1e, 0xa6, 0x03}, {0x1e, 0xa6, 0x02}}, // ATmega644RFR2 vs ATmega64RFR2 + {{0x1e, 0x96, 0x06}, {0x1e, 0x96, 0x0e}}, // ATmega6450=ATmega6450A vs ATmega6450P + {{0x1e, 0x96, 0x05}, {0x1e, 0x96, 0x0d}}, // ATmega645=ATmega645A vs ATmega645P + {{0x1e, 0x96, 0x04}, {0x1e, 0x96, 0x0c}}, // ATmega6490=ATmega6490A vs ATmega6490P + {{0x1e, 0x96, 0x03}, {0x1e, 0x96, 0x0b}}, // ATmega649=ATmega649A vs ATmega649P + {{0x1e, 0x93, 0x0a}, {0x1e, 0x93, 0x0f}}, // ATmega88=ATmega88A=ATA6612C vs ATmega88P=ATmega88PA + }; + + if(!memcmp(sig1, sig2, 3)) + return 1; + + for(size_t i = 0; i < sizeof compat/sizeof *compat; i++) { + if(!memcmp(sig1, compat[i].sig, 3) && !memcmp(sig2, compat[i].equ, 3)) + return 1; + if(!memcmp(sig2, compat[i].sig, 3) && !memcmp(sig1, compat[i].equ, 3)) + return 1; + } + + return 0; +} + /* * Iterate over the list of avrparts given as "avrparts", and * call the callback function cb for each entry found. cb is being diff --git a/src/libavrdude.h b/src/libavrdude.h index 11b0e584..73256b49 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -583,6 +583,7 @@ AVRPART * locate_part(const LISTID parts, const char *partdesc); AVRPART * locate_part_by_avr910_devcode(const LISTID parts, int devcode); AVRPART * locate_part_by_signature(const LISTID parts, unsigned char *sig, int sigsize); AVRPART * locate_part_by_signature_pm(const LISTID parts, unsigned char *sig, int sigsize, int prog_modes); +int avr_sig_compatible(const unsigned char *sig1, const unsigned char *sig2); char *avr_prog_modes(int pm), *str_prog_modes(int pm), *dev_prog_modes(int pm); void avr_display(FILE *f, const AVRPART *p, const char *prefix, int verbose); From c584f84a8e45cca4c5db08d8b11c664e70244d1b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 1 Jul 2024 00:18:55 +0100 Subject: [PATCH 211/422] Move signature check into multi-memory file read --- src/fileio.c | 17 +++++++++++++++++ src/update.c | 15 --------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 19a05ea4..99db50a8 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -577,6 +577,14 @@ static int ihex2b(const char *infile, FILE *inf, const AVRPART *p, const AVRMEM any->buf[nextaddr+i] = ihex.data[below + i]; any->tags[nextaddr+i] = TAG_ALLOCATED; } + if(!ovsigck && nextaddr == mulmem[MULTI_SIGROW].base && ihex.reclen >= 3) + if(!avr_sig_compatible(p->signature, any->buf+nextaddr)) { + pmsg_error("signature of %s incompatible with file's (%s)\n", p->desc, + str_ccmcunames_signature(any->buf+nextaddr)); + imsg_error("use -F to override this check\n"); + mmt_free(buffer); + goto error; + } if(ihex.reclen && nextaddr+ihex.reclen > maxaddr) maxaddr = nextaddr+ihex.reclen; break; @@ -924,6 +932,15 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, any->buf[nextaddr+i] = srec.data[below + i]; any->tags[nextaddr+i] = TAG_ALLOCATED; } + if(!ovsigck && nextaddr == mulmem[MULTI_SIGROW].base && srec.reclen >= 3) + if(!avr_sig_compatible(p->signature, any->buf+nextaddr)) { + pmsg_error("signature of %s incompatible with file's (%s)\n", p->desc, + str_ccmcunames_signature(any->buf+nextaddr)); + imsg_error("use -F to override this check\n"); + mmt_free(buffer); + goto error; + } + if(srec.reclen && nextaddr+srec.reclen > maxaddr) maxaddr = nextaddr+srec.reclen; reccount++; diff --git a/src/update.c b/src/update.c index 24ef6f3f..5d282944 100644 --- a/src/update.c +++ b/src/update.c @@ -613,21 +613,6 @@ static int update_all_from_file(const UPDATE *upd, const PROGRAMMER *pgm, const fsp->nbytes, str_plural(fsp->nbytes), mem_desc, str_inname(upd->filename) ); - if(!ovsigck) // Check part signature is sane as multi-file signature - if((sig = avr_locate_signature(p)) && sig->size > 0 && (off = fileio_mem_offset(p, sig)) >= 0) - if(off+sig->size <= all->size && is_memset(all->tags+off, TAG_ALLOCATED, sig->size)) - if(avr_read_mem(pgm, p, sig, NULL) == sig->size) - if(memcmp(sig->buf, all->buf+off, sig->size)) { // Uh-oh: multi-file is for another part - pmsg_error("signature of %s does not match file", p->desc); - char names[1024] = {0}; - (void) str_mcunames_signature(all->buf+off, names, sizeof names); - if(*names) - msg_error(" (%s)", names); - msg_error("\n"); - imsg_error("use -F to override this check\n"); - allsize = -1; - } - return allsize; } From 8a194719bab9ef22496c2d9c7a1d56b86781f8dd Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 1 Jul 2024 00:26:01 +0100 Subject: [PATCH 212/422] Remove unused variables --- src/update.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/update.c b/src/update.c index 5d282944..6aaf2b6d 100644 --- a/src/update.c +++ b/src/update.c @@ -598,8 +598,7 @@ static int update_mem_from_all(const UPDATE *upd, const AVRPART *p, const AVRMEM static int update_all_from_file(const UPDATE *upd, const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *all, const char *mem_desc, Filestats *fsp) { // On writing to the device trailing 0xff might be cut off - AVRMEM *sig; - int off, op = upd->op == DEVICE_WRITE? FIO_READ: FIO_READ_FOR_VERIFY; + int op = upd->op == DEVICE_WRITE? FIO_READ: FIO_READ_FOR_VERIFY; int allsize = fileio_mem(op, upd->filename, upd->format, p, all, -1); if(allsize < 0) { pmsg_error("reading from file %s failed\n", str_inname(upd->filename)); From b65c3c49b71d07063b2a475e091d079b1bb172b5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 1 Jul 2024 00:26:35 +0100 Subject: [PATCH 213/422] Fix reccount when writing srec files --- src/fileio.c | 14 +++++++------- src/libavrdude.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 99db50a8..3004f1f9 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -660,7 +660,7 @@ static int b2srec(const AVRMEM *mem, const Segment *segp, Segorder where, const unsigned char *buf; unsigned int nextaddr; - int n, hiaddr, addr_width, reccount; + int n, hiaddr, addr_width; buf = mem->buf + segp->addr; nextaddr = startaddr + segp->addr; @@ -697,9 +697,9 @@ static int b2srec(const AVRMEM *mem, const Segment *segp, Segorder where, for(int i = 0; i < len; i++) fprintf(outf, "%02X", s[i]); fprintf(outf, "%02X\n", cksum_srec((unsigned char *) s, len, 0, 2)); + cx->reccount = 0; } - reccount = 0; for(int bufsize = segp->len; bufsize; bufsize -= n) { n = recsize; if(n > bufsize) @@ -713,15 +713,15 @@ static int b2srec(const AVRMEM *mem, const Segment *segp, Segorder where, buf += n; nextaddr += n; hiaddr +=n; - reccount++; + cx->reccount++; } // Add S5/6 record count record and S7/8/9 end of data record if(where & LAST_SEG) { - if(reccount >= 0 && reccount <= 0xffffff) { - int wd = reccount <= 0xffff? 2: 3; - fprintf(outf, "S%c%02X%0*X%02X\n", '5' + (wd == 3), wd + 1, 2*wd, reccount, - cksum_srec(NULL, 0, reccount, wd)); + if(cx->reccount >= 0 && cx->reccount <= 0xffffff) { + int wd = cx->reccount <= 0xffff? 2: 3; + fprintf(outf, "S%c%02X%0*X%02X\n", '5' + (wd == 3), wd + 1, 2*wd, cx->reccount, + cksum_srec(NULL, 0, cx->reccount, wd)); } fprintf(outf, "S%c%02X%0*X", endrec, addr_width + 1, 2*addr_width, startaddr); fprintf(outf, "%02X\n", cksum_srec(NULL, 0, startaddr, addr_width)); diff --git a/src/libavrdude.h b/src/libavrdude.h index 73256b49..ff614dc9 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1626,6 +1626,9 @@ typedef struct { const char **upd_wrote, **upd_termcmds; int upd_nfwritten, upd_nterms; + // Static variable from fileio.c + int reccount; + // Static variables from usb_libusb.c #include "usbdevs.h" char usb_buf[USBDEV_MAX_XFER_3]; From f1ff03d562c4b6e7c22b96b538f0bc007d8899e5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 1 Jul 2024 00:30:46 +0100 Subject: [PATCH 214/422] Change /mem to \mem for subtracting mem from list /mem has the meaning of ALL\mem in set theory, which could cause confusion. --- src/update.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/update.c b/src/update.c index 6aaf2b6d..ee4ee015 100644 --- a/src/update.c +++ b/src/update.c @@ -315,7 +315,7 @@ static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rw if(e) *e = 0; s = str_trim(s); - if((not = *s == '/' || *s =='-')) // /mem or -mem removes the memory + if((not = *s == '\\' || *s =='-')) // \mem or -mem removes the memory s++; if(str_eq(s, "ALL")) { for(LNODEID lm = lfirst(p->mem); lm; lm = lnext(lm)) From dab725a343d2d4d21bf65f4feeaca846d7c48a70 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 1 Jul 2024 00:52:30 +0100 Subject: [PATCH 215/422] Provide str_infilename() and str_outfilename() --- src/libavrdude.h | 2 ++ src/strutil.c | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index ff614dc9..d67420f9 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1505,7 +1505,9 @@ char *str_utoa(unsigned n, char *buf, int base); char *str_endnumber(const char *str); const char *str_plural(int x); const char *str_inname(const char *fn); +const char *str_infilename(const char *fn); const char *str_outname(const char *fn); +const char *str_outfilename(const char *fn); const char *str_ccinterval(int a, int b); bool is_bigendian(void); void change_endian(void *p, int size); diff --git a/src/strutil.c b/src/strutil.c index 6e01e464..4d442f91 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -493,12 +493,30 @@ const char *str_plural(int x) { return x==1? "": "s"; } +// Path name fn or if fn is - const char *str_inname(const char *fn) { - return !fn? "???": strcmp(fn, "-")? fn: ""; + return !fn? "???": str_eq(fn, "-")? "": fn; } +// File name of fn or if fn is - +const char *str_infilename(const char *fn) { + if(!fn) + fn = "???"; + char *p1 = strrchr(fn, '/'), *p2 = strrchr(fn, '\\'); + return str_eq(fn, "-")? "": p1? p1+1: p2? p2+1: fn; +} + +// Path name fn or if fn is - const char *str_outname(const char *fn) { - return !fn? "???": strcmp(fn, "-")? fn: ""; + return !fn? "???": str_eq(fn, "-")? "": fn; +} + +// File name of fn or if fn is - +const char *str_outfilename(const char *fn) { + if(!fn) + fn = "???"; + char *p1 = strrchr(fn, '/'), *p2 = strrchr(fn, '\\'); + return str_eq(fn, "-")? "": p1? p1+1: p2? p2+1: fn; } // Return sth like "[0, 0x1ff]" in closed-circuit space From 7647aaa4fcbce51265378694d5fb0ff21e60212a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 1 Jul 2024 00:55:33 +0100 Subject: [PATCH 216/422] Show filename not pathname in -U warnings/errors --- src/update.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/update.c b/src/update.c index ee4ee015..7829d9fa 100644 --- a/src/update.c +++ b/src/update.c @@ -263,7 +263,7 @@ int update_is_readable(const char *fn) { static void ioerror(const char *iotype, const UPDATE *upd) { int errnocp = errno; - pmsg_ext_error("file %s is not %s: ", str_outname(upd->filename), iotype); + pmsg_ext_error("file %s is not %s: ", str_outfilename(upd->filename), iotype); if(errnocp) msg_ext_error("%s", strerror(errnocp)); else if(upd->filename && *upd->filename) @@ -476,7 +476,7 @@ static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRME // Patch flash input, eg, for vector bootloaders if(pgm->flash_readhook && mem_is_flash(mem)) { if((size = pgm->flash_readhook(pgm, p, mem, upd->filename, size)) < 0) { - pmsg_notice("readhook for file %s failed\n", str_inname(upd->filename)); + pmsg_notice("readhook for file %s failed\n", str_infilename(upd->filename)); return -1; } if(memstats_mem(p, mem, size, &fs_patched) < 0) @@ -587,7 +587,7 @@ static int update_mem_from_all(const UPDATE *upd, const AVRPART *p, const AVRMEM if(is_memset(all->tags+off, 0, size)) // Nothing set? This memory was not present size = 0; if(size == 0) - pmsg_warning("%s has no data for %s, skipping ...\n", str_inname(upd->filename), m_name); + pmsg_warning("%s has no data for %s, skipping ...\n", str_infilename(upd->filename), m_name); memcpy(m->buf, all->buf+off, size); memcpy(m->tags, all->tags+off, size); @@ -601,7 +601,7 @@ static int update_all_from_file(const UPDATE *upd, const PROGRAMMER *pgm, const int op = upd->op == DEVICE_WRITE? FIO_READ: FIO_READ_FOR_VERIFY; int allsize = fileio_mem(op, upd->filename, upd->format, p, all, -1); if(allsize < 0) { - pmsg_error("reading from file %s failed\n", str_inname(upd->filename)); + pmsg_error("reading from file %s failed\n", str_infilename(upd->filename)); return -1; } if(memstats_mem(p, all, allsize, fsp) < 0) @@ -609,7 +609,7 @@ static int update_all_from_file(const UPDATE *upd, const PROGRAMMER *pgm, const pmsg_info(upd->op == DEVICE_WRITE? "reading %d byte%s for %s from input file %s\n": "verifying %d byte%s of %s against input file %s\n", - fsp->nbytes, str_plural(fsp->nbytes), mem_desc, str_inname(upd->filename) + fsp->nbytes, str_plural(fsp->nbytes), mem_desc, str_infilename(upd->filename) ); return allsize; @@ -718,7 +718,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat } imsg_info("writing %d byte%s to output file %s\n", - nbytes, str_plural(nbytes), str_outname(upd->filename)); + nbytes, str_plural(nbytes), str_outfilename(upd->filename)); if(nn) rc = fileio_segments(FIO_WRITE, upd->filename, upd->format, p, mem, nn, seglist); else @@ -737,12 +737,12 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat if(rc == 0) pmsg_notice("empty memory, resulting file has no contents\n"); imsg_info("writing %d byte%s to output file %s\n", - rc, str_plural(rc), str_outname(upd->filename)); + rc, str_plural(rc), str_outfilename(upd->filename)); rc = fileio_mem(FIO_WRITE, upd->filename, upd->format, p, mem, rc); } if(rc < 0) { - pmsg_error("write to file %s failed\n", str_outname(upd->filename)); + pmsg_error("write to file %s failed\n", str_outfilename(upd->filename)); goto error; } break; From 3aaa722f72a32f153867efb0a8147da75c7951d2 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 2 Jul 2024 19:48:48 +0100 Subject: [PATCH 217/422] Inspect memory lists to decide whether initial chip erase is needed --- src/libavrdude.h | 2 ++ src/main.c | 19 +++++-------------- src/update.c | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index d67420f9..627d54b1 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1318,6 +1318,8 @@ int update_is_readable(const char *fn); int update_dryrun(const AVRPART *p, UPDATE *upd); +AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rwvsoftp, int *dry); +int memlist_contains_flash(const char *mstr, const AVRPART *p); #ifdef __cplusplus } diff --git a/src/main.c b/src/main.c index 6cc74233..9f7dc311 100644 --- a/src/main.c +++ b/src/main.c @@ -242,7 +242,7 @@ static void usage(void) " -r Reconnect to -P port after \"touching\" it; wait\n" " 400 ms for each -r; needed for some USB boards\n" " -F Override invalid signature or initial checks\n" - " -e Perform a chip erase\n" + " -e Perform a chip erase at the beginning\n" " -O Perform RC oscillator calibration (see AVR053)\n" " -t Run an interactive terminal when it is its turn\n" " -T Run terminal line when it is its turn\n" @@ -1686,22 +1686,13 @@ skipopen: imsg_info("Each page will be erased before programming it, but no chip erase is performed.\n"); imsg_info("To disable page erases, specify the -D option; for a chip-erase, use the -e option.\n"); } else { - AVRMEM * m; - const char *memname = p->prog_modes & PM_PDI? "application": "flash"; - uflags &= ~UF_AUTO_ERASE; - for (ln=lfirst(updates); ln; ln=lnext(ln)) { + for(ln=lfirst(updates); !erase && ln; ln=lnext(ln)) { upd = ldata(ln); - if(!upd->memstr) - continue; - m = avr_locate_mem(p, upd->memstr); - if (m == NULL) - continue; - if(str_eq(m->desc, memname) && upd->op == DEVICE_WRITE) { + if(upd->memstr && upd->op == DEVICE_WRITE && memlist_contains_flash(upd->memstr, p)) { erase = 1; - pmsg_info("Note: %s memory has been specified, an erase cycle will be performed.\n", memname); - imsg_info("To disable this feature, specify the -D option.\n"); - break; + pmsg_info("Note: carrying out an erase cycle as flash memory needs programming (-U %s:w:...)\n", upd->memstr); + imsg_info("specify the -D option to disable this feature\n"); } } } diff --git a/src/update.c b/src/update.c index 7829d9fa..80a1326f 100644 --- a/src/update.c +++ b/src/update.c @@ -38,7 +38,7 @@ // Is s a multi-memory string (comma-separates list, all, ALL, etc or list subtraction)? static int is_multimem(const char *s) { - return str_eq(s, "ALL") || str_eq(s, "all") || str_eq(s, "etc") || strpbrk(s, ",\\"); + return str_eq(s, "ALL") || str_eq(s, "all") || str_eq(s, "etc") || strpbrk(s, "-,\\"); } /* @@ -304,7 +304,7 @@ static int memadd(AVRMEM **mlist, int nm, int not, AVRMEM *m) { * to *np and *rwvsoftfail indicating unknown memories for this part. If dry is * set then -1 will be written to *dry when a generally unknown memory is used. */ -static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rwvsoftp, int *dry) { +AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rwvsoftp, int *dry) { int not, nm = (lsize(p->mem) + 1) * ((int) str_numc(mstr, ',') + 1); // Upper limit AVRMEM *m, **umemlist = mmt_malloc(nm*sizeof*umemlist); char *dstr = mmt_strdup(mstr), *s = dstr, *e; @@ -363,6 +363,19 @@ done: return umemlist; } + +// Returns whether or not the memory list contains a flash memory +int memlist_contains_flash(const char *mstr, const AVRPART *p) { + int ret = 0, nm = 0; + AVRMEM **mlist = memory_list(mstr, p, &nm, NULL, NULL); + for(int i=0; i Date: Tue, 2 Jul 2024 20:17:26 +0100 Subject: [PATCH 218/422] Warn when generating multi-memory list with unsuitable format AVRDUDE will happily generate all sorts of file formats from multiple memories, but only understands hex, srec and elf files. --- src/update.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/update.c b/src/update.c index 80a1326f..5823cace 100644 --- a/src/update.c +++ b/src/update.c @@ -700,6 +700,10 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat */ int dffo = cx->avr_disableffopt; cx->avr_disableffopt = 1; + if(upd->format != FMT_IHEX && upd->format != FMT_IHXC && upd->format != FMT_SREC && upd->format != FMT_ELF) { + pmsg_warning("generating %s file format with multiple memories that cannot\n", fileio_fmtstr(upd->format)); + imsg_warning("be read by %s; consider using :I :i or :s instead\n", progname); + } imsg_info("reading %s ...\n", mem_desc); int nn = 0, nbytes = 0; for(int ii = 0; ii < ns; ii++) { From 23e835b8a394b0cd85945ae21ca9a907fab28b6f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 2 Jul 2024 23:05:17 +0100 Subject: [PATCH 219/422] Document multi-memory files and dryrun options --- src/avrdude.1 | 98 ++++++++++++++++++++++++++++++++--- src/doc/avrdude.texi | 118 ++++++++++++++++++++++++++++++++++++------- src/term.c | 10 ++-- 3 files changed, 196 insertions(+), 30 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index 3a859781..d70d0a9a 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -286,7 +286,7 @@ for Teensy specific options. .Pp Input files can be provided, and output files can be written in different file formats, such as raw binary files containing the data -to download to the chip, Intel hex format, or Motorola S-record +to download to the chip, Intel Hex format, or Motorola S-Record format. There are a number of tools available to produce those files, like .Xr asl 1 @@ -773,8 +773,28 @@ Perform a memory operation as indicated when it is its turn in relation to other -t interactive terminals, -T terminal commands and -U memory operations. The .Ar memory -field specifies the memory to operate on. The available memory types are -device-dependent, the actual configuration can be viewed with the +field specifies the memory to operate on. From version 8.0 the memory +field can also be a comma-separated list of memories, eg, +.Ar flash,eeprom ; +also, Intel Hex or Motorola S-Record files generated by AVRDUDE can store +multiple memories. The special memory +.Ar ALL +expands to all memories that a part has while +.Ar all +expands to all memories with exception of sub-memories. +.Ar etc +is the same as +.Ar all ; +this can be used to change the order in which memories are written to +or read from file, eg, +.Ar signature,etc +is a list of all memories such that the +.Ar signature +memory comes first. It is possible to remove a memory from the list so far +by preceding a minus or backslash, eg, +.Ar all,-calibration . +The available memory types are device-dependent, the actual configuration +can be viewed with the .Cm part command in terminal mode. Typically, a device's memory configuration at least contains @@ -961,11 +981,11 @@ Intel Hex .It Ar I Intel Hex with comments on download and tolerance of checksum errors on upload .It Ar s -Motorola S-record +Motorola S-Record .It Ar r -raw binary; little-endian byte order, in the case of the flash ROM data +raw binary; little-endian byte order, in the case of the flash data .It Ar e -ELF (Executable and Linkable Format) +ELF (Executable and Linkable Format, for input only) .It Ar m immediate mode; actual byte values are specified on the command line, separated by commas or spaces in place of the filename field of the -U @@ -1016,8 +1036,15 @@ followed by 0x00, and 0x01234 will occupy 4 bytes. See the description of the terminal write command for more details. .Pp In absence of an explicit file format, the default is to use auto -detection for input files, and raw binary format for output files. Note -that if a +detection for input files, raw binary format for output files from a +single memory read and Intel Hex with comments when an output file is +generated from a list of memories. Note that while +.Nm avrdude +will generate a single output file from a memory list for all formats with +the exception of elf (:e) it only recognises Intel hex (:I or :i), +Motorola S-Record (:s) or elf files (:e, generated by the compiler) as +valid multi-memory files when reading a file for verifying or writing +memories. Note also that if a .Ar filename contains a colon as penultimate character the .Ar format @@ -1201,6 +1228,37 @@ the address information and concatenate the chosen memory segments into the output file. If the file name is - then .Nm writes to stdout. +.It Ar backup memlist file[:format] +Backup one or more memories to the specified file using the selected +format. The default format for a single-memory backup is :r (raw +binary); for multi-memory backups it is :I (Intel Hex with comments). +Memlist can be a comma separated list of memories just as in the +.Ar -U +command line argument. +.Ar backup +flushes the cache before reading memories. +.It Ar restore memlist file[:format] +Restore one or more memories from the specified file. It is the user's +responsibility to erase memories as needed beforehand: some paged memories +look like NOR-memory when using certain programmers, meaning programming +cannot set bits to 1 (eg, flash under most programmers). These memories +need to be erased beforehand using the erase command (see below). The +format only needs to be specified if it cannot be automatically detected, +eg, when the file is - for standard input. Memlist can be a comma +separated list of memories just as in the +.Ar -U +command line argument. +.Ar restore +flushes the cache before writing memories and resets the cache after +writing memories. Note that restoring read-only memories verifies file +contents with the corresponding microprocessor's memories. +.It Ar verify memlist file[:format] +Compare one or more memories with the specified file. +Memlist can be a comma separated list of memories just as in the +.Ar -U +command line argument. +.Ar verify +flushes the cache before verifying memories. .It Ar erase Perform a chip erase and discard all pending writes to EEPROM and flash. Note that EEPROM will be preserved if the EESAVE fuse bit is set. @@ -1504,6 +1562,30 @@ might leave the EEPROM unerased, at least on some versions of the bootloader. .Ss Programmers accepting extended parameters .Bl -tag -offset indent -width indent +.It Ar dryrun +.It Ar dryboot +These two programmers emulate programming and accept the following parameters: +.Bl -tag -offset indent -width indent +.It Ar xinit +Initialise memories with human-readable patterns. Flash memory will be +randomly configured with respect to bootloader, data and code length. +Patterns can best be seen with fixed-width font and the :I format +by inspecting the generated hex file or by using, eg, -U flash:r:-:I. +Patterns in flash memory are executable and represent benign AVR code, ie, +no I/O memory access. Choose a fixed seed for reproducible results. +.It Ar random +Initialise memories with random code and values. Flash memory will be +randomly configured with respect to bootloader, data and code length. +Random code in flash will be benign, that is, not accessing I/O memories, +SRAM or flash. Choose a fixed seed for reproducible results. +.It Ar seed= +Seed random number generator with ; the default is time(NULL). +Setting this option with a fixed n > 0 will make the random choices +reproducible, ie, they will stay the same between different avrdude +runs. +.It Ar help +Show help menu and exit. +.El .It Ar JTAG ICE mkII .It Ar JTAGICE3 .It Ar Atmel-ICE diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index b9b9dacf..9f0987a0 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -233,7 +233,7 @@ usbdev config parameter). The STK500, STK600, JTAG ICE, and avr910 contain on-board logic to control the programming of the target device. The avr109 bootloader implements a protocol similar to avr910, but is -actually implemented in the boot area of the target's flash ROM, as +actually implemented in the boot area of the target's flash, as opposed to being an external device. The fundamental difference between the two types lies in the protocol used to control the programmer. The avr910 protocol is very @@ -598,10 +598,10 @@ Setting -D implies -A. @item -e @cindex Option @code{-e} Causes a chip erase to be executed. This will reset the contents of the -flash ROM and EEPROM to the value `0xff', and clear all lock bits. +flash and EEPROM to the value `0xff', and clear all lock bits. Except for ATxmega devices which can use page erase, it is basically a -prerequisite command before the flash ROM can be reprogrammed again. +prerequisite command before the flash can be reprogrammed again. The only exception would be if the new contents would exclusively cause bits to be programmed from the value `1' to `0'. Note that in order to reprogram EERPOM cells, no explicit prior chip erase is required @@ -836,12 +836,23 @@ terminal commands and @code{-U} memory operations. @item -U @var{memory}:@var{op}:@var{filename}[:@var{format}] @cindex Option @code{-U} @var{memory}:@var{op}:@var{filename}[:@var{format}] + Perform a memory operation when it is its turn in relation to other -@code{-t} interactive terminals, @code{-T} terminal commands and -@code{-U} memory operations. The @var{memory} field specifies the memory -type to operate on. Use the @option{-T part} option on the command line or -the @code{part} command in the interactive terminal to display all the -memories supported by a particular device. +@code{-t} interactive terminals, @code{-T} terminal commands and @code{-U} +memory operations. The @var{memory} field specifies the memory type to +operate on. From version 8.0 the memory field can also be a +comma-separated list of memories, eg, @code{flash,eeprom}; also, Intel Hex +or Motorola S-Record files generated by AVRDUDE can store multiple +memories. The special memory @code{ALL} expands to all memories that a +part has while @code{all} expands to all memories with exception of +sub-memories. @code{etc} is the same as @code{all}; this can be used to +change the order in which memories are written to or read from file, eg, +@code{signature,etc} is a list of all memories such that the +@code{signature} memory comes first. It is possible to remove a memory +from the list so far by preceding a minus or backslash, eg, +@code{all,-calibration}. Use the @option{-T part} option on the command +line or the @code{part} command in the interactive terminal to display all +the memories supported by a particular device. Typically, a device's memory configuration at least contains the memory types @code{flash}, @code{eeprom}, @code{signature} and @code{lock}, which @@ -1011,10 +1022,10 @@ Intel Hex Intel Hex with comments on download and tolerance of checksum errors on upload @item s -Motorola S-record +Motorola S-Record @item r -raw binary; little-endian byte order, in the case of the flash ROM data +raw binary; little-endian byte order, in the case of the flash data @item e ELF (Executable and Linkable Format), the final output file from the @@ -1063,11 +1074,17 @@ bytes and write a @code{0x2a} to memory followed by @code{0x00}, while @code{0x01234} will occupy 4 bytes. See the description of the terminal write command for more details. -In absence of an explicit file format, the default is to use auto detection -for input files, and raw binary format for output files. Note that if -@var{filename} contains a colon as penultimate character the @var{format} -field is no longer optional since the last character would otherwise be -misinterpreted as @var{format}. +In absence of an explicit file format, the default is to use auto +detection for input files, raw binary format for output files from a +single memory read and Intel Hex with comments when an output file is +generated from a list of memories. Note that while AVRDUDE will generate a +single output file from a memory list for all formats with the exception +of elf (@code{:e}) it only recognises Intel hex (@code{:I} or @code{:i}), +Motorola S-Record (@code{:s}) or elf files (@code{:e}, generated by the +compiler) as valid multi-memory files when reading a file for verifying or +writing memories. Note also that if a @var{filename} contains a colon as +penultimate character the @var{format} field is no longer optional since +the last character would otherwise be misinterpreted as @var{format}. When reading any kind of flash memory area (including the various sub-areas in Xmega devices), the resulting output file will be truncated to not contain @@ -1111,6 +1128,46 @@ see the extended options of the chosen programmer. @cindex Option @code{-x} AVR Dragon @table @code +@cindex Option @code{-x} dryboot +@cindex Option @code{-x} dryrun +@item dryrun +@itemx dryboot + +Both dryrun and dryboot programmers emulate programming and accept the following parameters: + +@table @code +@item @samp{xinit} + +Initialise memories with human-readable patterns. Flash memory will be +randomly configured with respect to bootloader, data and code length. +Patterns can best be seen with fixed-width font and the @code{:I} format +by inspecting the generated hex file or by using, eg, @code{-U +flash:r:-:I}. Patterns in flash memory are executable and represent benign +AVR code, ie, no I/O memory access. Choose a fixed seed for reproducible +results. + +@item @samp{random} +Initialise memories with random code and values. Flash memory will be +randomly configured with respect to bootloader, data and code length. +Random code in flash will be benign, that is, not accessing I/O memories, +SRAM or flash. Choose a fixed seed for reproducible results. + +@item @samp{seed=} +Seed random number generator with @var{n}; the default is +@code{time(NULL)}. Setting this option with a fixed positive @var{n} will +make the random choices reproducible, ie, they will stay the same between +different avrdude runs. + +@item @samp{help} +Show help menu and exit. +@end table + +@cindex Option @code{-x} JTAG ICE mkII/3 +@cindex Option @code{-x} Atmel-ICE +@cindex Option @code{-x} PICkit 4 +@cindex Option @code{-x} MPLAB SNAP +@cindex Option @code{-x} Power Debugger +@cindex Option @code{-x} AVR Dragon @item JTAG ICE mkII/3 @itemx Atmel-ICE @itemx PICkit 4 @@ -2421,6 +2478,33 @@ ELF file formats. All the other file formats lose the address information and concatenate the chosen memory segments into the output file. If the file name is - then avrdude writes to stdout. +@item backup @var{memlist} @var{file[:format]} +Backup one or more memories to the specified file using the selected +format. The default format for a single-memory backup is @code{:r} (raw +binary); for multi-memory backups it is @code{:I} (Intel Hex with +comments). @var{Memlist} can be a comma separated list of memories just as +in the @code{-U} command line argument. @code{backup} flushes the cache +before reading memories. + +@item restore @var{memlist} @var{file[:format]} +Restore one or more memories from the specified file. It is the user's +responsibility to erase memories as needed beforehand: some paged memories +look like NOR-memory when using certain programmers, meaning programming +cannot set bits to 1 (eg, flash under most programmers). These memories +need to be erased beforehand using the erase command (see below). The +format only needs to be specified if it cannot be automatically detected, +eg, when the file is @code{-} for standard input. @var{Memlist} can be a +comma separated list of memories just as in the @code{-U} command line +argument. @code{restore} flushes the cache before writing memories and +resets the cache after writing memories. Note that restoring read-only +memories verifies file contents with the corresponding microprocessor's +memories. + +@item verify @var{memlist} @var{file[:format]} +Compare one or more memories with the specified file. Memlist can be a +comma separated list of memories just as in the @code{-U} command line +argument. @code{verify} flushes the cache before verifying memories. + @item erase Perform a chip erase and discard all pending writes to EEPROM and flash. Note that EEPROM will be preserved if the EESAVE fuse bit is set. @@ -4404,13 +4488,13 @@ fuse, and then power-cycling the target. While this mode is mainly intended for debugging/emulation, it also offers limited programming capabilities. Effectively, the only memory areas that can be read or programmed -in this mode are flash ROM and EEPROM. +in this mode are flash and EEPROM. It is also possible to read out the signature. All other memory areas cannot be accessed. There is no @emph{chip erase} functionality in debugWire mode; instead, while reprogramming the -flash ROM, each flash ROM page is erased right before updating it. +flash, each flash page is erased right before updating it. This is done transparently by the JTAG ICE mkII (or AVR Dragon). The only way back from debugWire mode is to initiate a special sequence of commands to the JTAG ICE mkII (or AVR Dragon), so the diff --git a/src/term.c b/src/term.c index 01e13620..e71d5f22 100644 --- a/src/term.c +++ b/src/term.c @@ -99,7 +99,7 @@ struct command cmd[] = { { "dump", cmd_dump, _fo(read_byte_cached), "display a memory section as hex dump" }, { "read", cmd_dump, _fo(read_byte_cached), "alias for dump" }, { "write", cmd_write, _fo(write_byte_cached), "write data to memory; flash and EEPROM are cached" }, - { "save", cmd_save, _fo(write_byte_cached), "save memory data to file" }, + { "save", cmd_save, _fo(write_byte_cached), "save memory segments to file" }, { "backup", cmd_backup, _fo(write_byte_cached), "backup memories to file" }, { "restore", cmd_restore, _fo(write_byte_cached), "restore memories from file" }, { "verify", cmd_verify, _fo(write_byte_cached), "compare memories with file" }, @@ -729,12 +729,12 @@ static int cmd_backup(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c if(argc != 3 || (argc > 1 && str_eq(argv[1], "-?"))) { msg_error( "Syntax: backup [:]\n" - "Function: save memories to file; default format :I Intel Hex + comments\n" + "Function: backup memories to file; default format :I Intel Hex + comments\n" "Notes:\n" " - Backup flushes the cache before reading memories\n" " - can be a comma separated list of known memories, all, etc or ALL\n" " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" - " - A single list subtraction \\ (without) is allowed, eg, all\\bootrow\n" + " - A leading - or \\ removes that memory from the list so far, eg, all,-bootrow\n" ); return -1; } @@ -776,7 +776,7 @@ static int cmd_restore(const PROGRAMMER *pgm, const AVRPART *p, int argc, const " - After writing memories restore resets the cache\n" " - can be a comma separated list of known memories, all, etc or ALL\n" " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" - " - A single list subtraction \\ (without) is allowed, eg, all\\bootrow\n" + " - A leading - or \\ removes that memory from the list so far, eg, all,-bootrow\n" " - Restoring a read-only memory verifies file contents with MUC memory\n" ); return -1; @@ -818,7 +818,7 @@ static int cmd_verify(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c " - Verify flushes the cache before verifying memories\n" " - can be a comma separated list of known memories, all, etc or ALL\n" " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" - " - A single list subtraction \\ (without) is allowed, eg, all\\bootrow\n" + " - A leading - or \\ removes that memory from the list so far, eg, all,-bootrow\n" ); return -1; } From 2ad860a53ae407e60cf1136557123655a94ed454 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 4 Jul 2024 00:03:07 +0100 Subject: [PATCH 220/422] Remove unused code --- src/dryrun.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index 6147a9b9..94f7d845 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -509,10 +509,11 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { if(dry.dp) // Already configured return; - unsigned char inifuses[16]; // For fuses: made up from fuse0, fuse1, ... + unsigned char inifuses[16]; // For fuses: made up from fuse0, fuse1, ... AVRMEM *m, *fusesm = NULL, *prodsigm = NULL, *calm; - AVRPART *q = dry.dp = avr_dup_part(p); // Allocate dryrun part and abbreviate with q + AVRPART *q = dry.dp = avr_dup_part(p); // Allocate dryrun part and abbreviate with q + memset(inifuses, 0xff, sizeof inifuses); srandom(dry.seed? dry.seed: time(NULL)); // Initialise the device with factory setting and erase flash/EEPROM to 0xff @@ -631,26 +632,6 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { if(flashlayout(pgm, q, flm, up, cp, nc) < 0) return; -#if 0 // Only a dryrun device, but what if saved random fuses are stored to a real device? - if(dry.random) { - const char *exempt[] = { - "rstdisbl", "selfprgen", "spien", // Here be dragons? - "rstpincfg", "updipincfg", "nvmkey", "nvmlevel", - "ap", "blb0", "blb1", "blba", "blbat", "blbb", "blp", "key", "lb", // lockbits - "crcsel", "crcsrc", // Not emulating CRCs in code/boot sections (yet) - "bootsize", "bootend", "codesize", "append", "bootrst", "bootsz", // Already randomly set - }; - for(int i=0; i 0 && cp[i].vlist? - cp[i].vlist[random() % cp[i].nvalues].value: // Have existing list of values, pick one - (random() & cp[i].mask) >> cp[i].lsh; // "free" value, shift mask into position - set_config_values(pgm, q, cp[i].name, v); - } - } - } -#endif - int vtb = putvectortable(q, flm, dry.appstart), urbtsz = 0; int urboot = random()%3 && dry.bootsize <= 512 && flm->size >= 1024 && From 2e1b66fb3456005c8ba0bef1b27f2d4138b63768 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 4 Jul 2024 11:24:13 +0100 Subject: [PATCH 221/422] Add more documentation for memory lists --- src/avrdude.1 | 5 ++++- src/doc/avrdude.texi | 9 ++++++--- src/term.c | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index d70d0a9a..35fce6dd 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -961,7 +961,10 @@ field specifies what operation to perform: .It Ar r read device memory and write to the specified file .It Ar w -read data from the specified file and write to the device memory +read data from the specified file and write to the device memories in the +list; read-only memories in a memory list are skipped, as are fuses and +lock bits when the programmer is a bootloader; writing to single read-only +memories fails only if the contents differs between the file and memory .It Ar v read data from both the device and the specified file and perform a verify .El diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 9f0987a0..2d1db42d 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -1000,13 +1000,16 @@ The @var{op} field specifies what operation to perform: @table @code @item r -read the specified device memory and write to the specified file +read device memories and write to the specified file @item w -read the specified file and write it to the specified device memory +read data from the specified file and write to the device memories in the +list; read-only memories in a memory list are skipped, as are fuses and +lock bits when the programmer is a bootloader; writing to single read-only +memories fails only if the contents differs between the file and memory @item v -read the specified device memory and the specified file and perform a verify operation +read data from both the device and the specified file and perform a verify @end table diff --git a/src/term.c b/src/term.c index e71d5f22..2eda2db9 100644 --- a/src/term.c +++ b/src/term.c @@ -777,7 +777,8 @@ static int cmd_restore(const PROGRAMMER *pgm, const AVRPART *p, int argc, const " - can be a comma separated list of known memories, all, etc or ALL\n" " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" " - A leading - or \\ removes that memory from the list so far, eg, all,-bootrow\n" - " - Restoring a read-only memory verifies file contents with MUC memory\n" + " - Skips read-only memories in a list and, for bootloaders, also fuses and lock\n" + " - Writing to single read-only memories only fails if the contents differs\n" ); return -1; } From 4f25cf8be6f12833311f8582616f38dd4d7da643 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 4 Jul 2024 15:33:36 +0100 Subject: [PATCH 222/422] Remove processing -U ... heading for backup/restore/verify --- src/libavrdude.h | 1 + src/term.c | 6 +++--- src/update.c | 10 ++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 627d54b1..baa24b1c 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1274,6 +1274,7 @@ enum updateflags { UF_NOWRITE = 1, UF_AUTO_ERASE = 2, UF_VERIFY = 4, + UF_NOHEADING = 8, }; diff --git a/src/term.c b/src/term.c index 2eda2db9..e56becf7 100644 --- a/src/term.c +++ b/src/term.c @@ -758,7 +758,7 @@ static int cmd_backup(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c }; pgm->flush_cache(pgm, p); // Flush cache before any device memory access - int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE); // -U argv[1]:r:file + int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE|UF_NOHEADING); // -U argv[1]:r:file mmt_free(upd.filename); mmt_free(upd.memstr); @@ -802,7 +802,7 @@ static int cmd_restore(const PROGRAMMER *pgm, const AVRPART *p, int argc, const }; pgm->flush_cache(pgm, p); // Flush cache before any device memory access - int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE|UF_VERIFY); // -U argv[1]:w:file (no -V) + int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE|UF_VERIFY|UF_NOHEADING); // -U argv[1]:w:file (no -V) mmt_free(upd.filename); mmt_free(upd.memstr); pgm->reset_cache(pgm, p); // Reset cache after writing to memories @@ -843,7 +843,7 @@ static int cmd_verify(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c }; pgm->flush_cache(pgm, p); // Flush cache before any device memory access - int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE); // -V -U argv[1]:v:file + int ret = do_op(pgm, p, &upd, UF_AUTO_ERASE|UF_NOHEADING); // -V -U argv[1]:v:file mmt_free(upd.filename); mmt_free(upd.memstr); diff --git a/src/update.c b/src/update.c index 5823cace..9a5637a7 100644 --- a/src/update.c +++ b/src/update.c @@ -633,12 +633,14 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat AVRMEM *mem, **umemlist = NULL, *m; Segment *seglist = NULL; Filestats fs; - char *tofree; const char *umstr = upd->memstr; - lmsg_info("\n"); // Ensure an empty line for visual separation of operations - pmsg_info("processing %s\n", tofree = update_str(upd)); - mmt_free(tofree); + if(!(flags & UF_NOHEADING)) { + char *heading = update_str(upd); + lmsg_info("\n"); // Ensure an empty line for visual separation of operations + pmsg_info("processing %s\n", heading); + mmt_free(heading); + } if(upd->cmdline) { if(!str_eq(upd->cmdline, "interactive terminal")) From 7427a8e37109c99faee96f13edc7e7984dd7fd1a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 4 Jul 2024 15:43:23 +0100 Subject: [PATCH 223/422] Remove -U/-T/-t heading when only one requested --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.c b/src/main.c index 9f7dc311..3e15575f 100644 --- a/src/main.c +++ b/src/main.c @@ -1724,6 +1724,8 @@ skipopen: int wrmem = 0, terminal = 0; + if(lsize(updates) <= 1) + uflags |= UF_NOHEADING; for (ln=lfirst(updates); ln; ln=lnext(ln)) { const AVRMEM *m; upd = ldata(ln); From ebe370ab0e35d970601496c331c85198a0587955 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 20 Jun 2024 00:10:01 +0100 Subject: [PATCH 224/422] Document XMEGA calibration, sernum and tempsense memories --- src/avrdude.1 | 16 ++++++++++++---- src/doc/avrdude.texi | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index 3a859781..528d40cf 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -845,6 +845,9 @@ Application flash area Application table flash area .It boot Boot flash area +.It calibration +An area of 4 (ATxmega-A series) or 5 bytes (ATxmega-B/C/D/E) with +oscillator calibration values; this is a sub-memory of prodsig .It fuse0 A.k.a. jtaguid: JTAG user ID for some devices .It fuse1 @@ -857,12 +860,17 @@ Other fuse bytes of ATxmega devices, where is 2, 4 or 5, for system configuration .It prodsig The production signature row is a read-only memory section for factory -programmed data such as the signature and calibration values for -oscillators or analogue modules; it also contains a serial number that -consists of the production lot number, wafer number and wafer coordinates -for the part +programmed data such as the calibration values for oscillators or analogue +modules; it also contains a serial number that consists of the production +lot number, wafer number and wafer coordinates for the part +.It sernum +Serial number with a unique ID for the part consisting of 10 bytes; these +are part of the prodsig memory above .It sigrow Memory alias for prodsig +.It tempsense +A two-byte memory, which is located within prodsig; it contains a 12-bit +temperature sensor calibration value .It usersig Additional flash memory page that can be used for firmware settings; this memory is not erased during a chip erase diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index b9b9dacf..dcde9e53 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -901,6 +901,9 @@ Application flash area Application table flash area @item boot Boot flash area +@item calibration +An area of 4 (ATxmega-A series) or 5 bytes (ATxmega-B/C/D/E) with +oscillator calibration values; this is a sub-memory of @code{prodsig} @item fuse0 A.k.a. jtaguid: JTAG user ID for some devices @item fuse1 @@ -911,12 +914,17 @@ Fault detection action configuration TC4/5 for ATxmega E series parts Other fuse bytes of ATxmega devices, where @emph{N} is 2, 4 or 5, for system configuration @item prodsig The production signature row is a read-only memory section for factory -programmed data such as the signature and calibration values for -oscillators or analogue modules; it also contains a serial number that -consists of the production lot number, wafer number and wafer coordinates -for the part +programmed data such as calibration values for oscillators or analogue +modules; it also contains a serial number that consists of the production +lot number, wafer number and wafer coordinates for the part +@item sernum +Serial number with a unique ID for the part consisting of 10 bytes; these +are part of the @code{prodsig} memory above @item sigrow Memory alias for prodsig +@item tempsense +A two-byte memory, which is located within @code{prodsig}; it contains a 12-bit +temperature sensor calibration value @item usersig Additional flash memory page that can be used for firmware settings; this memory is not erased during a chip erase From cde5d3e4619bc670ecba0d6761ad7cd1f99d4845 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 20 Jun 2024 00:26:39 +0100 Subject: [PATCH 225/422] Add sernum memory to m324pb, m328pb, t102 and t104 --- src/avrdude.conf.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 73f78feb..43a6efae 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -6233,6 +6233,11 @@ part parent "m324p" # m324pb memory "sigrow" alias "prodsig"; ; + + memory "sernum" + size = 10; + offset = 0xe; # Sub-region of prodsig + ; ; #------------------------------------------------------------ @@ -11036,6 +11041,11 @@ part parent "m328" # m328pb memory "sigrow" alias "prodsig"; ; + + memory "sernum" + size = 10; + offset = 0xe; # Sub-region of prodsig + ; ; #------------------------------------------------------------ @@ -20763,6 +20773,11 @@ part parent ".reduced_core_tiny" # t102 alias "prodsig"; ; + memory "sernum" + size = 10; + offset = 0x6; # Sub-region of prodsig + ; + memory "io" size = 64; ; @@ -20806,6 +20821,11 @@ part parent ".reduced_core_tiny" # t104 alias "prodsig"; ; + memory "sernum" + size = 10; + offset = 0x6; # Sub-region of prodsig + ; + memory "io" size = 64; ; From 110c7f961418f33c7ca7c8e97dd32bdbf356744d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 20 Jun 2024 22:38:52 +0100 Subject: [PATCH 226/422] Add collective fuses memory for XMEGAs --- src/avrdude.conf.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 43a6efae..51c54dfb 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -17313,6 +17313,18 @@ part # .xmega-cd readsize = 256; ; + ###### + # Collective fuses memory + # - Does not know factory settings (only individual fuse bytes do) + # - fuses[0] (jtaguid) only used for (most) XMEGA-A/B parts + # - fuses[3] always reserved + # - fuses[6] only used in XMEGA-E parts + # + memory "fuses" + size = 7; + offset = 0x8f0020; + ; + memory "fuse1" size = 1; initval = 0x00; From d184b10e540a2fd7ac490f4751daf778fa9e0f54 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 21 Jun 2024 20:59:40 +0100 Subject: [PATCH 227/422] Fix access to sigrow submemories in jtag3.c --- src/jtag3.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/jtag3.c b/src/jtag3.c index c5ff43db..b3935d6e 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -1184,8 +1184,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) { u32_to_b4(xd.nvm_prod_sig_offset, m->offset); } } - if(p->prog_modes & (PM_PDI | PM_UPDI)) - u32_to_b4(xd.nvm_data_offset, DATA_OFFSET); + u32_to_b4(xd.nvm_data_offset, DATA_OFFSET); if (jtag3_setparm(pgm, SCOPE_AVR, 2, PARM3_DEVICEDESC, (unsigned char *)&xd, sizeof xd) < 0) return -1; @@ -1245,8 +1244,7 @@ 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 (p->prog_modes & PM_UPDI && - PDATA(pgm)->use_hvupdi == true && + if (PDATA(pgm)->use_hvupdi == true && p->hvupdi_variant != HV_UPDI_VARIANT_1) { parm[0] = PARM3_UPDI_HV_NONE; for (LNODEID ln = lfirst(pgm->hvupdi_support); ln; ln = lnext(ln)) { @@ -2108,7 +2106,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM paddr = jtag3_memaddr(pgm, p, mem, addr); if (paddr != addr) - imsg_notice2("mapped to address: 0x%lx\n", paddr); + imsg_debug("addr 0x%lx mapped to address 0x%lx\n", addr, paddr); paddr = 0; if (mem->size < 1) { @@ -2131,7 +2129,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM cmd[3] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_FLASH: MTYPE_FLASH_PAGE; if (mem_is_in_flash(mem)) { - addr += mem->offset & (512 * 1024 - 1); /* max 512 KiB flash */ + addr += mem->offset & (512 * 1024 - 1); /* max 512 KiB flash @@@ could be max 8M */ pagesize = PDATA(pgm)->flash_pagesize; paddr = addr & ~(pagesize - 1); paddr_ptr = &PDATA(pgm)->flash_pageaddr; @@ -2167,19 +2165,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM if (pgm->flag & PGM_FL_IS_DW) unsupp = 1; } - } else if (mem_is_sernum(mem)) { - cmd[3] = MTYPE_SIGN_JTAG; - } else if (mem_is_osccal16(mem)) { - cmd[3] = MTYPE_SIGN_JTAG; - } else if (mem_is_osccal20(mem)) { - cmd[3] = MTYPE_SIGN_JTAG; - } else if (mem_is_tempsense(mem)) { - cmd[3] = MTYPE_SIGN_JTAG; - } else if (mem_is_osc16err(mem)) { - cmd[3] = MTYPE_SIGN_JTAG; - } else if (mem_is_osc20err(mem)) { - cmd[3] = MTYPE_SIGN_JTAG; - } else if (mem_is_calibration(mem)) { + } else if (!(p->prog_modes & (PM_PDI | PM_UPDI)) && mem_is_calibration(mem)) { // Classic part calibration cmd[3] = MTYPE_OSCCAL_BYTE; if (pgm->flag & PGM_FL_IS_DW) unsupp = 1; @@ -2226,6 +2212,11 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM msg_error("address out of range for signature memory: %lu\n", addr); return -1; } + } else if(mem_is_in_sigrow(mem)) { // sigrow submemories but not signature nor sigrow itself + cmd[3] = (p->prog_modes & PM_PDI)? MTYPE_SIGN_JTAG: MTYPE_PRODSIG; + AVRMEM *sigrow = avr_locate_sigrow(p); + if(sigrow) + addr += mem->offset - sigrow->offset; // Adjust offset for parent memory } else { pmsg_error("unknown memory %s\n", mem->desc); return -1; From 56e6535f963c0daf038cc46bf74118924d6e1b61 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 21 Jun 2024 21:32:11 +0100 Subject: [PATCH 228/422] Document the new fuses memory for XMEGAs --- src/avrdude.1 | 6 +++++- src/doc/avrdude.texi | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index 528d40cf..b97d7a9f 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -848,6 +848,10 @@ Boot flash area .It calibration An area of 4 (ATxmega-A series) or 5 bytes (ATxmega-B/C/D/E) with oscillator calibration values; this is a sub-memory of prodsig +.It fuses +A logical memory of 7 bytes containing all fuseX of a part, which can be +used to program all fuses at the same time; note that some fuse bytes will +be reserved, though .It fuse0 A.k.a. jtaguid: JTAG user ID for some devices .It fuse1 @@ -903,7 +907,7 @@ A.k.a. bootend or bootsize: end of the boot section or the boot size in blocks o .It fusea A.k.a. pdicfg: configures/locks updi access; it is the only fuse that consists of two bytes .It fuses -A "logical" memory of up to 16 bytes containing all fuseX of a part, which can be +A logical memory of up to 16 bytes containing all fuseX of a part, which can be used to program all fuses at the same time .It osc16err Two bytes typically describing the 16 MHz oscillator frequency error at 3 V and 5 V, respectively diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index dcde9e53..20b99dda 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -904,6 +904,10 @@ Boot flash area @item calibration An area of 4 (ATxmega-A series) or 5 bytes (ATxmega-B/C/D/E) with oscillator calibration values; this is a sub-memory of @code{prodsig} +@item fuses +A logical memory of 7 bytes containing all @code{fuse}X of a part, which +can be used to program all fuses at the same time; note that some of the +fuse bytes will be reserved, though @item fuse0 A.k.a. jtaguid: JTAG user ID for some devices @item fuse1 @@ -957,7 +961,7 @@ A.k.a. bootend or bootsize: end of the boot section or the boot size in blocks o @item fusea A.k.a. pdicfg: configures/locks updi access; it is the only fuse that consists of two bytes @item fuses -A "logical" memory of up to 16 bytes containing all fuseX of a part, which can be used to program all fuses at the same time +A logical memory of up to 16 bytes containing all fuseX of a part, which can be used to program all fuses at the same time @item osc16err Two bytes typically describing the 16 MHz oscillator frequency error at 3 V and 5 V, respectively @item osc20err From 808457e53e3a037a8a0fe962a55019a8c5a5348f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 4 Jul 2024 17:34:36 +0100 Subject: [PATCH 229/422] Fix flash size of x128a4 --- src/avrdude.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 51c54dfb..bf090b0f 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -19064,7 +19064,7 @@ part parent ".xmega-ab" # x128a4 memory "flash" size = 0x22000; - page_size = 512; + page_size = 256; ; memory "application" From dbb2fc36e4b113af5aa797b62f496bf5cf1e4349 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 4 Jul 2024 20:23:01 +0100 Subject: [PATCH 230/422] Adapt dryrun.c to new XMEGA memories --- src/dryrun.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index 94f7d845..dde53cc2 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -557,12 +557,10 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { } else if(mem_is_sigrow(m) && m->size >= 6) { prodsigm = m; memset(m->buf, 0xff, m->size); - if(q->prog_modes & PM_PDI) { - m->buf[0] = m->buf[1] = 'U'; - } else if(q->prog_modes & PM_Classic) { // Signature at even addresses + // Classic parts: signature at even addresses @@@ but not t102/t104 + if(q->prog_modes & PM_Classic) for(int i=0; i<3; i++) m->buf[2*i] = q->signature[i]; - } } else if(mem_is_io(m)) { // Initialise reset values (if known) int nr; const Register_file *rf = avr_locate_register_file(q, &nr); @@ -575,7 +573,7 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { } } if(prodsigm) { - if(q->prog_modes & PM_UPDI) { + if(q->prog_modes & (PM_UPDI | PM_PDI)) { for (LNODEID ln=lfirst(q->mem); ln; ln=lnext(ln)) { AVRMEM *m = ldata(ln); if(m->buf == prodsigm->buf) // Skip prodsig memory @@ -588,7 +586,7 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { } } if((q->prog_modes & PM_Classic) && (calm = avr_locate_calibration(q))) { - // Calibration bytes of classic parts are interspersed with signature + // Calibration bytes of classic parts are interspersed with signature @@@ but not t102/104 for(int i=0; isize; i++) if(2*i+1 < prodsigm->size) prodsigm->buf[2*i+1] = 'U'; From ff35f536531b8d9ad10689ec62fac414b4cf91f7 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 4 Jul 2024 20:25:23 +0100 Subject: [PATCH 231/422] Prevent warnings for incomplete stump XMEGA family entries --- src/avrdude.conf.in | 350 +------------------------------------------- 1 file changed, 7 insertions(+), 343 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index eb4bcb1e..4b4135e1 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -17286,30 +17286,37 @@ part # .xmega-cd factory_fcpu = 2000000; memory "eeprom" + size = 2048; page_size = 32; offset = 0x8c0000; readsize = 256; ; memory "flash" + size = 0x11000; page_size = 256; offset = 0x800000; readsize = 256; ; memory "application" + size = 0x10000; page_size = 256; offset = 0x800000; readsize = 256; ; memory "apptable" + size = 4096; page_size = 256; + offset = 0x80f000; readsize = 256; ; memory "boot" + size = 4096; page_size = 256; + offset = 0x810000; readsize = 256; ; @@ -17522,12 +17529,10 @@ part parent ".xmega-ab" # x16a4u ; memory "apptable" - size = 4096; offset = 0x803000; ; memory "boot" - size = 4096; offset = 0x804000; ; @@ -17571,12 +17576,10 @@ part parent ".xmega-cd" # x16c4 ; memory "apptable" - size = 4096; offset = 0x803000; ; memory "boot" - size = 4096; offset = 0x804000; ; @@ -17625,12 +17628,10 @@ part parent ".xmega-cd" # x16d4 ; memory "apptable" - size = 4096; offset = 0x803000; ; memory "boot" - size = 4096; offset = 0x804000; ; @@ -17680,12 +17681,10 @@ part parent ".xmega-ab" # x16a4 ; memory "apptable" - size = 4096; offset = 0x803000; ; memory "boot" - size = 4096; offset = 0x804000; ; @@ -17735,12 +17734,10 @@ part parent ".xmega-ab" # x32a4u ; memory "apptable" - size = 4096; offset = 0x807000; ; memory "boot" - size = 4096; offset = 0x808000; ; @@ -17784,12 +17781,10 @@ part parent ".xmega-cd" # x32c4 ; memory "apptable" - size = 4096; offset = 0x807000; ; memory "boot" - size = 4096; offset = 0x808000; ; @@ -17839,12 +17834,10 @@ part parent ".xmega-cd" # x32d4 ; memory "apptable" - size = 4096; offset = 0x807000; ; memory "boot" - size = 4096; offset = 0x808000; ; @@ -17894,12 +17887,10 @@ part parent ".xmega-ab" # x32a4 ; memory "apptable" - size = 4096; offset = 0x807000; ; memory "boot" - size = 4096; offset = 0x808000; ; @@ -17935,28 +17926,6 @@ part parent ".xmega-ab" # x64a4u signature = 0x1e 0x96 0x46; usbpid = 0x2fe5; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "prodsig" size = 64; page_size = 64; @@ -18002,12 +17971,10 @@ part parent ".xmega-cd" # x32c3 ; memory "apptable" - size = 4096; offset = 0x807000; ; memory "boot" - size = 4096; offset = 0x808000; ; @@ -18054,12 +18021,10 @@ part parent ".xmega-cd" # x32d3 ; memory "apptable" - size = 4096; offset = 0x807000; ; memory "boot" - size = 4096; offset = 0x808000; ; @@ -18094,28 +18059,6 @@ part parent ".xmega-cd" # x64c3 signature = 0x1e 0x96 0x49; usbpid = 0x2fd6; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "prodsig" page_size = 64; ; @@ -18147,28 +18090,6 @@ part parent ".xmega-cd" # x64d3 signature = 0x1e 0x96 0x4a; usbpid = 0x2fe5; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "prodsig" size = 52; readsize = 52; @@ -18201,28 +18122,6 @@ part parent ".xmega-cd" # x64d4 signature = 0x1e 0x96 0x47; usbpid = 0x2fe5; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "prodsig" page_size = 64; ; @@ -18253,28 +18152,6 @@ part parent ".xmega-ab" # x64a1 signature = 0x1e 0x96 0x4e; usbpid = 0x2fe5; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "fuse2" bitmask = 0x43; ; @@ -18305,28 +18182,6 @@ part parent ".xmega-ab" # x64a1u signature = 0x1e 0x96 0x4e; usbpid = 0x2fe8; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "prodsig" size = 64; page_size = 64; @@ -18358,28 +18213,6 @@ part parent ".xmega-ab" # x64a3 signature = 0x1e 0x96 0x42; usbpid = 0x2fe5; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "fuse2" bitmask = 0x43; ; @@ -18409,28 +18242,6 @@ part parent ".xmega-ab" # x64a3u signature = 0x1e 0x96 0x42; usbpid = 0x2fe5; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "sram" size = 4096; ; @@ -18451,28 +18262,6 @@ part parent ".xmega-ab" # x64a4 signature = 0x1e 0x96 0x46; usbpid = 0x2fe5; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "fuse0" initval = -1; ; @@ -18523,28 +18312,6 @@ part parent ".xmega-ab" # x64b1 signature = 0x1e 0x96 0x52; usbpid = 0x2fe1; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "fuse4" initval = 0xff; ; @@ -18575,28 +18342,6 @@ part parent ".xmega-ab" # x64b3 signature = 0x1e 0x96 0x51; usbpid = 0x2fdf; - memory "eeprom" - size = 2048; - ; - - memory "flash" - size = 0x11000; - ; - - memory "application" - size = 0x10000; - ; - - memory "apptable" - size = 4096; - offset = 0x80f000; - ; - - memory "boot" - size = 4096; - offset = 0x810000; - ; - memory "fuse4" initval = 0xff; ; @@ -18630,10 +18375,6 @@ part parent ".xmega-cd" # x128c3 signature = 0x1e 0x97 0x52; usbpid = 0x2fd7; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; page_size = 512; @@ -18691,10 +18432,6 @@ part parent ".xmega-cd" # x128d3 signature = 0x1e 0x97 0x48; usbpid = 0x2fd7; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; page_size = 512; @@ -18754,10 +18491,6 @@ part parent ".xmega-cd" # x128d4 signature = 0x1e 0x97 0x47; usbpid = 0x2fd7; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; ; @@ -18814,10 +18547,6 @@ part parent ".xmega-ab" # x128a1 signature = 0x1e 0x97 0x4c; usbpid = 0x2fd7; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; page_size = 512; @@ -18887,10 +18616,6 @@ part parent ".xmega-ab" # x128a1u signature = 0x1e 0x97 0x4c; usbpid = 0x2fed; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; page_size = 512; @@ -18949,10 +18674,6 @@ part parent ".xmega-ab" # x128a3 signature = 0x1e 0x97 0x42; usbpid = 0x2fd7; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; page_size = 512; @@ -19009,10 +18730,6 @@ part parent ".xmega-ab" # x128a3u signature = 0x1e 0x97 0x42; usbpid = 0x2fe6; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; page_size = 512; @@ -19058,13 +18775,8 @@ part parent ".xmega-ab" # x128a4 boot_section_size = 8192; signature = 0x1e 0x97 0x46; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; - page_size = 256; ; memory "application" @@ -19073,7 +18785,6 @@ part parent ".xmega-ab" # x128a4 ; memory "apptable" - size = 4096; page_size = 512; offset = 0x81f000; ; @@ -19148,10 +18859,6 @@ part parent ".xmega-ab" # x128a4u signature = 0x1e 0x97 0x46; usbpid = 0x2fde; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; ; @@ -19161,7 +18868,6 @@ part parent ".xmega-ab" # x128a4u ; memory "apptable" - size = 4096; offset = 0x81f000; ; @@ -19200,10 +18906,6 @@ part parent ".xmega-ab" # x128b1 signature = 0x1e 0x97 0x4d; usbpid = 0x2fea; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; ; @@ -19255,10 +18957,6 @@ part parent ".xmega-ab" # x128b3 signature = 0x1e 0x97 0x4b; usbpid = 0x2fe0; - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x22000; ; @@ -19307,12 +19005,6 @@ part parent ".xmega-cd" # x192c3 boot_section_size = 8192; signature = 0x1e 0x97 0x51; -# usbpid = 0x2f??; - - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x32000; page_size = 512; @@ -19369,12 +19061,6 @@ part parent ".xmega-cd" # x192d3 boot_section_size = 8192; signature = 0x1e 0x97 0x49; -# usbpid = 0x2f??; - - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x32000; page_size = 512; @@ -19427,12 +19113,6 @@ part parent ".xmega-ab" # x192a1 boot_section_size = 8192; signature = 0x1e 0x97 0x4e; -# usbpid = 0x2f??; - - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x32000; page_size = 512; @@ -19517,12 +19197,6 @@ part parent ".xmega-ab" # x192a3 boot_section_size = 8192; signature = 0x1e 0x97 0x44; -# usbpid = 0x2f??; - - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x32000; page_size = 512; @@ -19580,12 +19254,6 @@ part parent ".xmega-ab" # x192a3u signature = 0x1e 0x97 0x44; usbpid = 0x2fe7; -# usbpid = 0x2f??; - - memory "eeprom" - size = 2048; - ; - memory "flash" size = 0x32000; page_size = 512; @@ -20260,12 +19928,10 @@ part parent ".xmega-e" # x16e5 ; memory "apptable" - size = 4096; offset = 0x803000; ; memory "boot" - size = 4096; offset = 0x804000; ; @@ -20310,12 +19976,10 @@ part parent ".xmega-e" # x32e5 ; memory "apptable" - size = 4096; offset = 0x807000; ; memory "boot" - size = 4096; offset = 0x808000; ; From 6de1cd928ec277e7e8be12dfb2575c2e8b8bf0cb Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 4 Jul 2024 20:34:57 +0100 Subject: [PATCH 232/422] Place classic prodsig submemories into flat address model --- src/fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fileio.c b/src/fileio.c index 3004f1f9..719786f8 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -224,7 +224,7 @@ unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { // Classic parts intersperse signature and calibration bytes, this code places them together (p->prog_modes & PM_Classic) && mem_is_signature(mem)? MBASE(SIGROW): (p->prog_modes & PM_Classic) && mem_is_calibration(mem)? MBASE(SIGROW)+3: - (p->prog_modes & PM_Classic) && mem_is_sigrow(mem)? MBASE(SIGROW)+0x10: // Eg, m328pb + (p->prog_modes & PM_Classic) && mem_is_in_sigrow(mem)? MBASE(SIGROW)+0x10+mem->offset-boffset(p, sigrow): // XMEGA parts have signature separate from prodsig, place prodsig at +0x10 as above (p->prog_modes & PM_PDI) && mem_is_signature(mem)? MBASE(SIGROW): (p->prog_modes & PM_PDI) && mem_is_in_sigrow(mem)? MBASE(SIGROW)+0x10 + mem->offset - boffset(p, sigrow): From 42c984c9e83190f3d882799ee1c4a5fed94475bf Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 5 Jul 2024 02:49:20 +0100 Subject: [PATCH 233/422] Update NEWS --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 0433dd0c..828cf711 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ Changes since version 7.3: * Major changes compared to the previous version: + - Support of multi-memory .hex and .srec files and memory lists + * New devices supported: - AVR16DU14, AVR16DU20, AVR16DU28, AVR16DU32 @@ -40,6 +42,7 @@ Changes since version 7.3: - Custom programmer broken in v7.3 #1807 - ATtiny11 does not have EEPROM #1812 - AVRDUDE fails to return -1 on some write errors #1821 + - Multi-memory files #1817 * Pull requests: @@ -95,6 +98,8 @@ Changes since version 7.3: - Extend elf format for bootrow #1820 - Update AUTHORS list #1819 - Downgrade out-of-range file input errors on -F #1818 + - Multi-memory file handling #1828 + - Add developer options -p*/vcr to explore SW compatibility #1830 * Internals: From 640bf85b12c6fb938ab27ed3f8939dc16a98630c Mon Sep 17 00:00:00 2001 From: Dawid Buchwald Date: Fri, 5 Jul 2024 10:23:11 +0200 Subject: [PATCH 234/422] Alternative fix proposal for #1832 --- src/serialupdi.c | 10 ++++++++++ src/updi_nvm.c | 19 +++++++++++++++++++ src/updi_nvm.h | 1 + src/updi_nvm_v0.c | 7 +++++++ src/updi_nvm_v0.h | 1 + src/updi_nvm_v2.c | 11 +++++++++++ src/updi_nvm_v2.h | 1 + src/updi_nvm_v3.c | 7 +++++++ src/updi_nvm_v3.h | 1 + src/updi_nvm_v4.c | 11 +++++++++++ src/updi_nvm_v4.h | 1 + src/updi_nvm_v5.c | 7 +++++++ src/updi_nvm_v5.h | 1 + 13 files changed, 78 insertions(+) diff --git a/src/serialupdi.c b/src/serialupdi.c index d9f58eb8..6c46007d 100644 --- a/src/serialupdi.c +++ b/src/serialupdi.c @@ -769,6 +769,11 @@ static int serialupdi_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const buffer[0]=value; return updi_nvm_write_flash(pgm, p, mem->offset + addr, buffer, 1); } + if (mem_is_bootrow(mem)) { + unsigned char buffer[1]; + buffer[0]=value; + return updi_nvm_write_boot_row(pgm, p, mem->offset + addr, buffer, 1); + } // Read-only memories if(mem_is_readonly(mem)) { unsigned char is; @@ -841,6 +846,9 @@ static int serialupdi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const } else if (mem_is_userrow(m)) { rc = serialupdi_write_userrow(pgm, p, m, page_size, write_offset, remaining_bytes > m->page_size ? m->page_size : remaining_bytes); + } else if (mem_is_bootrow(m)) { + rc = updi_nvm_write_boot_row(pgm, p, m->offset + write_offset, m->buf + write_offset, + remaining_bytes > m->page_size ? m->page_size : remaining_bytes); } else if (mem_is_fuses(m)) { pmsg_debug("page write operation requested for fuses, falling back to byte-level write\n"); return -1; @@ -866,6 +874,8 @@ static int serialupdi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const rc = updi_nvm_write_flash(pgm, p, m->offset+addr, m->buf+addr, n_bytes); } else if (mem_is_userrow(m)) { rc = serialupdi_write_userrow(pgm, p, m, page_size, addr, n_bytes); + } else if (mem_is_bootrow(m)) { + rc = updi_nvm_write_boot_row(pgm, p, m->offset+addr, m->buf+addr, n_bytes); } else if (mem_is_fuses(m)) { pmsg_debug("page write operation requested for fuses, falling back to byte-level write\n"); rc = -1; diff --git a/src/updi_nvm.c b/src/updi_nvm.c index 89bb2fe9..441432b3 100644 --- a/src/updi_nvm.c +++ b/src/updi_nvm.c @@ -157,6 +157,25 @@ int updi_nvm_write_user_row(const PROGRAMMER *pgm, const AVRPART *p, uint32_t ad } } +int updi_nvm_write_boot_row(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { + switch(updi_get_nvm_mode(pgm)) + { + case UPDI_NVM_MODE_V0: + return updi_nvm_write_boot_row_V0(pgm, p, address, buffer, size); + case UPDI_NVM_MODE_V2: + return updi_nvm_write_boot_row_V2(pgm, p, address, buffer, size); + case UPDI_NVM_MODE_V3: + return updi_nvm_write_boot_row_V3(pgm, p, address, buffer, size); + case UPDI_NVM_MODE_V4: + return updi_nvm_write_boot_row_V4(pgm, p, address, buffer, size); + case UPDI_NVM_MODE_V5: + return updi_nvm_write_boot_row_V5(pgm, p, address, buffer, size); + default: + pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm)); + return -1; + } +} + int updi_nvm_write_eeprom(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { switch(updi_get_nvm_mode(pgm)) { diff --git a/src/updi_nvm.h b/src/updi_nvm.h index cc5e6e5a..50df8f18 100644 --- a/src/updi_nvm.h +++ b/src/updi_nvm.h @@ -39,6 +39,7 @@ int updi_nvm_erase_eeprom(const PROGRAMMER *pgm, const AVRPART *p); int updi_nvm_erase_user_row(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint16_t size); int updi_nvm_write_flash(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_user_row(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); +int updi_nvm_write_boot_row(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_eeprom(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_fuse(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint8_t value); int updi_nvm_wait_ready(const PROGRAMMER *pgm, const AVRPART *p); diff --git a/src/updi_nvm_v0.c b/src/updi_nvm_v0.c index ece24f67..7e048477 100644 --- a/src/updi_nvm_v0.c +++ b/src/updi_nvm_v0.c @@ -282,6 +282,13 @@ int updi_nvm_write_user_row_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t return updi_nvm_write_eeprom_V0(pgm, p, address, buffer, size); } +int updi_nvm_write_boot_row_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { +/* + Perform write operation as if it was regular flash memory, but ensure page erase/page write command +*/ + return nvm_write_V0(pgm, p, address, buffer, size, USE_WORD_ACCESS, UPDI_V0_NVMCTRL_CTRLA_ERASE_WRITE_PAGE); +} + int updi_nvm_write_eeprom_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* def write_eeprom(self, address, data): diff --git a/src/updi_nvm_v0.h b/src/updi_nvm_v0.h index 40d9e3f1..fbf4421d 100644 --- a/src/updi_nvm_v0.h +++ b/src/updi_nvm_v0.h @@ -39,6 +39,7 @@ int updi_nvm_erase_eeprom_V0(const PROGRAMMER *pgm, const AVRPART *p); int updi_nvm_erase_user_row_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint16_t size); int updi_nvm_write_flash_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_user_row_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); +int updi_nvm_write_boot_row_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_eeprom_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_fuse_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint8_t value); int updi_nvm_wait_ready_V0(const PROGRAMMER *pgm, const AVRPART *p); diff --git a/src/updi_nvm_v2.c b/src/updi_nvm_v2.c index bff8e799..c6670916 100644 --- a/src/updi_nvm_v2.c +++ b/src/updi_nvm_v2.c @@ -282,6 +282,17 @@ int updi_nvm_write_user_row_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t return nvm_write_V2(pgm, p, address, buffer, size, DONT_USE_WORD_ACCESS); } +int updi_nvm_write_boot_row_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { +/* + Perform write operation as if it was regular flash memory, but perform erase operation first +*/ + if (updi_nvm_erase_flash_page_V2(pgm, p, address) <0) { + pmsg_error("Flash page erase failed for bootrow\n"); + return -1; + } + return updi_nvm_write_flash_V2(pgm, p, address, buffer, size); +} + int updi_nvm_write_eeprom_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* def write_eeprom(self, address, data): diff --git a/src/updi_nvm_v2.h b/src/updi_nvm_v2.h index 21d97d0c..59ff5eb5 100644 --- a/src/updi_nvm_v2.h +++ b/src/updi_nvm_v2.h @@ -39,6 +39,7 @@ int updi_nvm_erase_eeprom_V2(const PROGRAMMER *pgm, const AVRPART *p); int updi_nvm_erase_user_row_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint16_t size); int updi_nvm_write_flash_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_user_row_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); +int updi_nvm_write_boot_row_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_eeprom_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_fuse_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint8_t value); int updi_nvm_wait_ready_V2(const PROGRAMMER *pgm, const AVRPART *p); diff --git a/src/updi_nvm_v3.c b/src/updi_nvm_v3.c index 51aab6b5..99989ddd 100644 --- a/src/updi_nvm_v3.c +++ b/src/updi_nvm_v3.c @@ -297,6 +297,13 @@ int updi_nvm_write_user_row_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t return nvm_write_V3(pgm, p, address, buffer, size, USE_WORD_ACCESS, USE_DEFAULT_COMMAND); } +int updi_nvm_write_boot_row_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { +/* + Perform the operation as the regular flash write, but with page erase/page write command +*/ + return nvm_write_V3(pgm, p, address, buffer, size, USE_WORD_ACCESS, UPDI_V3_NVMCTRL_CTRLA_FLASH_PAGE_ERASE_WRITE); +} + int updi_nvm_write_eeprom_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* def write_eeprom(self, address, data): diff --git a/src/updi_nvm_v3.h b/src/updi_nvm_v3.h index b0bd293e..92947400 100644 --- a/src/updi_nvm_v3.h +++ b/src/updi_nvm_v3.h @@ -39,6 +39,7 @@ int updi_nvm_erase_eeprom_V3(const PROGRAMMER *pgm, const AVRPART *p); int updi_nvm_erase_user_row_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint16_t size); int updi_nvm_write_flash_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_user_row_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); +int updi_nvm_write_boot_row_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_eeprom_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_fuse_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint8_t value); int updi_nvm_wait_ready_V3(const PROGRAMMER *pgm, const AVRPART *p); diff --git a/src/updi_nvm_v4.c b/src/updi_nvm_v4.c index 154edb5a..5d3b0cd6 100644 --- a/src/updi_nvm_v4.c +++ b/src/updi_nvm_v4.c @@ -283,6 +283,17 @@ int updi_nvm_write_user_row_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t return nvm_write_V4(pgm, p, address, buffer, size, DONT_USE_WORD_ACCESS); } +int updi_nvm_write_boot_row_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { +/* + Write it as a regular flash page, but perform page erase first +*/ + if (updi_nvm_erase_flash_page_V4(pgm, p, address) <0) { + pmsg_error("Flash page erase failed for bootrow\n"); + return -1; + } + return updi_nvm_write_flash_V4(pgm, p, address, buffer, size); +} + int updi_nvm_write_eeprom_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* def write_eeprom(self, address, data): diff --git a/src/updi_nvm_v4.h b/src/updi_nvm_v4.h index aa8a6135..14a16353 100644 --- a/src/updi_nvm_v4.h +++ b/src/updi_nvm_v4.h @@ -39,6 +39,7 @@ int updi_nvm_erase_eeprom_V4(const PROGRAMMER *pgm, const AVRPART *p); int updi_nvm_erase_user_row_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint16_t size); int updi_nvm_write_flash_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_user_row_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); +int updi_nvm_write_boot_row_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_eeprom_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_fuse_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint8_t value); int updi_nvm_wait_ready_V4(const PROGRAMMER *pgm, const AVRPART *p); diff --git a/src/updi_nvm_v5.c b/src/updi_nvm_v5.c index 24002c45..bc11708e 100644 --- a/src/updi_nvm_v5.c +++ b/src/updi_nvm_v5.c @@ -298,6 +298,13 @@ int updi_nvm_write_user_row_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t return nvm_write_V5(pgm, p, address, buffer, size, USE_WORD_ACCESS, USE_DEFAULT_COMMAND); } +int updi_nvm_write_boot_row_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { +/* + Perform the operation as the regular flash write, but with page erase/page write command +*/ + return nvm_write_V5(pgm, p, address, buffer, size, USE_WORD_ACCESS, UPDI_V5_NVMCTRL_CTRLA_FLASH_PAGE_ERASE_WRITE); +} + int updi_nvm_write_eeprom_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* def write_eeprom(self, address, data): diff --git a/src/updi_nvm_v5.h b/src/updi_nvm_v5.h index 0cb1259c..c1102236 100644 --- a/src/updi_nvm_v5.h +++ b/src/updi_nvm_v5.h @@ -39,6 +39,7 @@ int updi_nvm_erase_eeprom_V5(const PROGRAMMER *pgm, const AVRPART *p); int updi_nvm_erase_user_row_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint16_t size); int updi_nvm_write_flash_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_user_row_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); +int updi_nvm_write_boot_row_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_eeprom_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size); int updi_nvm_write_fuse_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, uint8_t value); int updi_nvm_wait_ready_V5(const PROGRAMMER *pgm, const AVRPART *p); From 72064357ae1dc7165a5ba1cffbf02ae76c28d1ef Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 5 Jul 2024 18:26:32 +0100 Subject: [PATCH 235/422] Inform user whether terminal erase includes EEPROM --- src/term.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index e56becf7..ce0eef14 100644 --- a/src/term.c +++ b/src/term.c @@ -964,7 +964,16 @@ static int cmd_erase(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch return cmd_write(pgm, p, 6, args); } - term_out("erasing chip ...\n"); + const char *note = ""; + if(avr_locate_eeprom(p)) { + int eesave, bakverb = verbose; + verbose = -123; // Silently read EESAVE configuration bit + if(avr_get_config_value(pgm, p, "eesave", &eesave) == 0) + note = eesave == !(p->prog_modes & PM_UPDI)? "(including EEPROM) ": "(but not EEPROM) "; + verbose = bakverb; + } + + term_out("erasing chip %s...\n", note); // Erase chip and clear cache int rc = pgm->chip_erase_cached(pgm, p); From 91cd1f967340af392e6fd025c6e868e8685e4469 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 6 Jul 2024 01:47:25 +0100 Subject: [PATCH 236/422] Handle chip erase correctly for bootrow --- src/avrcache.c | 21 +++++++++++---------- src/avrdude.1 | 9 +++++---- src/doc/avrdude.texi | 6 +++--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/avrcache.c b/src/avrcache.c index ea091577..dbf49201 100644 --- a/src/avrcache.c +++ b/src/avrcache.c @@ -66,8 +66,8 @@ * flash (and sometimes EEPROM, too) looks like a NOR memory, ie, a write can * only clear bits, never set them. For NOR memories a page erase or, if not * available, a chip erase needs to be issued before writing arbitrary data. - * Bootrow and usersig are generally unaffected by a chip erase, so will need - * a page erase. When a memory looks like a NOR memory, either page erase is + * Usersig is generally unaffected by a chip erase, so will always need a + * page erase. When a memory looks like a NOR memory, either page erase is * deployed (eg, with parts that have PDI/UPDI interfaces), or if that is not * available, both EEPROM and flash caches are fully read in, a * pgm->chip_erase() command is issued and both EEPROM and flash are written @@ -90,7 +90,7 @@ * has these clear bits on the device. Only with this evidence is the EEPROM * cache preset to all 0xff otherwise the cache discards all pending writes * to EEPROM and is left unchanged otherwise. avr_chip_erase_cached() does not - * affect the bootrow or usersig cache. + * affect the usersig cache. * * The avr_page_erase_cached() function erases a page and synchronises it * with the cache. @@ -689,10 +689,11 @@ int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM // Erase the chip and set the cache accordingly int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p) { - Cache_desc mems[3] = { + Cache_desc mems[] = { { avr_locate_flash(p), pgm->cp_flash, 1, 0, -1, 0 }, { avr_locate_eeprom(p), pgm->cp_eeprom, 0, 1, -1, 0 }, - // bootrow/usersig is unaffected by CE + { avr_locate_bootrow(p), pgm->cp_bootrow, 0, 0, -1, 0 }, + // usersig is unaffected by CE }; int rc; @@ -718,19 +719,19 @@ int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p) { memset(cp->cont, 0xff, cp->size); memset(cp->iscached, 1, cp->size/cp->page_size); } - } else if(mems[i].iseeprom) { // Test whether cached EEPROM pages were zapped - bool erasedee = 0; + } else { // Test whether cached EEPROM/bootrow pages were zapped + bool erased = 0; for(int pgno = 0, n = 0; n < cp->size; pgno++, n += cp->page_size) { if(cp->iscached[pgno]) { - if(!is_memset(cp->copy + n, 0xff, cp->page_size)) { // Page has EEPROM data? + if(!is_memset(cp->copy + n, 0xff, cp->page_size)) { // Page has data? if(avr_read_page_default(pgm, p, mem, n, cp->copy + n) < 0) return LIBAVRDUDE_GENERAL_FAILURE; - erasedee = is_memset(cp->copy + n, 0xff, cp->page_size); + erased = is_memset(cp->copy + n, 0xff, cp->page_size); break; } } } - if(erasedee) { // EEPROM was erased, set cache correspondingly + if(erased) { // Memory was erased, set cache correspondingly memset(cp->copy, 0xff, cp->size); memset(cp->cont, 0xff, cp->size); memset(cp->iscached, 1, cp->size/cp->page_size); diff --git a/src/avrdude.1 b/src/avrdude.1 index 35fce6dd..af2ca414 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -937,10 +937,11 @@ Temperature sensor calibration values .It bootrow Extra page of memory that is only accessible by the MCU in bootloader code; UDPI can read and write this memory only when the device is -unlocked; bootrow is not erased during chip erase +unlocked .It userrow Extra page of EEPROM memory that can be used for firmware settings; this -memory is not erased during a chip erase +memory is not erased during a chip erase; UPDI cannot read this memory +when the device is locked .It sib Special system information block memory with information about AVR family, chip revision etc. .It io @@ -1274,8 +1275,8 @@ Synchronise with the device all pending writes to flash, EEPROM, bootrow and usersig. With some programmer and part combinations, flash (and sometimes EEPROM, too) looks like a NOR memory, i.e., a write can only clear bits, never set them. For NOR memories a page erase or, if not available, a chip -erase needs to be issued before writing arbitrary data. Bootrow and usersig are -generally unaffected by a chip erase. When a memory looks like a NOR +erase needs to be issued before writing arbitrary data. Usersig is +unaffected by a chip erase. When a memory looks like a NOR memory, either page erase is deployed (e.g., with parts that have PDI/UPDI interfaces), or if that is not available, both EEPROM and flash caches are fully read in, a chip erase command is issued and both EEPROM and flash diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 2d1db42d..c084ad61 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -981,7 +981,7 @@ Temperature sensor calibration values @item bootrow Extra page of memory that is only accessible by the MCU in bootloader code; UDPI can read and write this memory only when the device is -unlocked; bootrow is not erased during chip erase +unlocked @item userrow Extra page of EEPROM memory that can be used for firmware settings; this memory is not erased during a chip erase @@ -2523,8 +2523,8 @@ Synchronise with the device all pending writes to flash, EEPROM, bootrow and usersig. With some programmer and part combinations, flash (and sometimes EEPROM, too) looks like a NOR memory, i.e., a write can only clear bits, never set them. For NOR memories a page erase or, if not available, a chip -erase needs to be issued before writing arbitrary data. Bootrow and usersig are -generally unaffected by a chip erase. When a memory looks like a NOR +erase needs to be issued before writing arbitrary data. Usersig is +unaffected by a chip erase. When a memory looks like a NOR memory, either page erase is deployed (e.g., with parts that have PDI/UPDI interfaces), or if that is not available, both EEPROM and flash caches are fully read in, a chip erase command is issued and both EEPROM and flash From 1e05d70cda82c594d3b6ca192189600808d4bbed Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 6 Jul 2024 02:02:28 +0100 Subject: [PATCH 237/422] Improve chip erase emulation for dryboot/dryrun --- src/dryrun.c | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index 94f7d845..7adce1dd 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -62,6 +62,7 @@ typedef struct { int appstart, appsize; // Start and size of application section int datastart, datasize; // Start and size of application data section (if any) int bootstart, bootsize; // Start and size of boot section (if any) + int initialised; // 1 once the part memories are initialised } Dryrun_data; // Use private programmer data as if they were a global structure dry @@ -87,19 +88,40 @@ static int dryrun_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const } -// Emulate chip erase (only erase flash, pretend EESAVE fuse is active - FIXME: check EESAVE fuse) +// Emulate chip erase static int dryrun_chip_erase(const PROGRAMMER *pgm, const AVRPART *punused) { - AVRMEM *flm; + AVRMEM *mem; pmsg_debug("%s()\n", __func__); if(!dry.dp) Return("no dryrun device?"); - if(!(flm = avr_locate_flash(dry.dp))) + if(!(mem = avr_locate_flash(dry.dp))) Return("cannot locate %s flash memory for chip erase", dry.dp->desc); - if(flm->size < 1) - Return("cannot erase %s flash memory owing to its size %d", dry.dp->desc, flm->size); + if(mem->size < 1) + Return("cannot erase %s flash memory owing to its size %d", dry.dp->desc, mem->size); - memset(flm->buf, 0xff, flm->size); + if(dry.bl) { // Bootloaders won't overwrite themselves + memset(mem->buf + (dry.bl == DRY_TOP? 0: dry.bootsize), 0xff, mem->size-dry.bootsize); + return 0; // Assume that's all a bootloader does + } + + memset(mem->buf, 0xff, mem->size); + + int eesave, bakverb = verbose; + verbose = -123; + if((mem = avr_locate_eeprom(dry.dp))) // Check whether EEPROM needs erasing + if(avr_get_config_value(pgm, dry.dp, "eesave", &eesave) == 0 && eesave == !(dry.dp->prog_modes & PM_UPDI)) + if(mem->size > 0) + memset(mem->buf, 0xff, mem->size); + verbose = bakverb; + + if((mem = avr_locate_bootrow(dry.dp))) // Also erase bootrow if it's there + if(mem->size > 0) + memset(mem->buf, 0xff, mem->size); + + if((mem = avr_locate_lock(dry.dp))) + if(mem->initval != -1 && mem->size > 0 && mem->size <= (int) sizeof(mem->initval)) + memcpy(mem->buf, &mem->initval, mem->size); // FIXME: relying on little endian here return 0; } @@ -640,7 +662,12 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { int ps = flm->page_size; urbtsz = dry.bootsize? dry.bootsize: flm->size > 32768? 512: flm->size < 16384? 256: 384; urbtsz = (urbtsz + ps-1)/ps*ps; - int ubaddr = dry.bootsize? dry.bootstart: flm->size - urbtsz; + if(!dry.bootsize && !dry.datasize) { + dry.bootsize += urbtsz; + dry.appsize -= urbtsz; + dry.bootstart = dry.appsize; + } + int ubaddr = dry.bootstart; putflash(pgm, flm, ubaddr, urbtsz, urbtsz==384? U384: U512); flm->buf[ubaddr] = 0xff; flm->buf[ubaddr+1] = 0xcf; // rjmp .-2 } else if(dry.bootsize) { @@ -666,6 +693,7 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { putother(pgm, q, m, "The five boxing wizards jump quickly. "); if((m = avr_locate_bootrow(q))) putother(pgm, q, m, "Lorem ipsum dolor sit amet. "); + dry.initialised = 1; } @@ -942,7 +970,7 @@ static int dryrun_readonly(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM // @@@ check for bootloader write protection - if(mem_is_in_fuses(mem) || mem_is_lock(mem)) + if(dry.initialised && (mem_is_in_fuses(mem) || mem_is_lock(mem))) return 1; return 0; From 9d21e05059b2ac610eaedc8c283c63d89fd41cd9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 6 Jul 2024 02:07:44 +0100 Subject: [PATCH 238/422] Not show EEPROM erase note when a bootloader --- src/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index ce0eef14..de4b564e 100644 --- a/src/term.c +++ b/src/term.c @@ -965,7 +965,7 @@ static int cmd_erase(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch } const char *note = ""; - if(avr_locate_eeprom(p)) { + if(!(pgm->prog_modes & PM_SPM) && avr_locate_eeprom(p)) { // Not a bootloader: is EEPROM saved? int eesave, bakverb = verbose; verbose = -123; // Silently read EESAVE configuration bit if(avr_get_config_value(pgm, p, "eesave", &eesave) == 0) From 4e2413bacbff7859a0db3f2da4240d28204a3087 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 6 Jul 2024 16:01:46 +0100 Subject: [PATCH 239/422] Use page erase for UPDI programming --- src/avrdude.1 | 47 ++++++++++++++++++++++++------------- src/doc/avrdude.texi | 56 +++++++++++++++++++++++++++----------------- src/main.c | 19 ++++++++++----- 3 files changed, 78 insertions(+), 44 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index 35fce6dd..b540d244 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -472,17 +472,15 @@ arduino. .It Fl D Disable auto erase for flash. When the .Fl U -option with flash memory is specified, +option for writing to any flash memory is specified, .Nm will perform a chip erase before starting any of the programming -operations, since it generally is a mistake to program the flash -without performing an erase first. This option disables that. -Auto erase is not used for ATxmega devices as these devices can -use page erase before writing each page so no explicit chip erase -is required. -Note however that any page not affected by the current operation -will retain its previous contents. -Setting +operations, since it generally is a mistake to program the flash without +performing an erase first. This option disables that. Auto erase is not +used for ATxmega parts nor for the UPDI (AVR8X family) parts as these can +use page erase before writing each page so no explicit chip erase is +required. Note, however, that any flash page not affected by the current +operation will retain its previous contents. Setting .Fl D implies .Fl A. @@ -491,9 +489,9 @@ Causes a chip erase to be executed. This will reset the contents of the flash ROM and EEPROM to the value .Ql 0xff , and clear all lock bits. -Except for ATxmega devices which can use page erase, -it is basically a prerequisite command before the flash ROM can be -reprogrammed again. The only exception would be if the new +Except for ATxmega and UPDI (AVR8X family) devices, all of which can use +page erase, it is basically a prerequisite command before the flash ROM +can be reprogrammed again. The only exception would be if the new contents would exclusively cause bits to be programmed from the value .Ql 1 to @@ -797,6 +795,7 @@ The available memory types are device-dependent, the actual configuration can be viewed with the .Cm part command in terminal mode. +.Pp Typically, a device's memory configuration at least contains the memories .Ar flash , @@ -812,10 +811,26 @@ memory contains the three device signature bytes, which should be, but not always are, unique for the part. The .Ar lock memory of one or four bytes typically details whether or not external -reading/writing of the flash memory, or parts of it, is allowed. Parts -will also typically have fuse bytes, which are read/write memories for -configuration of the device and calibration memories that typically -contain read-only factory calibration values. +reading/writing of the flash memory, or parts of it, is allowed. After +restricting access via the lock memory, often the only way to unlock +memory is via a chip erase. Parts will also typically have fuse bytes, +which are read/write memories for configuration of the device and +calibration memories that typically contain read-only factory calibration +values. +.Pp +The flash memory, being physically implemented as NOR-memory, is special +in the sense that it is normally only possible to program bits to change +from 1 to 0. Before reprogramming takes place normally flash memory has +to be erased. Older parts would only offer a chip erase to do so, which +also erases EEPROM unless a fuse configuration preserves its contents. If +AVRDUDE detects a -U option that writes to a flash memory it will +automatically trigger a chip erase for these older parts. ATxmegas or +UPDI parts (AVR8X family) offer a page erase, and AVRDUDE takes advantage +of that by erasing pages before programming them unless -e (chip erase) or +-D (do not erase before writing) was requested. It should be noted that in +absence of the -e chip erase option any ATxmega or UPDI flash pages not +affected by the programming will retain their previous content. + .Pp Classic devices may have the following memories in addition to eeprom, flash, signature and lock: .Bl -tag -width " calibration" -compact diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 2d1db42d..4645d5af 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -584,31 +584,28 @@ engaged by default when specifying -c arduino. @item -D @cindex Option @code{-D} -Disable auto erase for flash. When the -U option with flash memory is -specified, avrdude will perform a chip erase before starting any of the -programming operations, since it generally is a mistake to program the flash -without performing an erase first. This option disables that. -Auto erase is not used for ATxmega devices as these devices can -use page erase before writing each page so no explicit chip erase -is required. -Note however that any page not affected by the current operation -will retain its previous contents. -Setting -D implies -A. +Disable auto erase for flash. When the -U option for writing to any +flash memory is specified, AVRDUDE will perform a chip erase before +starting any of the programming operations, since it generally is a +mistake to program the flash without performing an erase first. This +option disables that. Auto erase is not used for ATxmega parts nor for the +UPDI (AVR8X family) parts as these can use page erase before writing each +page so no explicit chip erase is required. Note, however, that any flash +page not affected by the current operation will retain its previous +contents. Setting -D implies -A. @item -e @cindex Option @code{-e} Causes a chip erase to be executed. This will reset the contents of the -flash and EEPROM to the value `0xff', and clear all lock bits. -Except for ATxmega devices which can use page erase, -it is basically a -prerequisite command before the flash can be reprogrammed again. -The only exception would be if the new contents would exclusively cause -bits to be programmed from the value `1' to `0'. Note that in order -to reprogram EERPOM cells, no explicit prior chip erase is required -since the MCU provides an auto-erase cycle in that case before +flash and EEPROM to the value `0xff', and clear all lock bits. Except for +ATxmega and UPDI (AVR8X family) devices, all of which can use page erase, +it is basically a prerequisite command before the flash ROM can be +reprogrammed again. The only exception would be if the new contents would +exclusively cause bits to be programmed from the value `1' to `0'. Note +that in order to reprogram EERPOM cells, no explicit prior chip erase is +required since the MCU provides an auto-erase cycle in that case before programming the cell. - @item -E @var{exitspec}[,@dots{}] @cindex Option @code{-E} @var{exitspec}[,@dots{}] By default, AVRDUDE leaves the parallel port in the same state at exit @@ -860,9 +857,24 @@ is sometimes known as @code{lockbits}. The signature memory contains the three device signature bytes, which should be, but not always are, unique for the part. The @code{lock} memory of one or four bytes typically details whether or not external reading/writing of the flash memory, or -parts of it, is allowed. Parts will also typically have fuse bytes, which -are read/write memories for configuration of the device and calibration -memories that typically contain read-only factory calibration values. +parts of it, is allowed. After restricting access via the lock memory, +often the only way to unlock memory is via a chip erase. Parts will also +typically have fuse bytes, which are read/write memories for configuration +of the device and calibration memories that typically contain read-only +factory calibration values. + +The flash memory, being physically implemented as NOR-memory, is special +in the sense that it is normally only possible to program bits to change +from 1 to 0. Before reprogramming takes place normally flash memory has to +be erased. Older parts would only offer a chip erase to do so, which also +erases EEPROM unless a fuse configuration preserves its contents. If +AVRDUDE detects a -U option that writes to a flash memory it will +automatically trigger a chip erase for these older parts. ATxmegas or +UPDI parts (AVR8X family) offer a page erase, and AVRDUDE takes advantage +of that by erasing pages before programming them unless -e (chip erase) or +-D (do not erase before writing) was requested. It should be noted that in +absence of the -e chip erase option any ATxmega or UPDI flash pages not +affected by the programming will retain their previous content. Classic devices may have the following memories in addition to @code{eeprom}, @code{flash}, @code{signature} and @code{lock}: diff --git a/src/main.c b/src/main.c index 3e15575f..51b0cb46 100644 --- a/src/main.c +++ b/src/main.c @@ -1681,18 +1681,25 @@ skipopen: } if (uflags & UF_AUTO_ERASE) { - if ((p->prog_modes & PM_PDI) && pgm->page_erase && lsize(updates) > 0) { - pmsg_info("Note: programmer supports page erase for Xmega devices.\n"); - imsg_info("Each page will be erased before programming it, but no chip erase is performed.\n"); - imsg_info("To disable page erases, specify the -D option; for a chip-erase, use the -e option.\n"); + if((p->prog_modes & (PM_PDI | PM_UPDI)) && pgm->page_erase && lsize(updates) > 0) { + for(ln=lfirst(updates); ln; ln=lnext(ln)) { + upd = ldata(ln); + if(upd->memstr && upd->op == DEVICE_WRITE && memlist_contains_flash(upd->memstr, p)) { + cx->avr_disableffopt = 1; // Must write full flash file including trailing 0xff + pmsg_info("NOT erasing chip as page erase will be used for new flash%s contents\n", + avr_locate_bootrow(p)? "/bootrow": ""); + imsg_notice("unprogrammed flash contents remains: use -e for an explicit chip-erase\n"); + break; + } + } } else { uflags &= ~UF_AUTO_ERASE; for(ln=lfirst(updates); !erase && ln; ln=lnext(ln)) { upd = ldata(ln); if(upd->memstr && upd->op == DEVICE_WRITE && memlist_contains_flash(upd->memstr, p)) { erase = 1; - pmsg_info("Note: carrying out an erase cycle as flash memory needs programming (-U %s:w:...)\n", upd->memstr); - imsg_info("specify the -D option to disable this feature\n"); + pmsg_info("Performing a chip erase as flash memory needs programming (-U %s:w:...)\n", upd->memstr); + imsg_notice("specify the -D option to disable this feature\n"); } } } From d3ce83ce0e739c714ebfa30634f9a6302381041e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 7 Jul 2024 00:07:52 +0100 Subject: [PATCH 240/422] Provide dryrun_page_erase() for PDI/UPDI parts --- src/dryrun.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/dryrun.c b/src/dryrun.c index 7adce1dd..e5c3bbaf 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -146,6 +146,30 @@ static int dryrun_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned } +static int dryrun_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, + unsigned int addr) { + + pmsg_debug("%s(%s, 0x%04x)\n", __func__, m->desc, addr); + if(!dry.dp) + Return("no dryrun device?"); + + AVRMEM *dmem; + if(!(dmem = avr_locate_mem(dry.dp, m->desc))) + Return("cannot locate %s %s memory for paged write", dry.dp->desc, m->desc); + + if(!avr_has_paged_access(pgm, dmem) || addr >= (unsigned) dmem->size) + Return("%s does not support paged access", dmem->desc); + addr &= ~(dmem->page_size-1); + if(addr + dmem->page_size > (unsigned) dmem->size) + Return("%s page erase of %s reaches outside %s?", dmem->desc, + str_ccinterval(addr, addr + dmem->page_size-1), str_ccinterval(0, dmem->size-1)); + + memset(dmem->buf+addr, 0xff, dmem->page_size); + + return 0; +} + + static int dryrun_program_enable(const PROGRAMMER *pgm, const AVRPART *p_unused) { pmsg_debug("%s()\n", __func__); @@ -625,6 +649,10 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { if((m = avr_locate_flash(q)) && m->size >= 1024 && (pgm->prog_modes & PM_SPM)) dry.bl = (q->prog_modes & PM_UPDI)? DRY_BOTTOM: DRY_TOP; + // So that dryrun can emulate AVRDUDE page erase + if(!(pgm->prog_modes & PM_SPM) && (q->prog_modes & (PM_PDI | PM_UPDI))) + pgm->page_erase = dryrun_page_erase; + if(!dry.random && !dry.init) // OK, no further initialisation needed return; @@ -693,6 +721,7 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { putother(pgm, q, m, "The five boxing wizards jump quickly. "); if((m = avr_locate_bootrow(q))) putother(pgm, q, m, "Lorem ipsum dolor sit amet. "); + dry.initialised = 1; } From 0f74b7be853d42bb922e96d42f92f8dae8fce8eb Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 7 Jul 2024 00:08:57 +0100 Subject: [PATCH 241/422] Remove note on what CE might erase --- src/term.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/term.c b/src/term.c index de4b564e..d7057a50 100644 --- a/src/term.c +++ b/src/term.c @@ -964,16 +964,8 @@ static int cmd_erase(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch return cmd_write(pgm, p, 6, args); } - const char *note = ""; - if(!(pgm->prog_modes & PM_SPM) && avr_locate_eeprom(p)) { // Not a bootloader: is EEPROM saved? - int eesave, bakverb = verbose; - verbose = -123; // Silently read EESAVE configuration bit - if(avr_get_config_value(pgm, p, "eesave", &eesave) == 0) - note = eesave == !(p->prog_modes & PM_UPDI)? "(including EEPROM) ": "(but not EEPROM) "; - verbose = bakverb; - } - - term_out("erasing chip %s...\n", note); + term_out("%s chip erase ...\n", (pgm->prog_modes & PM_SPM)? + "asking bootloader to perform": "performing"); // Erase chip and clear cache int rc = pgm->chip_erase_cached(pgm, p); From fa618a8440f57fa06c4b04ea147df39d2ec1434f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 7 Jul 2024 12:15:19 +0100 Subject: [PATCH 242/422] Improve documentation for terminal erase --- src/avrdude.1 | 5 +++-- src/doc/avrdude.texi | 5 +++-- src/term.c | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index af2ca414..28e7b0d7 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -1264,8 +1264,9 @@ command line argument. .Ar verify flushes the cache before verifying memories. .It Ar erase -Perform a chip erase and discard all pending writes to EEPROM and flash. -Note that EEPROM will be preserved if the EESAVE fuse bit is set. +Perform a chip erase and discard all pending writes to flash, EEPROM and bootrow. +Note that EEPROM will be preserved if the EESAVE fuse bit is active, ie, had +a corresponding value at the last reset prior to the operation. .It Ar erase memory Erase the entire specified memory. .It Ar erase memory addr len diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index c084ad61..40746ba4 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -2509,8 +2509,9 @@ comma separated list of memories just as in the @code{-U} command line argument. @code{verify} flushes the cache before verifying memories. @item erase -Perform a chip erase and discard all pending writes to EEPROM and flash. -Note that EEPROM will be preserved if the EESAVE fuse bit is set. +Perform a chip erase and discard all pending writes to flash, EEPROM and bootrow. +Note that EEPROM will be preserved if the EESAVE fuse bit is active, ie, had +a corresponding value at the last reset prior to the operation. @item erase @var{memory} Erase the entire specified memory. diff --git a/src/term.c b/src/term.c index d7057a50..07ade813 100644 --- a/src/term.c +++ b/src/term.c @@ -964,8 +964,9 @@ static int cmd_erase(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch return cmd_write(pgm, p, 6, args); } - term_out("%s chip erase ...\n", (pgm->prog_modes & PM_SPM)? - "asking bootloader to perform": "performing"); + term_out("%s chip erase; discarded pending writes to flash%s\n", + (pgm->prog_modes & PM_SPM)? "asking bootloader to perform": "performing", + avr_locate_bootrow(p)? ", EEPROM and bootrow": avr_locate_eeprom(p)? "and EEPROM": ""); // Erase chip and clear cache int rc = pgm->chip_erase_cached(pgm, p); From d10986f12c9fc39aa450b6ed966a8fb5580f4a03 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 7 Jul 2024 14:43:47 +0100 Subject: [PATCH 243/422] Update News --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 828cf711..24be8646 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,7 @@ Changes since version 7.3: - ATtiny11 does not have EEPROM #1812 - AVRDUDE fails to return -1 on some write errors #1821 - Multi-memory files #1817 + - Terminal erase command #1833 * Pull requests: @@ -100,6 +101,8 @@ Changes since version 7.3: - Downgrade out-of-range file input errors on -F #1818 - Multi-memory file handling #1828 - Add developer options -p*/vcr to explore SW compatibility #1830 + - Improve chip erase emulation for dryboot/dryrun #1836 + - Use page erase for UPDI programming #1837 * Internals: From e7f7691367fc4a0d6edba8c686e1d5f56478711e Mon Sep 17 00:00:00 2001 From: Dawid Buchwald Date: Sun, 7 Jul 2024 17:21:12 +0200 Subject: [PATCH 244/422] Rolled back page erase feature as not needed anymore --- src/updi_nvm_v0.c | 4 ++-- src/updi_nvm_v2.c | 8 ++------ src/updi_nvm_v3.c | 4 ++-- src/updi_nvm_v4.c | 8 ++------ src/updi_nvm_v5.c | 4 ++-- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/updi_nvm_v0.c b/src/updi_nvm_v0.c index 7e048477..f3f1be64 100644 --- a/src/updi_nvm_v0.c +++ b/src/updi_nvm_v0.c @@ -284,9 +284,9 @@ int updi_nvm_write_user_row_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t int updi_nvm_write_boot_row_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* - Perform write operation as if it was regular flash memory, but ensure page erase/page write command + Perform write operation as if it was regular flash memory */ - return nvm_write_V0(pgm, p, address, buffer, size, USE_WORD_ACCESS, UPDI_V0_NVMCTRL_CTRLA_ERASE_WRITE_PAGE); + return nvm_write_V0(pgm, p, address, buffer, size, USE_WORD_ACCESS, USE_DEFAULT_COMMAND); } int updi_nvm_write_eeprom_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { diff --git a/src/updi_nvm_v2.c b/src/updi_nvm_v2.c index c6670916..ebf5382b 100644 --- a/src/updi_nvm_v2.c +++ b/src/updi_nvm_v2.c @@ -284,13 +284,9 @@ int updi_nvm_write_user_row_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t int updi_nvm_write_boot_row_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* - Perform write operation as if it was regular flash memory, but perform erase operation first + Perform write operation as if it was regular flash memory */ - if (updi_nvm_erase_flash_page_V2(pgm, p, address) <0) { - pmsg_error("Flash page erase failed for bootrow\n"); - return -1; - } - return updi_nvm_write_flash_V2(pgm, p, address, buffer, size); + return nvm_write_V2(pgm, p, address, buffer, size, USE_WORD_ACCESS); } int updi_nvm_write_eeprom_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { diff --git a/src/updi_nvm_v3.c b/src/updi_nvm_v3.c index 99989ddd..73c62bc3 100644 --- a/src/updi_nvm_v3.c +++ b/src/updi_nvm_v3.c @@ -299,9 +299,9 @@ int updi_nvm_write_user_row_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t int updi_nvm_write_boot_row_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* - Perform the operation as the regular flash write, but with page erase/page write command + Perform the operation as the regular flash write */ - return nvm_write_V3(pgm, p, address, buffer, size, USE_WORD_ACCESS, UPDI_V3_NVMCTRL_CTRLA_FLASH_PAGE_ERASE_WRITE); + return nvm_write_V3(pgm, p, address, buffer, size, USE_WORD_ACCESS, USE_DEFAULT_COMMAND); } int updi_nvm_write_eeprom_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { diff --git a/src/updi_nvm_v4.c b/src/updi_nvm_v4.c index 5d3b0cd6..0773983a 100644 --- a/src/updi_nvm_v4.c +++ b/src/updi_nvm_v4.c @@ -285,13 +285,9 @@ int updi_nvm_write_user_row_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t int updi_nvm_write_boot_row_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* - Write it as a regular flash page, but perform page erase first + Write it as a regular flash page */ - if (updi_nvm_erase_flash_page_V4(pgm, p, address) <0) { - pmsg_error("Flash page erase failed for bootrow\n"); - return -1; - } - return updi_nvm_write_flash_V4(pgm, p, address, buffer, size); + return nvm_write_V4(pgm, p, address, buffer, size, USE_WORD_ACCESS); } int updi_nvm_write_eeprom_V4(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { diff --git a/src/updi_nvm_v5.c b/src/updi_nvm_v5.c index bc11708e..a337678c 100644 --- a/src/updi_nvm_v5.c +++ b/src/updi_nvm_v5.c @@ -300,9 +300,9 @@ int updi_nvm_write_user_row_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t int updi_nvm_write_boot_row_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { /* - Perform the operation as the regular flash write, but with page erase/page write command + Perform the operation as the regular flash write */ - return nvm_write_V5(pgm, p, address, buffer, size, USE_WORD_ACCESS, UPDI_V5_NVMCTRL_CTRLA_FLASH_PAGE_ERASE_WRITE); + return nvm_write_V5(pgm, p, address, buffer, size, USE_WORD_ACCESS, USE_DEFAULT_COMMAND); } int updi_nvm_write_eeprom_V5(const PROGRAMMER *pgm, const AVRPART *p, uint32_t address, unsigned char *buffer, uint16_t size) { From f489dac5f7548cd4b8deadb5e5de34ba628304aa Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 10 Jul 2024 19:38:10 +0100 Subject: [PATCH 245/422] Fix typo --- src/usb_hidapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usb_hidapi.c b/src/usb_hidapi.c index 70a75cfc..59c6dee4 100644 --- a/src/usb_hidapi.c +++ b/src/usb_hidapi.c @@ -149,7 +149,7 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor * provide us with an API function for that, nor for the report * descriptor (which also contains that information). * - * Since the Atmel tools a very picky to only respond to incoming + * Since the Atmel tools are very picky to only respond to incoming * packets that have full size, we need to know whether our device * handles 512-byte data (JTAGICE3 in CMSIS-DAP mode, or AtmelICE, * both on USB 2.0 connections), or 64-byte data only (both these on From 6979fce1ee161fe7b5e20a7f49e075f2b4f010a5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 17:52:54 +0100 Subject: [PATCH 246/422] Fix sernum entries for classic parts --- src/avrdude.conf.in | 6 ++++-- src/config_gram.y | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 4b4135e1..f874d40b 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -6237,6 +6237,7 @@ part parent "m324p" # m324pb memory "sernum" size = 10; offset = 0xe; # Sub-region of prodsig + read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; ; ; @@ -11045,6 +11046,7 @@ part parent "m328" # m328pb memory "sernum" size = 10; offset = 0xe; # Sub-region of prodsig + read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; ; ; @@ -20451,7 +20453,7 @@ part parent ".reduced_core_tiny" # t102 memory "sernum" size = 10; - offset = 0x6; # Sub-region of prodsig + offset = 0x3fc6; # Sub-region of prodsig ; memory "io" @@ -20499,7 +20501,7 @@ part parent ".reduced_core_tiny" # t104 memory "sernum" size = 10; - offset = 0x6; # Sub-region of prodsig + offset = 0x3fc6; # Sub-region of prodsig ; memory "io" diff --git a/src/config_gram.y b/src/config_gram.y index 11e57316..62f0e673 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -374,7 +374,7 @@ part_def : m->type &= and_mask; // Remove MEM_IN_SIGROW attribute from classic calibration and classic/XMEGA signature mem - if(!(current_part->prog_modes & (PM_PDI|PM_UPDI))) { + if(current_part->prog_modes & PM_Classic) { if(mem_is_signature(m)) m->type &= ~MEM_IN_SIGROW; if(mem_is_calibration(m)) @@ -1396,11 +1396,11 @@ static int parse_cmdbits(OPCODE * op, int opnum) case 'a': sb = opnum == AVR_OP_LOAD_EXT_ADDR? bitno+8: bitno-8; // should be this number if(bitno < 8 || bitno > 23) { - if(!current_mem || !mem_is_sigrow(current_mem)) // Known exemption + if(!current_mem || !mem_is_in_sigrow(current_mem)) // Known exemptions yywarning("address bits don't normally appear in Bytes 0 or 3 of SPI commands"); } else if((bn & 31) != sb) { if(!current_part || !str_casestarts(current_part->desc, "AT89S5")) // Exempt AT89S5x - if(!current_mem || !mem_is_sigrow(current_mem)) // and prodsig + if(!current_mem || !mem_is_in_sigrow(current_mem)) // ... and prodsig/sernum yywarning("a%d would normally be expected to be a%d", bn, sb); } else if(bn < 0 || bn > 31) yywarning("invalid address bit a%d, using a%d", bn, bn & 31); From 8d1ea3829769ac243b6e25aeda1aa20e56faea6c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 18:25:21 +0100 Subject: [PATCH 247/422] Fix plural in message --- src/term.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index 07ade813..937c8ac2 100644 --- a/src/term.c +++ b/src/term.c @@ -2009,7 +2009,8 @@ static int cmd_part(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha else if(onlyvariants) avr_variants_display(stdout, p, ""); else { - term_out("%s with programming modes %s\n", p->desc, str_prog_modes(p->prog_modes)); + char *q = str_prog_modes(p->prog_modes); + term_out("%s with programming mode%s %s\n", p->desc, strchr(q, ',')? "s": "", q); avr_mem_display(stdout, p, ""); avr_variants_display(stdout, p, ""); } From be63435aa24cb143b09dda294e8fffa7be1cec78 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 18:37:28 +0100 Subject: [PATCH 248/422] Copy sernum into prodsig for classic parts in dryrun.c --- src/dryrun.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index 30a33dac..d680a728 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -603,10 +603,11 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { } else if(mem_is_sigrow(m) && m->size >= 6) { prodsigm = m; memset(m->buf, 0xff, m->size); - // Classic parts: signature at even addresses @@@ but not t102/t104 + // Classic parts: signature at even addresses + int n = q->prog_modes & PM_TPI? 1: 2; // ... unless it's the TPI parts t102/t104 if(q->prog_modes & PM_Classic) for(int i=0; i<3; i++) - m->buf[2*i] = q->signature[i]; + m->buf[n*i] = q->signature[i]; } else if(mem_is_io(m)) { // Initialise reset values (if known) int nr; const Register_file *rf = avr_locate_register_file(q, &nr); @@ -632,10 +633,18 @@ static void dryrun_enable(PROGRAMMER *pgm, const AVRPART *p) { } } if((q->prog_modes & PM_Classic) && (calm = avr_locate_calibration(q))) { - // Calibration bytes of classic parts are interspersed with signature @@@ but not t102/104 - for(int i=0; isize; i++) - if(2*i+1 < prodsigm->size) - prodsigm->buf[2*i+1] = 'U'; + // Calibration bytes of classic parts are interspersed with signature + int n, tpi = !!(q->prog_modes & PM_TPI); // ... unless it's the TPI parts t102/t104 + for(int i=0; isize; i++) { + if((n = tpi? 3+i: 2*i+1) < prodsigm->size) + prodsigm->buf[n] = 'U'; + } + } + if((q->prog_modes & PM_Classic) && (m = avr_locate_sernum(q))) { // m324pb/m328pb, t102/t104 + int off = m->offset - prodsigm->offset; + int cpy = m->size; + if(off >= 0 && off+cpy <= prodsigm->size) + memcpy(prodsigm->buf + off, m->buf, cpy); } } if(fusesm) { From 8a4c00fc21a923266a53ebdfd6ce6cf800b828ce Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 18:41:37 +0100 Subject: [PATCH 249/422] Add ability to read classic sernum mem to avr_read_byte_default() --- src/avr.c | 18 +++++++++++++++++- src/libavrdude.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/avr.c b/src/avr.c index 51be9006..fe48def3 100644 --- a/src/avr.c +++ b/src/avr.c @@ -181,6 +181,22 @@ static int avr_tpi_setup_rw(const PROGRAMMER *pgm, const AVRMEM *mem, return 0; } +// If mem is a sub-memory of sigrow return its offset within sigrow, 0 otherwise +int avr_sigrow_offset(const AVRPART *p, const AVRMEM *mem, int addr) { + int offset = 0; + + if(mem_is_in_sigrow(mem)) { + AVRMEM *m = avr_locate_sigrow(p); + if(m) { + int off = mem->offset - m->offset; + if(off >= 0 && off + addr < m->size) + offset = off; + } + } + + return offset; +} + int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char * value) { @@ -258,7 +274,7 @@ int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM memset(cmd, 0, sizeof(cmd)); avr_set_bits(readop, cmd); - avr_set_addr(readop, cmd, addr); + avr_set_addr(readop, cmd, addr + avr_sigrow_offset(p, mem, addr)); rc = pgm->cmd(pgm, cmd, res); if(rc < 0) goto rcerror; diff --git a/src/libavrdude.h b/src/libavrdude.h index baa24b1c..d1b4af40 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1102,6 +1102,7 @@ extern "C" { int avr_tpi_poll_nvmbsy(const PROGRAMMER *pgm); int avr_tpi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p); int avr_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p, unsigned char guard_time); +int avr_sigrow_offset(const AVRPART *p, const AVRMEM *mem, int addr); int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char * value); From 45d1bea57584987f9b979185dc30a47af637b718 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 18:53:00 +0100 Subject: [PATCH 250/422] Enable classic sernum read for ISP/HVPP/HVSP/JTAG in stk500v2.c --- src/stk500v2.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/stk500v2.c b/src/stk500v2.c index e69ad7e6..35054740 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -2308,11 +2308,11 @@ static int stk500hv_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR buf[0] = mode == PPMODE? CMD_READ_OSCCAL_PP: CMD_READ_OSCCAL_HVSP; } else if (mem_is_signature(mem)) { buf[0] = mode == PPMODE? CMD_READ_SIGNATURE_PP: CMD_READ_SIGNATURE_HVSP; - } else if (mem_is_sigrow(mem)) { + } else if (mem_is_in_sigrow(mem)) { buf[0] = addr&1? (mode == PPMODE? CMD_READ_OSCCAL_PP: CMD_READ_OSCCAL_HVSP): (mode == PPMODE? CMD_READ_SIGNATURE_PP: CMD_READ_SIGNATURE_HVSP); - addr /= 2; + addr = (addr + avr_sigrow_offset(p, mem, addr))/2; } else { pmsg_error("unsupported memory %s\n", mem->desc); return -1; @@ -2391,7 +2391,7 @@ static int stk500hvsp_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const A static int stk500isp_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char * value) { - int result, pollidx; + int result, pollidx, offset = 0; unsigned char buf[6]; unsigned long paddr = 0UL, *paddr_ptr = NULL; unsigned int pagesize = 0; @@ -2441,8 +2441,9 @@ static int stk500isp_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AV buf[0] = CMD_READ_OSCCAL_ISP; } else if (mem_is_signature(mem)) { buf[0] = CMD_READ_SIGNATURE_ISP; - } else if (mem_is_sigrow(mem)) { + } else if (mem_is_in_sigrow(mem)) { // Sernum and prodsig/sigrow (m324pb/m328pb) buf[0] = addr&1? CMD_READ_OSCCAL_ISP: CMD_READ_SIGNATURE_ISP; + offset = avr_sigrow_offset(p, mem, addr); } else { pmsg_error("unsupported memory %s\n", mem->desc); return -1; @@ -2459,7 +2460,7 @@ static int stk500isp_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AV pollidx = 3; } buf[1] = pollidx + 1; - avr_set_addr(op, buf + 2, addr); + avr_set_addr(op, buf + 2, addr + offset); pmsg_notice2("stk500isp_read_byte(): sending read memory command: "); @@ -4570,7 +4571,7 @@ static int stk600_xprog_paged_load(const PROGRAMMER *pgm, const AVRPART *p, cons mtype = XPRG_MEM_TYPE_FUSE; } else if (mem_is_lock(mem)) { mtype = XPRG_MEM_TYPE_LOCKBITS; - } else if (mem_is_calibration(mem) || mem_is_sigrow(mem)) { + } else if (mem_is_calibration(mem) || mem_is_in_sigrow(mem)) { mtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION; } else if (mem_is_userrow(mem)) { mtype = XPRG_MEM_TYPE_USERSIG; From 1ce9154664276d95454d000f98fe506bcf85a6a1 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 19:04:19 +0100 Subject: [PATCH 251/422] Review sigrow sub-memory treatment in jtag*.c --- src/jtag3.c | 4 ++-- src/jtagmkI.c | 3 ++- src/jtagmkII.c | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/jtag3.c b/src/jtag3.c index b3935d6e..c2976ae0 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -2165,7 +2165,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM if (pgm->flag & PGM_FL_IS_DW) unsupp = 1; } - } else if (!(p->prog_modes & (PM_PDI | PM_UPDI)) && mem_is_calibration(mem)) { // Classic part calibration + } else if ((p->prog_modes & PM_Classic) && mem_is_calibration(mem)) { // Classic part calibration cmd[3] = MTYPE_OSCCAL_BYTE; if (pgm->flag & PGM_FL_IS_DW) unsupp = 1; @@ -2815,7 +2815,7 @@ static unsigned char tpi_get_mtype(const AVRMEM *m) { mem_is_lock(m)? XPRG_MEM_TYPE_LOCKBITS: mem_is_calibration(m)? XPRG_MEM_TYPE_LOCKBITS: // Sic, uses offset to distingish memories mem_is_signature(m)? XPRG_MEM_TYPE_LOCKBITS: - mem_is_sigrow(m)? XPRG_MEM_TYPE_LOCKBITS: + mem_is_in_sigrow(m)? XPRG_MEM_TYPE_LOCKBITS: XPRG_MEM_TYPE_APPL; // Sic, TPI parts do not have eeprom } diff --git a/src/jtagmkI.c b/src/jtagmkI.c index 9f546cf8..23923bf5 100644 --- a/src/jtagmkI.c +++ b/src/jtagmkI.c @@ -852,7 +852,8 @@ static int jtagmkI_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRM cmd[1] = MTYPE_OSCCAL_BYTE; } else if (mem_is_signature(mem)) { cmd[1] = MTYPE_SIGN_JTAG; - } else if (mem_is_sigrow(mem)) { + } else if (mem_is_in_sigrow(mem)) { + addr += avr_sigrow_offset(p, mem, addr); cmd[1] = addr&1? MTYPE_OSCCAL_BYTE: MTYPE_SIGN_JTAG; addr /= 2; } else { diff --git a/src/jtagmkII.c b/src/jtagmkII.c index 12c4b53b..4cf13f46 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -892,7 +892,7 @@ static void jtagmkII_set_devdescr(const PROGRAMMER *pgm, const AVRPART *p) { } } sendbuf.dd.ucCacheType = - p->prog_modes & (PM_PDI | PM_UPDI)? 0x02 /* ATxmega */: 0x00; + p->prog_modes & (PM_PDI | PM_UPDI)? 0x02: 0x00; pmsg_notice2("jtagmkII_set_devdescr(): " "Sending set device descriptor command: "); @@ -2193,6 +2193,9 @@ static int jtagmkII_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR } else if ((p->prog_modes & (PM_PDI | PM_UPDI)) && mem_is_in_sigrow(mem)) { cmd[1] = MTYPE_PRODSIG; pmsg_notice2("in_sigrow addr 0x%05lx\n", addr); + } else if (mem_is_in_sigrow(mem)) { // Classic part + cmd[1] = addr&1? MTYPE_OSCCAL_BYTE: MTYPE_SIGN_JTAG; + addr /= 2; } else if (mem_is_io(mem) || mem_is_sram(mem)) { cmd[1] = MTYPE_FLASH; addr += avr_data_offset(p); From b23370a8c105e50f9fddc36a37e65b36e5666b59 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 19:05:42 +0100 Subject: [PATCH 252/422] Enable sigrow sub-memory reading for avrftdi_jtag --- src/avrftdi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index e3435300..1a00bf12 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -1501,7 +1501,8 @@ static int avrftdi_jtag_read_byte(const PROGRAMMER *pgm, const AVRPART *p, avrftdi_jtag_dr_out(pgm, 0x3600, 15); *value = avrftdi_jtag_dr_inout(pgm, 0x3700, 15) & 0xff; - } else if (mem_is_sigrow(m)) { + } else if (mem_is_in_sigrow(m)) { + addr += avr_sigrow_offset(p, m, addr); avrftdi_jtag_ir_out(pgm, JTAG_IR_PROG_COMMANDS); avrftdi_jtag_dr_out(pgm, 0x2300 | JTAG_DR_PROG_SIGCAL_READ, 15); avrftdi_jtag_dr_out(pgm, 0x0300 | (addr/2 & 0xff), 15); From 6f92e188fd25e4baab7a4ce82fc7aadf25fd94a9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 19:06:23 +0100 Subject: [PATCH 253/422] Enable sigrow sub-memory reading for butterfly --- src/butterfly.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/butterfly.c b/src/butterfly.c index a645e540..1337faec 100644 --- a/src/butterfly.c +++ b/src/butterfly.c @@ -491,7 +491,9 @@ static int butterfly_read_byte_flash(const PROGRAMMER *pgm, const AVRPART *p, co unsigned long addr, unsigned char * value) { int ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; - char mtype = mem_is_flash(m)? 'F': mem_is_sigrow(m)? 'P': mem_is_userrow(m)? 'U': '?'; + char mtype = mem_is_flash(m)? 'F': mem_is_in_sigrow(m)? 'P': mem_is_userrow(m)? 'U': '?'; + + addr += avr_sigrow_offset(p, m, addr); if(mtype == '?') { pmsg_error("cannot read memory %s\n", m->desc); @@ -533,7 +535,7 @@ static int butterfly_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AV { char cmd; - if (mem_is_flash(m) || mem_is_sigrow(m) || mem_is_userrow(m)) { + if (mem_is_flash(m) || mem_is_in_sigrow(m) || mem_is_userrow(m)) { return butterfly_read_byte_flash(pgm, p, m, addr, value); } From 6ca23bd3c7818ac4bf2fa2fffc51ed81157de9ca Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 12 Jul 2024 19:52:13 +0100 Subject: [PATCH 254/422] Utilise PM_Classic in code --- src/jtag3.c | 4 ++-- src/jtagmkII.c | 12 ++++++------ src/stk500.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/jtag3.c b/src/jtag3.c index c2976ae0..854ccc70 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -1450,7 +1450,7 @@ static void jtag3_disable(const PROGRAMMER *pgm) { static void jtag3_enable(PROGRAMMER *pgm, const AVRPART *p) { // Page erase only useful for classic parts with usersig mem or AVR8X/XMEGAs - if(!(p->prog_modes & (PM_PDI | PM_UPDI))) + if(p->prog_modes & PM_Classic) if(!avr_locate_usersig(p)) pgm->page_erase = NULL; } @@ -1865,7 +1865,7 @@ static int jtag3_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AVRME pmsg_notice2("jtag3_page_erase(.., %s, 0x%x)\n", m->desc, addr); - if(!(p->prog_modes & (PM_PDI | PM_UPDI)) && !mem_is_userrow(m)) { + if((p->prog_modes & PM_Classic) && !mem_is_userrow(m)) { pmsg_error("page erase only available for AVR8X/XMEGAs or classic-part usersig mem\n"); return -1; } diff --git a/src/jtagmkII.c b/src/jtagmkII.c index 4cf13f46..be97b147 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -832,7 +832,7 @@ static int jtagmkII_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { return -1; } - if (!(p->prog_modes & (PM_PDI | PM_UPDI))) + if (p->prog_modes & PM_Classic) pgm->initialize(pgm, p); PDATA(pgm)->recently_written = 1; @@ -1292,7 +1292,7 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) { return -1; } - if ((pgm->flag & PGM_FL_IS_JTAG) && !(p->prog_modes & (PM_PDI | PM_UPDI))) { + if ((pgm->flag & PGM_FL_IS_JTAG) && (p->prog_modes & PM_Classic)) { int ocden = 0; if(avr_get_config_value(pgm, p, "ocden", &ocden) == 0 && ocden) // ocden == 1 means disabled pmsg_warning("OCDEN fuse not programmed, single-byte EEPROM updates not possible\n"); @@ -1323,7 +1323,7 @@ static void jtagmkII_disable(const PROGRAMMER *pgm) { static void jtagmkII_enable(PROGRAMMER *pgm, const AVRPART *p) { // Page erase only useful for classic parts with usersig mem or AVR8X/XMEGAs - if(!(p->prog_modes & (PM_PDI | PM_UPDI))) + if(p->prog_modes & PM_Classic) if(!avr_locate_usersig(p)) pgm->page_erase = NULL; @@ -1796,7 +1796,7 @@ static int jtagmkII_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AV pmsg_notice2("jtagmkII_page_erase(.., %s, 0x%x)\n", m->desc, addr); - if (!(p->prog_modes & (PM_PDI | PM_UPDI)) && !mem_is_userrow(m)) { + if ((p->prog_modes & PM_Classic) && !mem_is_userrow(m)) { pmsg_error("page erase only available for AVR8X/XMEGAs or classic-part usersig mem\n"); return -1; } @@ -2139,7 +2139,7 @@ static int jtagmkII_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR } } else if(mem_is_a_fuse(mem) || mem_is_fuses(mem)) { cmd[1] = MTYPE_FUSE_BITS; - if(!(p->prog_modes & (PM_PDI | PM_UPDI)) && mem_is_a_fuse(mem)) + if((p->prog_modes & PM_Classic) && mem_is_a_fuse(mem)) addr = mem_fuse_offset(mem); if (pgm->flag & PGM_FL_IS_DW) unsupp = 1; @@ -2311,7 +2311,7 @@ static int jtagmkII_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AV PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; } else if (mem_is_a_fuse(mem) || mem_is_fuses(mem)) { cmd[1] = MTYPE_FUSE_BITS; - if(!(p->prog_modes & (PM_PDI | PM_UPDI)) && mem_is_a_fuse(mem)) + if((p->prog_modes & PM_Classic) && mem_is_a_fuse(mem)) addr = mem_fuse_offset(mem); if (pgm->flag & PGM_FL_IS_DW) unsupp = 1; diff --git a/src/stk500.c b/src/stk500.c index fa4dcb38..d3a4b0b6 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -1006,9 +1006,9 @@ static int set_memchr_a_div(const PROGRAMMER *pgm, const AVRPART *p, const AVRME if(mem_is_eeprom(m)) { *memchrp = 'E'; - // Word addr for bootloaders or Arduino as ISP if part is a "classic" part, byte addr otherwise + // Word addr for bootloaders or Arduino as ISP if part is a classic part; byte addr otherwise *a_divp = ((pgm->prog_modes & PM_SPM) || str_caseeq(pgmid, "arduino_as_isp")) \ - && !(p->prog_modes & (PM_UPDI | PM_PDI))? 2: 1; + && (p->prog_modes & PM_Classic)? 2: 1; return 0; } From 71029c515a14128b64f7e7983bb3ade8164914b5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 13 Jul 2024 14:30:22 +0100 Subject: [PATCH 255/422] Fix write delays for some classic parts Compared the T WD_FUSE etc values in the data sheets for m169, m169a, m169p, m169pa, m3290a, m3290p, m3290pa, m329a, m329p, m329pa, m6490a, m6490p, m649a, m649p and m8535. --- src/avrdude.conf.in | 85 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 14 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index f874d40b..623462ed 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -7098,8 +7098,8 @@ part # m169 memory "lfuse" size = 1; initval = 0x62; - min_write_delay = 2000; - max_write_delay = 2000; + min_write_delay = 4500; + max_write_delay = 4500; read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; ; @@ -7107,8 +7107,8 @@ part # m169 memory "hfuse" size = 1; initval = 0x99; - min_write_delay = 2000; - max_write_delay = 2000; + min_write_delay = 4500; + max_write_delay = 4500; read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; ; @@ -7117,8 +7117,8 @@ part # m169 size = 1; initval = 0xff; bitmask = 0x0f; - min_write_delay = 2000; - max_write_delay = 2000; + min_write_delay = 4500; + max_write_delay = 4500; read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; ; @@ -7127,8 +7127,8 @@ part # m169 size = 1; initval = 0xff; bitmask = 0x3f; - min_write_delay = 2000; - max_write_delay = 2000; + min_write_delay = 4500; + max_write_delay = 4500; read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; ; @@ -7174,6 +7174,8 @@ part parent "m169" # m169a resetdelay = 15; memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; readback = 0x00 0x00; ; @@ -7221,6 +7223,8 @@ part parent "m169" # m169p resetdelay = 15; memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; readback = 0x00 0x00; ; @@ -7263,6 +7267,8 @@ part parent "m169" # m169pa resetdelay = 15; memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; readback = 0x00 0x00; ; @@ -7442,6 +7448,11 @@ part parent "m329" # m329a "ATmega329A-MN: QFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATmega329A-MU: VQFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 122; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7468,6 +7479,11 @@ part parent "m329" # m329p "ATmega329PV-10MUR: VQFN64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 123; signature = 0x1e 0x95 0x0b; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7486,6 +7502,11 @@ part parent "m329" # m329pa "ATmega329PA-MUR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 124; signature = 0x1e 0x95 0x0b; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7520,6 +7541,11 @@ part parent "m329" # m3290a mcuid = 151; n_interrupts = 25; signature = 0x1e 0x95 0x04; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7538,6 +7564,11 @@ part parent "m329" # m3290p mcuid = 152; n_interrupts = 25; signature = 0x1e 0x95 0x0c; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7554,6 +7585,11 @@ part parent "m329" # m3290pa mcuid = 153; n_interrupts = 25; signature = 0x1e 0x95 0x0c; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7723,6 +7759,11 @@ part parent "m649" # m649a "ATmega649A-MU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega649A-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; mcuid = 136; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7739,6 +7780,11 @@ part parent "m649" # m649p "ATmega649P-MUR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 137; signature = 0x1e 0x96 0x0b; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7773,6 +7819,11 @@ part parent "m649" # m6490a mcuid = 158; n_interrupts = 25; signature = 0x1e 0x96 0x04; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -7789,6 +7840,11 @@ part parent "m649" # m6490p mcuid = 159; n_interrupts = 25; signature = 0x1e 0x96 0x0c; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; ; #------------------------------------------------------------ @@ -8470,8 +8526,8 @@ part # m8535 memory "lfuse" size = 1; initval = 0xe1; - min_write_delay = 2000; - max_write_delay = 2000; + min_write_delay = 4500; + max_write_delay = 4500; read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; ; @@ -8479,8 +8535,8 @@ part # m8535 memory "hfuse" size = 1; initval = 0xd9; - min_write_delay = 2000; - max_write_delay = 2000; + min_write_delay = 4500; + max_write_delay = 4500; read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; ; @@ -8489,8 +8545,8 @@ part # m8535 size = 1; initval = 0xff; bitmask = 0x3f; - min_write_delay = 2000; - max_write_delay = 2000; + min_write_delay = 4500; + max_write_delay = 4500; read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; ; @@ -14699,6 +14755,7 @@ part parent "t44" # t44a "ATtiny44A-SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = XVII + IV; # 21; + ; #------------------------------------------------------------ From 8f7160799af658215b3ba976ba5c130652f21e1e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 13 Jul 2024 20:17:01 +0100 Subject: [PATCH 256/422] Correct comments --- src/avrpart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index 38f38a97..f27ae6f0 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -1150,7 +1150,7 @@ void walk_avrparts(LISTID avrparts, walk_avrparts_cb cb, void *cookie) } /* - * Compare function to sort the list of programmers + * Compare function to sort a list of parts */ static int sort_avrparts_compare(const AVRPART *p1, const AVRPART *p2) { if(p1 == NULL || p1->desc == NULL || p2 == NULL || p2->desc == NULL) @@ -1160,7 +1160,7 @@ static int sort_avrparts_compare(const AVRPART *p1, const AVRPART *p2) { } /* - * Sort the list of programmers given as "programmers" + * Sort the list avrparts of parts */ void sort_avrparts(LISTID avrparts) { From 90a4a54fd3e32e7e5ade5eefa0bffadcf29fc41a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 00:41:14 +0100 Subject: [PATCH 257/422] Map x-bits to 0 for SPI opcode comparison --- src/developer_opts.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/developer_opts.c b/src/developer_opts.c index 63bec49d..c47b797a 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -372,8 +372,15 @@ static int avrmem_deep_copy(AVRMEMdeep *d, const AVRMEM *m) { // Copy over the SPI operations themselves memset(d->ops, 0, sizeof d->ops); for(size_t i=0; iop[i]) + if(m->op[i]) { d->ops[i] = *m->op[i]; + for(int b=0; b<32; b++) { // Replace x with 0 as they are treated the same + if(d->ops[i].bit[b].type == AVR_CMDBIT_IGNORE) { + d->ops[i].bit[b].type = AVR_CMDBIT_VALUE; + d->ops[i].bit[b].value = 0; + } + } + } return 0; } From 7fbd963ea4efe2ca9cc4c6e67081f3537ce5e034 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 00:43:59 +0100 Subject: [PATCH 258/422] Rearrange classic parts and parenting in avrdude.conf Although, on the surface of it, every entry of a classic part has been changed, and some radically so by different parenting, there are only subtle changes in AVRDUDE's internal representation: - 15 parts that did not have an io memory entry now have one - Some ISP opcodes were replaced with equivalent ones (x maps to 0) This has been checked using the development options, particularly -p*/At, before and after the changes. The benefit of the new avrdude.conf is that every (non-TPI) classic part is now derived from a common .classic or .classic-nocal stub. This enables putting a common prodsig and sernum memory there. Generally, parenting off now only happens between related chips. All in all, more systematic. And it's some 10% smaller, too. --- src/avrdude.conf.in | 21302 +++++++++++++++++++----------------------- 1 file changed, 9377 insertions(+), 11925 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 623462ed..46531cc8 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -3422,13 +3422,381 @@ serialadapter # pl2303 # PART DEFINITIONS # +#------------------------------------------------------------ +# Common values for reduced core tinys (4/5/9/10/20/40) +#------------------------------------------------------------ + +part # .reduced_core_tiny + desc = "Common values for reduced core tinys"; + id = ".reduced_core_tiny"; + prog_modes = PM_TPI; + + memory "fuse" + size = 1; + page_size = 16; + initval = 0xff; + bitmask = 0x07; + offset = 0x3f40; + blocksize = 4; + ; + + memory "lockbits" + size = 1; + page_size = 16; + initval = 0xff; + bitmask = 0x03; + offset = 0x3f00; + ; + + memory "signature" + size = 3; + page_size = 16; + offset = 0x3fc0; + ; + + memory "calibration" + size = 1; + page_size = 16; + offset = 0x3f80; + ; + + memory "sram" + size = 32; + offset = 0x40; + ; +; + +#------------------------------------------------------------ +# ATtiny4 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" # t4 + desc = "ATtiny4"; + id = "t4"; + variants = + "ATtiny4-MAHR: UDFN8, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny4-TS8R: SOT23-6, Fmax=10 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny4-TSHR: SOT23-6, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 0; + n_interrupts = 10; + signature = 0x1e 0x8f 0x0a; + factory_fcpu = 1000000; + + memory "flash" + size = 512; + page_size = 16; + offset = 0x4000; + blocksize = 128; + ; + + memory "io" + size = 64; + ; +; + +#------------------------------------------------------------ +# ATtiny5 +#------------------------------------------------------------ + +part parent "t4" # t5 + desc = "ATtiny5"; + id = "t5"; + variants = + "ATtiny5-MAHR: USON8, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny5-TS8R: SOT23-6, Fmax=10 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny5-TSHR: SOT23-6, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 1; + n_interrupts = 11; + signature = 0x1e 0x8f 0x09; +; + +#------------------------------------------------------------ +# ATtiny9 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" # t9 + desc = "ATtiny9"; + id = "t9"; + variants = + "ATtiny9-MAHR: DFN8, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny9-TS8R: SOT23-6, Fmax=10 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny9-TSHR: SOT23-6, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 2; + n_interrupts = 10; + signature = 0x1e 0x90 0x08; + factory_fcpu = 1000000; + + memory "flash" + size = 1024; + page_size = 16; + offset = 0x4000; + blocksize = 128; + ; + + memory "io" + size = 64; + ; +; + +#------------------------------------------------------------ +# ATtiny10 +#------------------------------------------------------------ + +part parent "t9" # t10 + desc = "ATtiny10"; + id = "t10"; + variants = + "ATtiny10-MAHR: UDFN8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny10-TS8R: SOT23-6, Fmax=10 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny10-TSHR: SOT23-6, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 3; + n_interrupts = 11; + signature = 0x1e 0x90 0x03; +; + +#------------------------------------------------------------ +# ATtiny20 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" # t20 + desc = "ATtiny20"; + id = "t20"; + variants = + "ATtiny20-CCU: UFBGA15, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny20-CCUR: UFBGA15, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny20-MMH: VQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny20-MMHR: VQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny20-SSU: SOIC14, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny20-SSUR: SOIC14, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny20-UUR: WLCSP12, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny20-XU: TSSOP14, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny20-XUR: TSSOP14, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 4; + n_interrupts = 17; + signature = 0x1e 0x91 0x0f; + factory_fcpu = 1000000; + + memory "flash" + size = 2048; + page_size = 16; + n_word_writes = 2; + offset = 0x4000; + blocksize = 128; + ; + + memory "fuse" + bitmask = 0x77; + n_word_writes = 2; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny40 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" # t40 + desc = "ATtiny40"; + id = "t40"; + variants = + "ATtiny40-MMH: VQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny40-MMHR: VQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny40-SU: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny40-SUR: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny40-XU: TSSOP20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny40-XUR: TSSOP20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 5; + n_interrupts = 18; + signature = 0x1e 0x92 0x0e; + factory_fcpu = 1000000; + + memory "flash" + size = 4096; + page_size = 64; + n_word_writes = 4; + offset = 0x4000; + blocksize = 128; + ; + + memory "fuse" + bitmask = 0x77; + n_word_writes = 4; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 256; + ; +; + +#------------------------------------------------------------ +# ATtiny102 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" # t102 + desc = "ATtiny102"; + id = "t102"; + variants = + "ATtiny102-M7R: UDFN8, Fmax=12 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny102-M8R: UDFN8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny102-SSFR: SOIC8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny102-SSNR: SOIC8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny102F-M7R: UDFN8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny102F-M8R: UDFN8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny102F-SSFR: SOIC8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny102F-SSNR: SOIC8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 6; + n_interrupts = 16; + signature = 0x1e 0x90 0x0c; + factory_fcpu = 1000000; + + memory "flash" + size = 1024; + page_size = 16; + offset = 0x4000; + blocksize = 128; + ; + + memory "fuse" + bitmask = 0x0f; + ; + + memory "prodsig" + size = 16; + page_size = 16; + offset = 0x3fc0; + ; + + memory "sigrow" + alias "prodsig"; + ; + + memory "sernum" + size = 10; + offset = 0x3fc6; # Sub-region of prodsig + ; + + memory "io" + size = 64; + ; +; + +#------------------------------------------------------------ +# ATtiny104 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" # t104 + desc = "ATtiny104"; + id = "t104"; + variants = + "ATtiny104-SSFR: SOIC14, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny104-SSNR: SOIC14, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny104F-SSFR: SOIC14, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny104F-SSNR: SOIC14, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 7; + n_interrupts = 16; + signature = 0x1e 0x90 0x0b; + factory_fcpu = 1000000; + + memory "flash" + size = 1024; + page_size = 16; + offset = 0x4000; + blocksize = 128; + ; + + memory "fuse" + bitmask = 0x0f; + ; + + memory "prodsig" + size = 16; + page_size = 16; + offset = 0x3fc0; + ; + + memory "sigrow" + alias "prodsig"; + ; + + memory "sernum" + size = 10; + offset = 0x3fc6; # Sub-region of prodsig + ; + + memory "io" + size = 64; + ; +; + +#------------------------------------------------------------ +# Common values for classic parts without calibration mem +#------------------------------------------------------------ + +# Classic here means non-TPI classic part + +part # .classic-nocal + desc = "Common values for classic parts without calibration mem"; + id = ".classic-nocal"; + prog_modes = PM_SPM | PM_ISP; + + memory "lock" + size = 1; + initval = 0xff; + read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; + write = "1010.1100--1110.0000--0000.0000--11ii.iiii"; + ; + + memory "signature" + size = 3; + read = "0011.0000--0000.0000--0000.00aa--oooo.oooo"; + ; + + memory "io" + size = 224; + offset = 0x20; + ; + + memory "sram" + size = 2048; + offset = 0x100; + ; +; + +#------------------------------------------------------------ +# Common values for classic parts +#------------------------------------------------------------ + +part parent ".classic-nocal" # .classic + desc = "Common values for classic parts"; + id = ".classic"; + factory_fcpu = 1000000; + chip_erase = "1010.1100--1000.0000--0000.0000--0000.0000"; + pgm_enable = "1010.1100--0101.0011--0000.0000--0000.0000"; + + memory "calibration" + size = 1; + read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; + ; +; + #------------------------------------------------------------ # ATtiny11 #------------------------------------------------------------ # This is an HVSP-only device. -part # t11 +part parent ".classic" # t11 desc = "ATtiny11"; id = "t11"; variants = @@ -3469,6 +3837,8 @@ part # t11 programlockpolltimeout = 25; synchcycles = 6; factory_fcpu = 1200000; + chip_erase = NULL; + pgm_enable = NULL; memory "flash" size = 1024; @@ -3484,21 +3854,22 @@ part # t11 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x06; + read = NULL; + write = NULL; ; memory "signature" - size = 3; + read = NULL; ; memory "calibration" - size = 1; + read = NULL; ; memory "io" size = 64; + offset = 0x0; ; memory "sram" @@ -3511,7 +3882,7 @@ part # t11 # ATtiny12 #------------------------------------------------------------ -part # t12 +part parent "t11" # t12 desc = "ATtiny12"; id = "t12"; variants = @@ -3528,9 +3899,8 @@ part # t12 n_interrupts = 6; stk500_devcode = 0x12; avr910_devcode = 0x55; - chip_erase_delay = 20000; signature = 0x1e 0x90 0x05; - timeout = 200; + serial = yes; stabdelay = 100; cmdexedelay = 25; synchloops = 32; @@ -3538,23 +3908,6 @@ part # t12 pollvalue = 0x53; predelay = 1; postdelay = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x00, - 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, - 0x78, 0x00, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 1; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - factory_fcpu = 1200000; chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; @@ -3572,14 +3925,11 @@ part # t12 ; memory "flash" - size = 1024; min_write_delay = 4500; max_write_delay = 20000; readback = 0xff 0x00; mode = 0x04; delay = 10; - blocksize = 128; - readsize = 256; read_lo = "0010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; read_hi = "0010.1000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; write_lo = "0100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; @@ -3587,8 +3937,8 @@ part # t12 ; memory "fuse" - size = 1; initval = 0x52; + bitmask = -1; min_write_delay = 9000; max_write_delay = 9000; read = "0101.0000--xxxx.xxxx--xxxx.xxxx--oooo.oooo"; @@ -3596,9 +3946,6 @@ part # t12 ; memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x06; min_write_delay = 9000; max_write_delay = 9000; read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xoox"; @@ -3606,21 +3953,196 @@ part # t12 ; memory "signature" - size = 3; read = "0011.0000--xxxx.xxxx--0000.00aa--oooo.oooo"; ; memory "calibration" - size = 1; read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; ; +; + +#------------------------------------------------------------ +# ATtiny15 +#------------------------------------------------------------ + +part parent "t11" # t15 + desc = "ATtiny15"; + id = "t15"; + variants = + "ATtiny15: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATtiny15L-1PC: DIP8, Fmax=1.6 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny15L-1PI: DIP8, Fmax=1.6 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny15L-1PU: DIP8, Fmax=1.6 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny15L-1SC: SOIC8, Fmax=1.6 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny15L-1SI: SOIC8, Fmax=1.6 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny15L-1SU: SOIC8, Fmax=1.6 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_ISP | PM_HVSP; + mcuid = 12; + n_interrupts = 9; + stk500_devcode = 0x13; + avr910_devcode = 0x56; + chip_erase_delay = 8200; + signature = 0x1e 0x90 0x06; + serial = yes; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + latchcycles = 16; + hvspcmdexedelay = 5; + factory_fcpu = 1600000; + chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; + pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + + memory "eeprom" + size = 64; + min_write_delay = 8200; + max_write_delay = 8200; + readback = 0xff 0xff; + mode = 0x04; + delay = 20; + blocksize = 64; + readsize = 256; + read = "1010.0000--xxxx.xxxx--xxaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + ; + + memory "flash" + min_write_delay = 4100; + max_write_delay = 4100; + readback = 0xff 0x00; + mode = 0x04; + delay = 10; + read_lo = "0010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; + write_lo = "0100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; + write_hi = "0100.1000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; + ; + + memory "fuse" + initval = 0x5c; + bitmask = 0xf3; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--xxxx.xxxx--xxxx.xxxx--oooo.xxoo"; + write = "1010.1100--101x.xxxx--xxxx.xxxx--iiii.11ii"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xoox"; + write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "signature" + read = "0011.0000--xxxx.xxxx--0000.00aa--oooo.oooo"; + ; + + memory "calibration" + read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; + ; +; + +#------------------------------------------------------------ +# ATtiny22 +#------------------------------------------------------------ + +part parent ".classic-nocal" # t22 + desc = "ATtiny22"; + id = "t22"; + variants = + "ATtiny22L-1PC: DIP8, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 6 V]", + "ATtiny22L-1PI: DIP8, Fmax=1 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]", + "ATtiny22L-1SC: SOIC8, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 6 V]", + "ATtiny22L-1SI: SOIC8, Fmax=1 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVSP; + mcuid = 13; + n_interrupts = 3; + stk500_devcode = 0x20; + chip_erase_delay = 18000; + signature = 0x1e 0x91 0x06; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + hvsp_controlstack = + 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x00, + 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, + 0x78, 0x00, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, + 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; + hventerstabdelay = 100; + latchcycles = 1; + poweroffdelay = 25; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + synchcycles = 6; + factory_fcpu = 1000000; + chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; + pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback = 0x00 0xff; + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + read = "1010.0000--0000.0000--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.0000--xaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback = 0xff 0xff; + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 128; + read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + write_lo = "0100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + write_hi = "0100.1000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + ; + + memory "fuse" + size = 1; + bitmask = 0x21; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxox.xxxo"; + write = "1010.1100--1011.111i--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "lock" + bitmask = 0x06; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0 1 0 1 1 0 0 0 x x x x x x x x x x x x x x x x o1 o2 x x x x x x"; + write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; + ; memory "io" size = 64; ; memory "sram" - size = 32; + size = 128; offset = 0x60; ; ; @@ -3629,7 +4151,7 @@ part # t12 # ATtiny13 #------------------------------------------------------------ -part # t13 +part parent ".classic" # t13 desc = "ATtiny13"; id = "t13"; variants = @@ -3698,8 +4220,6 @@ part # t13 eecr = 0x3c; ocdrev = 0; factory_fcpu = 1200000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 64; @@ -3754,18 +4274,9 @@ part # t13 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x03; min_write_delay = 4500; max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; ; memory "calibration" @@ -3775,7 +4286,6 @@ part # t13 memory "io" size = 64; - offset = 0x20; ; memory "sram" @@ -3816,27 +4326,347 @@ part parent "t13" # t13a ; #------------------------------------------------------------ -# ATtiny15 +# ATtiny25 #------------------------------------------------------------ -part # t15 - desc = "ATtiny15"; - id = "t15"; +part parent "t13" # t25 + desc = "ATtiny25"; + id = "t25"; variants = - "ATtiny15: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATtiny15L-1PC: DIP8, Fmax=1.6 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny15L-1PI: DIP8, Fmax=1.6 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny15L-1PU: DIP8, Fmax=1.6 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny15L-1SC: SOIC8, Fmax=1.6 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny15L-1SI: SOIC8, Fmax=1.6 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny15L-1SU: SOIC8, Fmax=1.6 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_ISP | PM_HVSP; - mcuid = 12; - n_interrupts = 9; - stk500_devcode = 0x13; - avr910_devcode = 0x56; - chip_erase_delay = 8200; - signature = 0x1e 0x90 0x06; + "ATtiny25: N/A, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[N/A, N/A]", + "ATtiny25-15ST: SOIC8, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20MF: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20MFR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20MUR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SN: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SNR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SSH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SSHR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SSN: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SSNR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SSU: SOIC8N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SSUR: SOIC8N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25-20SUR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-10MF: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10MFR: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10MUR: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10PU: PDIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SH: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SN: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SNR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SSH: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SSHR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SSN: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SSNR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SSU: SOIC8N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SSUR: SOIC8N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SU: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-10SUR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny25V-20MF: MLF20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-20SH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-20SN: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-20SSH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-20SSN: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-20SSU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny25V-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 16; + n_interrupts = 15; +# avr910_devcode = ?; +# Try the AT90S2313 devcode: + avr910_devcode = 0x20; + chip_erase_delay = 4500; + signature = 0x1e 0x91 0x08; + reset = io; + flash_instr = 0xb4, 0x02, 0x12; + eeprom_instr = + 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, + 0xbc, 0x02, 0xb4, 0x02, 0xba, 0x0d, 0xbb, 0xbc, + 0x99, 0xe1, 0xbb, 0xac; + idr = 0x22; + ocdrev = 1; + factory_fcpu = 1000000; + + memory "eeprom" + size = 128; + max_write_delay = 4500; + read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 2048; + num_pages = 64; + read_lo = "0010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.00aa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--0000.00aa--aaaa.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + initval = 0xdf; + bitmask = -1; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny45 +#------------------------------------------------------------ + +part parent "t13" # t45 + desc = "ATtiny45"; + id = "t45"; + variants = + "ATtiny45: N/A, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[N/A, N/A]", + "ATtiny45-15SZ: SOIC8, Fmax=N/A, T=[-40 C, 85 C], Vcc=[N/A, N/A]", + "ATtiny45-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45-20MUR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45-20SUR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45-20XU: TSSOP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45-20XUR: TSSOP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny45V-10MUR: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny45V-10PU: PDIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny45V-10SH: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny45V-10SU: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny45V-10SUR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny45V-10XU: TSSOP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny45V-10XUR: TSSOP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny45V-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45V-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45V-20SH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45V-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny45V-20XU: TSSOP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 22; + n_interrupts = 15; +# avr910_devcode = ?; +# Try the AT90S2313 devcode: + avr910_devcode = 0x20; + chip_erase_delay = 4500; + signature = 0x1e 0x92 0x06; + reset = io; + flash_instr = 0xb4, 0x02, 0x12; + eeprom_instr = + 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, + 0xbc, 0x02, 0xb4, 0x02, 0xba, 0x0d, 0xbb, 0xbc, + 0x99, 0xe1, 0xbb, 0xac; + idr = 0x22; + ocdrev = 1; + factory_fcpu = 1000000; + + memory "eeprom" + size = 256; + max_write_delay = 4500; + read = "1010.0000--000x.xxxx--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 4096; + page_size = 64; + num_pages = 64; + blocksize = 64; + read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.0aaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + initval = 0xdf; + bitmask = -1; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 256; + ; +; + +#------------------------------------------------------------ +# ATtiny85 +#------------------------------------------------------------ + +part parent "t13" # t85 + desc = "ATtiny85"; + id = "t85"; + variants = + "ATtiny85: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[N/A, N/A]", + "ATtiny85-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85-20MUR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85-20SF: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny85-20SFR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85-20SUR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny85V-10MUR: MLF20, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny85V-10PU: PDIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny85V-10SH: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny85V-10SU: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny85V-10SUR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny85V-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85V-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85V-20SH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny85V-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 26; + n_interrupts = 15; +# avr910_devcode = ?; +# Try the AT90S2313 devcode: + avr910_devcode = 0x20; + chip_erase_delay = 4500; + signature = 0x1e 0x93 0x0b; + reset = io; + flash_instr = 0xb4, 0x02, 0x12; + eeprom_instr = + 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, + 0xbc, 0x02, 0xb4, 0x02, 0xba, 0x0d, 0xbb, 0xbc, + 0x99, 0xe1, 0xbb, 0xac; + idr = 0x22; + ocdrev = 1; + factory_fcpu = 1000000; + + memory "eeprom" + size = 512; + max_write_delay = 4500; + read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 8192; + page_size = 64; + num_pages = 128; + blocksize = 64; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + initval = 0xdf; + bitmask = -1; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATtiny2313 +#------------------------------------------------------------ + +part parent ".classic" # t2313 + desc = "ATtiny2313"; + id = "t2313"; + variants = + "ATtiny2313: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny2313-20MUR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny2313-20PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny2313-20SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny2313-20SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny2313V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313V-10MUR: WQFN20, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313V-10PU: PDIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313V-10SUR: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 42; + n_interrupts = 19; + stk500_devcode = 0x23; +# Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + chip_erase_delay = 9000; + pagel = 0xd4; + bs2 = 0xd6; + signature = 0x1e 0x91 0x0a; + reset = io; timeout = 200; stabdelay = 100; cmdexedelay = 25; @@ -3845,13 +4675,554 @@ part # t15 pollvalue = 0x53; predelay = 1; postdelay = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x00, - 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, - 0x78, 0x00, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, + 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, + 0x26, 0x36, 0x66, 0x76, 0x2a, 0x3a, 0x6a, 0x7a, + 0x2e, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb2, 0x0f, 0x1f; + eeprom_instr = + 0xbb, 0xfe, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, + 0xba, 0x0f, 0xb2, 0x0f, 0xba, 0x0d, 0xbb, 0xbc, + 0x99, 0xe1, 0xbb, 0xac; hventerstabdelay = 100; - latchcycles = 16; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x1f; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 0; + + memory "eeprom" + size = 128; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 32; + readsize = 256; + read_lo = "0010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.00aa--aaaa.aaaa--oooo.oooo"; +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_lo = "0100.0000--000x.xxxx--xxxx.aaaa--iiii.iiii"; +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_hi = "0100.1000--000x.xxxx--xxxx.aaaa--iiii.iiii"; +# The information in the data sheet of April/2004 is wrong, this works: + writepage = "0100.1100--0000.00aa--aaaa.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x64; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 9000; + max_write_delay = 9000; + ; + +# The Tiny2313 has calibration data for both 4 MHz and 8 MHz. +# The information in the data sheet of April/2004 is wrong, this works: + + memory "calibration" + size = 2; + read = "0011.1000--000x.xxxx--0000.000a--oooo.oooo"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 128; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# ATtiny2313A +#------------------------------------------------------------ + +part parent "t2313" # t2313a + desc = "ATtiny2313A"; + id = "t2313a"; + variants = + "ATtiny2313A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313A-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313A-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313A-MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313A-MUR: WQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313A-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313A-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny2313A-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 43; + n_interrupts = 21; + idr = 0x27; + + memory "lfuse" + initval = 0x62; + ; +; + +#------------------------------------------------------------ +# ATtiny4313 +#------------------------------------------------------------ + +part parent "t2313" # t4313 + desc = "ATtiny4313"; + id = "t4313"; + variants = + "ATtiny4313: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny4313-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny4313-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny4313-MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny4313-MUR: MLF20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny4313-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny4313-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny4313-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 44; + n_interrupts = 21; + signature = 0x1e 0x92 0x0d; + idr = 0x27; + + memory "eeprom" + size = 256; + read = "1010.0000--000x.xxxx--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 4096; + page_size = 64; + read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.0aaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + initval = 0x62; + ; + + memory "sram" + size = 256; + ; +; + +#------------------------------------------------------------ +# ATtiny24 +#------------------------------------------------------------ + +part parent ".classic" # t24 + desc = "ATtiny24"; + id = "t24"; + variants = + "ATtiny24: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24-20MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny24-20MUR: WQFN20, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATtiny24-20PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny24-20SSU: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny24-20SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny24V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24V-10MUR: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24V-10PU: PDIP14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24V-10SSU: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24V-10SSUR: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; + mcuid = 14; + n_interrupts = 17; +# no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +# avr910_devcode = ?; +# Try the AT90S2313 devcode: + avr910_devcode = 0x20; + chip_erase_delay = 4500; + signature = 0x1e 0x91 0x0b; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + hvsp_controlstack = + 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, + 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, + 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, + 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0f; + flash_instr = 0xb4, 0x07, 0x17; + eeprom_instr = + 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, + 0xbc, 0x07, 0xb4, 0x07, 0xba, 0x0d, 0xbb, 0xbc, + 0x99, 0xe1, 0xbb, 0xac; + hventerstabdelay = 100; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 50; + resetdelayus = 3; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + synchcycles = 6; + hvspcmdexedelay = 50; + idr = 0x27; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 1; + + memory "eeprom" + size = 128; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 32; + readsize = 256; + read_lo = "0010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.00aa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxx.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxx.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.00aa--aaaa.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 9000; + max_write_delay = 9000; + write = "1010.1100--111x.xxxx--xxxx.xxxx--xxxx.xxii"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 128; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# ATtiny24A +#------------------------------------------------------------ + +part parent "t24" # t24a + desc = "ATtiny24A"; + id = "t24a"; + variants = + "ATtiny24A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-CCU: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-CCUR: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-MF: QFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-MFR: QFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-MM8: VQFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-MM8R: VQFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-MUR: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-SSF: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-SSFR: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny24A-SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 15; +; + +#------------------------------------------------------------ +# ATtiny44 +#------------------------------------------------------------ + +part parent "t24" # t44 + desc = "ATtiny44"; + id = "t44"; + variants = + "ATtiny44: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44-20MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny44-20MUR: WQFN20, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATtiny44-20PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny44-20SSU: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny44-20SSUR: SOIC14N, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATtiny44V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44V-10MUR: WQFN20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44V-10PU: PDIP14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44V-10SSU: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44V-10SSUR: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 20; + signature = 0x1e 0x92 0x07; + + memory "eeprom" + size = 256; + read = "1010.0000--000x.xxxx--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 4096; + page_size = 64; + blocksize = 64; + read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.0aaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 256; + ; +; + +#------------------------------------------------------------ +# ATtiny44A +#------------------------------------------------------------ + +part parent "t44" # t44a + desc = "ATtiny44A"; + id = "t44a"; + variants = + "ATtiny44A: N/A, Fmax=20 MHz, T=[-40 C, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-CCU: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-CCUR: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-MF: QFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-MFR: QFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-MUR: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-SSF: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-SSFR: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny44A-SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = XVII + IV; # 21; + + +; + +#------------------------------------------------------------ +# ATtiny84 +#------------------------------------------------------------ + +part parent "t24" # t84 + desc = "ATtiny84"; + id = "t84"; + variants = + "ATtiny84: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84-15MZ: MLF20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny84-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny84-20MUR: WQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny84-20PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny84-20SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny84-20SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny84V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84V-10MUR: WQFN20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84V-10PU: PDIP14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84V-10SSU: SOIC14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84V-10SSUR: SOIC14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 24; + signature = 0x1e 0x93 0x0c; + + memory "eeprom" + size = 512; + read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 8192; + page_size = 64; + num_pages = 128; + blocksize = 64; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATtiny84A +#------------------------------------------------------------ + +part parent "t84" # t84a + desc = "ATtiny84A"; + id = "t84a"; + variants = + "ATtiny84A-CCU: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-CCUR: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-MF: WQFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-MFR: WQFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-MUR: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-SSF: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-SSFR: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny84A-SSUR: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 25; +; + +#------------------------------------------------------------ +# ATtiny441 +#------------------------------------------------------------ + +part parent ".classic" # t441 + desc = "ATtiny441"; + id = "t441"; + variants = + "ATtiny441-MMH: VQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny441-MMHR: VQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny441-MU: QFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny441-MUR: QFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny441-SSU: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny441-SSUR: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; + mcuid = 32; + n_interrupts = 30; + n_page_erase = 4; + stk500_devcode = 0x14; + avr910_devcode = 0x20; + chip_erase_delay = 4500; + signature = 0x1e 0x92 0x15; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + hvsp_controlstack = + 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, + 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, + 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, + 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0f; + flash_instr = 0xb4, 0x07, 0x17; + eeprom_instr = + 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, + 0xbc, 0x07, 0xb4, 0x07, 0xba, 0x0d, 0xbb, 0xbc, + 0x99, 0xe1, 0xbb, 0xac; + hventerstabdelay = 100; + latchcycles = 1; togglevtg = 1; poweroffdelay = 25; resetdelayms = 1; @@ -3861,67 +5232,780 @@ part # t15 programfusepolltimeout = 25; programlockpolltimeout = 25; synchcycles = 6; - hvspcmdexedelay = 5; - factory_fcpu = 1600000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + idr = 0x27; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 1; memory "eeprom" - size = 64; - min_write_delay = 8200; - max_write_delay = 8200; + size = 256; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxx--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 4096; + page_size = 16; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 16; + readsize = 256; + read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxx.xaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxx.xaaa--iiii.iiii"; + writepage = "0100.1100--0000.0aaa--aaaa.axxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + bitmask = 0xdf; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0xff; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 9000; + max_write_delay = 9000; + write = "1010.1100--111x.xxxx--xxxx.xxxx--xxxx.xxii"; + ; + + memory "sram" + size = 256; + ; +; + +#------------------------------------------------------------ +# ATtiny841 +#------------------------------------------------------------ + +part parent "t441" # t841 + desc = "ATtiny841"; + id = "t841"; + variants = + "ATtiny841-MMH: VQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny841-MMHR: VQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny841-MU: QFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny841-MUR: QFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny841-SSU: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny841-SSUR: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]"; + mcuid = 37; + signature = 0x1e 0x93 0x15; + + memory "eeprom" + size = 512; + read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 8192; + num_pages = 512; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--0000.aaaa--aaaa.axxx--xxxx.xxxx"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATtiny26 +#------------------------------------------------------------ + +part parent ".classic" # t26 + desc = "ATtiny26"; + id = "t26"; + variants = + "ATtiny26: N/A, Fmax=16 MHz, T=[N/A, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny26-16MU: MLF32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATtiny26-16MUR: VQFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATtiny26-16PU: PDIP20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATtiny26-16SU: SOIC20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATtiny26-16SUR: SOIC20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATtiny26L-8MU: MLF32, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny26L-8MUR: VQFN32, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny26L-8PU: PDIP20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny26L-8SU: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny26L-8SUR: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_ISP | PM_HVPP; + mcuid = 17; + n_interrupts = 12; + stk500_devcode = 0x21; + avr910_devcode = 0x5e; + chip_erase_delay = 9000; + pagel = 0xb3; + bs2 = 0xb2; + signature = 0x1e 0x91 0x09; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0xc4, 0xe4, 0xc4, 0xe4, 0xcc, 0xec, 0xcc, 0xec, + 0xd4, 0xf4, 0xd4, 0xf4, 0xdc, 0xfc, 0xdc, 0xfc, + 0xc8, 0xe8, 0xd8, 0xf8, 0x4c, 0x6c, 0x5c, 0x7c, + 0xec, 0xbc, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 20; + programfusepolltimeout = 10; + programlockpolltimeout = 10; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 9000; readback = 0xff 0xff; mode = 0x04; delay = 20; blocksize = 64; readsize = 256; - read = "1010.0000--xxxx.xxxx--xxaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + read = "1010.0000--xxxx.xxxx--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; ; memory "flash" - size = 1024; - min_write_delay = 4100; - max_write_delay = 4100; + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; readback = 0xff 0x00; - mode = 0x04; + mode = 0x21; delay = 10; - blocksize = 128; + blocksize = 16; + readsize = 256; + read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xxxx.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xxxx.aaaa--iiii.iiii"; + writepage = "0100.1100--xxxx.xxaa--aaaa.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0xe1; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xf7; + bitmask = 0x1f; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--xxxi.iiii"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xxoo"; + write = "1010.1100--1111.11ii--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "calibration" + size = 4; + read = "0011.1000--xxxx.xxxx--0000.00aa--oooo.oooo"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 128; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# ATtiny261 +#------------------------------------------------------------ + +part parent ".classic" # t261 + desc = "ATtiny261"; + id = "t261"; + variants = + "ATtiny261: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[N/A, N/A]", + "ATtiny261-20MU: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny261-20PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny261-20SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny261V-10MU: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261V-10PU: PDIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 30; + n_interrupts = 19; + chip_erase_delay = 4000; + pagel = 0xb3; + bs2 = 0xb2; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0c; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0xc4, 0xe4, 0xc4, 0xe4, 0xcc, 0xec, 0xcc, 0xec, + 0xd4, 0xf4, 0xd4, 0xf4, 0xdc, 0xfc, 0xdc, 0xfc, + 0xc8, 0xe8, 0xd8, 0xf8, 0x4c, 0x6c, 0x5c, 0x7c, + 0xec, 0xbc, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb4, 0x00, 0x10; + eeprom_instr = + 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, + 0xbc, 0x00, 0xb4, 0x00, 0xba, 0x0d, 0xbb, 0xbc, + 0x99, 0xe1, 0xbb, 0xac; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x20; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 1; + + memory "eeprom" + size = 128; + page_size = 4; + num_pages = 32; + min_write_delay = 4000; + max_write_delay = 4000; + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + read = "1010.0000--xxxx.xxxx--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 32; + readsize = 256; + read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xxxx.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xxxx.aaaa--iiii.iiii"; + writepage = "0100.1100--xxxx.xxaa--aaaa.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xxoo"; + write = "1010.1100--1111.11ii--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 128; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# ATtiny261A +#------------------------------------------------------------ + +part parent "t261" # t261a + desc = "ATtiny261A"; + id = "t261a"; + variants = + "ATtiny261A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-MF: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-MFR: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-MN: MLF32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-MNR: VQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-XU: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny261A-XUR: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 31; +; + +#------------------------------------------------------------ +# ATtiny461 +#------------------------------------------------------------ + +part parent "t261" # t461 + desc = "ATtiny461"; + id = "t461"; + variants = + "ATtiny461: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[N/A, N/A]", + "ATtiny461-20MU: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny461-20MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny461-20PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny461-20SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny461-20SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny461V-10MU: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny461V-10MUR: VQFN32, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny461V-10PU: PDIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny461V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny461V-10SUR: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 33; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x08; + + memory "eeprom" + size = 256; + num_pages = 64; + read = "1010.0000--xxxx.xxxx--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxx--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 4096; + page_size = 64; + blocksize = 64; + read_lo = "0010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--xxxx.xaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 256; + ; +; + +#------------------------------------------------------------ +# ATtiny461A +#------------------------------------------------------------ + +part parent "t461" # t461a + desc = "ATtiny461A"; + id = "t461a"; + variants = + "ATtiny461A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny461A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny461A-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny461A-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny461A-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny461A-XU: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny461A-XUR: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 34; +; + +#------------------------------------------------------------ +# ATtiny861 +#------------------------------------------------------------ + +part parent "t261" # t861 + desc = "ATtiny861"; + id = "t861"; + variants = + "ATtiny861: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[N/A, N/A]", + "ATtiny861-20MU: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny861-20MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny861-20PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny861-20SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny861-20SUR: SOIC20, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATtiny861V-10MU: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861V-10MUR: VQFN32, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny861V-10PU: PDIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861V-10SUR: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 38; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x93 0x0d; + + memory "eeprom" + size = 512; + num_pages = 128; + read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 8192; + page_size = 64; + num_pages = 128; + blocksize = 64; + read_lo = "0010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--xxxx.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATtiny861A +#------------------------------------------------------------ + +part parent "t861" # t861a + desc = "ATtiny861A"; + id = "t861a"; + variants = + "ATtiny861A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny861A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861A-MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861A-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861A-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861A-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861A-XU: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny861A-XUR: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 39; +; + +#------------------------------------------------------------ +# ATtiny48 +#------------------------------------------------------------ + +part parent ".classic" # t48 + desc = "ATtiny48"; + id = "t48"; + variants = + "ATtiny48-AU: TQFP32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-AUR: TQFP32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-CCU: UFBGA32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-MMH: VQFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-MMHR: VQFN28, Fmax=12 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-MMU: MLF28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-MMUR: VQFN28, Fmax=12 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-MU: MLF32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-MUR: VQFN32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny48-PU: PDIP28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 23; + n_interrupts = 20; + stk500_devcode = 0x73; + chip_erase_delay = 15000; + pagel = 0xd7; + bs2 = 0xc2; +# avr910_devcode = 0x??; + signature = 0x1e 0x92 0x09; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 64; + page_size = 4; + min_write_delay = 3600; + max_write_delay = 3600; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x6e; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "sram" + size = 256; + ; +; + +#------------------------------------------------------------ +# ATtiny88 +#------------------------------------------------------------ + +part parent "t48" # t88 + desc = "ATtiny88"; + id = "t88"; + variants = + "ATtiny88-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-AUR: TQFP32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-CCU: UFBGA32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-MMH: VQFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-MMHR: VQFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-MMU: QFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-MMUR: QFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-MU: QFN32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-MUR: VQFN32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny88-PU: PDIP28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 28; + chip_erase_delay = 9000; +# avr910_devcode = 0x??; + signature = 0x1e 0x93 0x11; + + memory "flash" + size = 8192; + num_pages = 128; + ; + + memory "efuse" + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATtiny28 +#------------------------------------------------------------ + +# This is an HVPP-only device. + +part parent ".classic" # t28 + desc = "ATtiny28"; + id = "t28"; + variants = + "ATtiny28: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATtiny28L-4AU: TQFP32, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny28L-4MU: MLF32, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny28L-4MUR: VQFN32, Fmax=4 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATtiny28L-4PU: PDIP28, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny28V-1AU: TQFP32, Fmax=1.2 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny28V-1AUR: TQFP32, Fmax=1 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny28V-1MU: MLF32, Fmax=1.2 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny28V-1MUR: VQFN32, Fmax=1 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny28V-1PU: PDIP28, Fmax=1.2 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_HVPP; + mcuid = 18; + n_interrupts = 6; + stk500_devcode = 0x22; + avr910_devcode = 0x5c; + signature = 0x1e 0x91 0x07; + serial = no; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + factory_fcpu = 1200000; + chip_erase = NULL; + pgm_enable = NULL; + + memory "flash" + size = 2048; + page_size = 2; + delay = 5; readsize = 256; - read_lo = "0010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; - write_lo = "0100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; - write_hi = "0100.1000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; ; memory "fuse" size = 1; - initval = 0x5c; - bitmask = 0xf3; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--xxxx.xxxx--xxxx.xxxx--oooo.xxoo"; - write = "1010.1100--101x.xxxx--xxxx.xxxx--iiii.11ii"; + initval = 0x12; + bitmask = 0x1f; ; memory "lock" - size = 1; - initval = 0xff; + initval = 0x06; bitmask = 0x06; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xoox"; - write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; + read = NULL; + write = NULL; ; memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--0000.00aa--oooo.oooo"; + read = NULL; ; memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; + read = NULL; ; memory "io" @@ -3935,90 +6019,1827 @@ part # t15 ; #------------------------------------------------------------ -# AT89S51 +# ATtiny43U #------------------------------------------------------------ -# Nonstandard part -# - Tested with -c avrisp -# - USBASP programmers may require different firmware - -part # 89S51 - desc = "AT89S51"; - id = "89S51"; +part parent ".classic" # t43u + desc = "ATtiny43U"; + id = "t43u"; variants = - "AT89S51: N/A, Fmax=33 MHz, T=[N/A, N/A], Vcc=[4 V, 5.5 V]", - "AT89S51-24AU: TQFP44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", - "AT89S51-24JU: PLCC44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", - "AT89S51-24PU: PDIP40, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]"; - prog_modes = PM_ISP | PM_HVPP; - mcuid = 372; - stk500_devcode = 0xe0; - chip_erase_delay = 250000; - signature = 0x1e 0x51 0x06; + "ATtiny43U: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[0.7 V, 5.5 V]", + "ATtiny43U-MU: QFN20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny43U-MUR: WQFN20, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATtiny43U-SU: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny43U-SUR: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 19; + n_interrupts = 16; + stk500_devcode = 0x14; +# avr910_devcode = ?; +# Try the AT90S2313 devcode: + avr910_devcode = 0x20; + chip_erase_delay = 1000; + pagel = 0xa3; + bs2 = 0xa2; + signature = 0x1e 0x92 0x0c; + reset = io; timeout = 200; stabdelay = 100; cmdexedelay = 25; synchloops = 32; - pollindex = 4; - pollvalue = 0x69; + pollindex = 3; + pollvalue = 0x53; predelay = 1; postdelay = 1; - chiperasepulsewidth = 15; - programfusepulsewidth = 2; - programlockpolltimeout = 1; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + pp_controlstack = + 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, + 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, + 0x06, 0x16, 0x46, 0x56, 0x0a, 0x1a, 0x4a, 0x5a, + 0x1e, 0x7c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb4, 0x07, 0x17; + eeprom_instr = + 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, + 0xbc, 0x07, 0xb4, 0x07, 0xba, 0x0d, 0xbb, 0xbc, + 0x99, 0xe1, 0xbb, 0xac; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 20; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x27; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 1; + + memory "eeprom" + size = 64; + page_size = 4; + num_pages = 16; + min_write_delay = 4000; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxx--00aa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxx--00aa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxx--00aa.aa00--xxxx.xxxx"; + ; memory "flash" + paged = yes; size = 4096; + page_size = 64; + num_pages = 64; min_write_delay = 4500; max_write_delay = 4500; - readback = 0xff 0xff; - mode = 0x02; + mode = 0x41; delay = 10; - blocksize = 256; - read = "0010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; - write = "0100.0000--xxxa.aaaa--aaaa.aaaa--iiii.iiii"; - # Nonstandard page mode is available but not implemented + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.0aaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; ; memory "lock" - size = 1; - read = "0010.0100--xxxx.xxxx--xxxx.xxxx--xxxo.ooxx"; - # Nonstandard write: expect verification errors - # See datasheet Page 20, Note 1 https://ww1.microchip.com/downloads/en/DeviceDoc/doc2487.pdf - # Activate lock mode 0 through chip erase: avrdude -e - # Activate lock mode 1: avrdude -e -V -U lock:w:1:m - # Activate lock mode 2: avrdude -e -V -U lock:w:1:m -U lock:w:2:m - # Activate lock mode 3: avrdude -e -V -U lock:w:1:m -U lock:w:2:m -U lock:w:3:m - write = "1010.1100--1110.00ii--xxxx.xxxx--xxxx.xxxx"; + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; ; - memory "signature" - size = 3; - read = "0 0 1 0 1 0 0 0 x x x x x x a1 a0 x x x x x x x 0 o o o o o o o o"; + memory "io" + size = 64; + ; + + memory "sram" + size = 256; + offset = 0x60; ; ; #------------------------------------------------------------ -# AT89S52 +# ATtiny828 #------------------------------------------------------------ -part parent "89S51" # 89S52 - desc = "AT89S52"; - id = "89S52"; +part parent ".classic" # t828 + desc = "ATtiny828"; + id = "t828"; variants = - "AT89S52: N/A, Fmax=33 MHz, T=[N/A, N/A], Vcc=[4 V, 5.5 V]", - "AT89S52-24AU: TQFP44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", - "AT89S52-24AUR: TQFP44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", - "AT89S52-24JU: PLCC44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", - "AT89S52-24PU: PDIP40, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]"; - mcuid = 373; - stk500_devcode = 0xe1; - signature = 0x1e 0x52 0x06; + "ATtiny828: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.62 V, 5.5 V]", + "ATtiny828-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny828-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny828-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny828-MUR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 35; + n_interrupts = 26; + n_boot_sections = 4; + boot_section_size = 256; + stk500_devcode = 0x86; + chip_erase_delay = 15000; + pagel = 0xd7; + bs2 = 0xc2; +# avr910_devcode = 0x??; + signature = 0x1e 0x93 0x14; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 256; + page_size = 4; + min_write_delay = 3600; + max_write_delay = 3600; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; memory "flash" + paged = yes; size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x6e; + bitmask = 0xf3; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0xf7; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--iiii.1iii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATtiny828R +#------------------------------------------------------------ + +part parent "t828" # t828r + desc = "ATtiny828R"; + id = "t828r"; + variants = + "ATtiny828R-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", + "ATtiny828R-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]"; + mcuid = 36; +; + +#------------------------------------------------------------ +# ATtiny87 +#------------------------------------------------------------ + +part parent ".classic" # t87 + desc = "ATtiny87"; + id = "t87"; + variants = + "ATtiny87: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny87-MU: VQFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny87-MUR: VQFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny87-SU: SOIC20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny87-SUR: SOIC20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny87-XU: TSSOP20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny87-XUR: TSSOP20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 27; + n_interrupts = 20; +# no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +# Try the AT90S2313 devcode: + avr910_devcode = 0x20; + chip_erase_delay = 15000; + pagel = 0xb3; + bs2 = 0xb2; + signature = 0x1e 0x93 0x87; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, + 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, + 0x06, 0x16, 0x46, 0x56, 0x0a, 0x1a, 0x4a, 0x5a, + 0x1e, 0x7c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 9000; + max_write_delay = 9000; + write = "1010.1100--111x.xxxx--xxxx.xxxx--xxxx.xxii"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATtiny167 +#------------------------------------------------------------ + +part parent "t87" # t167 + desc = "ATtiny167"; + id = "t167"; + variants = + "ATtiny167: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny167-A15XD: TSSOP20, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", + "ATtiny167-MMU: WQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny167-MMUR: WQFN20, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATtiny167-MU: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny167-MUR: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny167-SU: SOIC20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny167-SUR: SOIC20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny167-XU: TSSOP20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny167-XUR: TSSOP20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 29; + signature = 0x1e 0x94 0x87; + + memory "flash" + size = 0x4000; + num_pages = 128; + writepage = "0100.1100--000a.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; +; + +#------------------------------------------------------------ +# ATtiny1634 +#------------------------------------------------------------ + +part parent ".classic" # t1634 + desc = "ATtiny1634"; + id = "t1634"; + variants = + "ATtiny1634: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634-MN: WQFN20, Fmax=12 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634-MNR: WQFN20, Fmax=12 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634-MU: QFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634-MUR: QFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634-SU: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634-SUR: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 40; + n_interrupts = 28; + n_page_erase = 4; + stk500_devcode = 0x86; + chip_erase_delay = 9000; + pagel = 0xb3; + bs2 = 0xb1; +# avr910_devcode = 0x??; + signature = 0x1e 0x94 0x12; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x2e; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 1; + + memory "eeprom" + size = 256; + page_size = 4; + min_write_delay = 3600; + max_write_delay = 3600; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x4000; + page_size = 32; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 32; + readsize = 256; + read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxx.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxx.aaaa--iiii.iiii"; + writepage = "0100.1100--00aa.aaaa--aaaa.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + bitmask = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x1f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxi.iiii"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; + write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; + ; + + memory "sram" + size = 1024; + ; +; + +#------------------------------------------------------------ +# ATtiny1634R +#------------------------------------------------------------ + +part parent "t1634" # t1634r + desc = "ATtiny1634R"; + id = "t1634r"; + variants = + "ATtiny1634R-MU: QFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634R-MUR: WQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634R-SU: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATtiny1634R-SUR: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 41; +; + +#------------------------------------------------------------ +# AT90CAN32 +#------------------------------------------------------------ + +part parent ".classic" # c32 + desc = "AT90CAN32"; + id = "c32"; + variants = + "AT90CAN32: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90CAN32-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN32-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN32-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN32-16MI: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN32-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN32-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 171; + n_interrupts = 37; + n_boot_sections = 4; + boot_section_size = 1024; + stk500_devcode = 0xb3; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; +# avr910_devcode = 0x43; + signature = 0x1e 0x95 0x81; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01; + hventerstabdelay = 100; + latchcycles = 6; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 3; + + memory "eeprom" + size = 1024; + page_size = 8; + min_write_delay = 9000; + max_write_delay = 9000; + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + read = "1010.0000--000x.xxaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x8000; + page_size = 256; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0x99; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x0f; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# AT90CAN64 +#------------------------------------------------------------ + +part parent "c32" # c64 + desc = "AT90CAN64"; + id = "c64"; + variants = + "AT90CAN64: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90CAN64-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN64-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN64-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN64-16MI: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN64-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN64-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; + mcuid = 172; +# avr910_devcode = 0x43; + signature = 0x1e 0x96 0x81; + + memory "eeprom" + size = 2048; + read = "1010.0000--000x.xaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xaaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x10000; + num_pages = 256; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# AT90CAN128 +#------------------------------------------------------------ + +part parent "c32" # c128 + desc = "AT90CAN128"; + id = "c128"; + variants = + "AT90CAN128: N/A, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, N/A]", + "AT90CAN128-15AZ: TQFP64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN128-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN128-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN128-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN128-16MI: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN128-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90CAN128-16MUR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; + mcuid = 176; +# avr910_devcode = 0x43; + signature = 0x1e 0x97 0x81; + rampz = 0x3b; + + memory "eeprom" + size = 4096; + read = "1010.0000--000x.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.aaaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x20000; + num_pages = 512; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# AT90PWM81 +#------------------------------------------------------------ + +part parent ".classic" # pwm81 + desc = "AT90PWM81"; + id = "pwm81"; + variants = + "AT90PWM81: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM81-16MF: QFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM81-16MN: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM81-16SF: SOIC20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM81-16SN: SOIC20, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM81EP-16MN: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 173; + n_interrupts = 20; + n_boot_sections = 4; + boot_section_size = 256; + chip_erase_delay = 9000; + pagel = 0xe2; + bs2 = 0xd6; + signature = 0x1e 0x93 0x88; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0xc4, 0xe4, 0xc4, 0xe4, 0xcc, 0xec, 0xcc, 0xec, + 0xd4, 0xf4, 0xd4, 0xf4, 0xdc, 0xfc, 0xdc, 0xfc, + 0xc8, 0xe8, 0xd8, 0xf8, 0x4c, 0x6c, 0x5c, 0x7c, + 0xec, 0xbc, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 3600; + max_write_delay = 3600; + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + read = "1010.0000--0000.000a--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.000a--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--0000.000a--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--000a.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--000a.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaa0.0000--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xd9; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xfd; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; + ; + + memory "sram" + size = 256; + ; +; + +#------------------------------------------------------------ +# AT90PWM161 +#------------------------------------------------------------ + +part parent "pwm81" # pwm161 + desc = "AT90PWM161"; + id = "pwm161"; + variants = + "AT90PWM161: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM161-16MN: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM161-16MNR: QFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM161-16SN: SOIC20, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM161-16SNR: SOIC20, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; + mcuid = 177; + signature = 0x1e 0x94 0x8b; + + memory "flash" + size = 0x4000; + page_size = 128; + read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--00aa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--00aa.aaaa--iiii.iiii"; + writepage = "0100.1100--000a.aaaa--aa00.0000--xxxx.xxxx"; + ; + + memory "sram" + size = 1024; + ; +; + +#------------------------------------------------------------ +# AT90PWM1 +#------------------------------------------------------------ + +part parent ".classic" # pwm1 + desc = "AT90PWM1"; + id = "pwm1"; + variants = + "AT90PWM1: SOIC24, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM1-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM1-16MUR: QFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM1-16SU: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 166; + n_interrupts = 32; + n_boot_sections = 4; + boot_section_size = 256; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xe2; + signature = 0x1e 0x93 0x83; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 3600; + max_write_delay = 3600; + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + read = "1010.0000--0000.000a--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.000a--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--0000.000a--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--000a.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--000a.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaa0.0000--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xf9; + bitmask = 0xb7; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--o1oo.1ooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--i1ii.1iii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# AT90PWM2 +#------------------------------------------------------------ + +part parent ".classic" # pwm2 + desc = "AT90PWM2"; + id = "pwm2"; + variants = + "AT90PWM2: SOIC24, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM2-16SQ: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM2-16SQR: SOIC24, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 167; + n_interrupts = 32; + n_boot_sections = 4; + boot_section_size = 256; + stk500_devcode = 0x65; + chip_erase_delay = 9000; + pagel = 0xd8; + bs2 = 0xe2; +# avr910_devcode = ?; + signature = 0x1e 0x93 0x81; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + spmcr = 0x57; + eecr = 0x3f; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback = 0xff 0xff; + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback = 0xff 0xff; + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xf9; + bitmask = 0xf7; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# AT90PWM2B +#------------------------------------------------------------ +# Same as AT90PWM2 but different signature. + +part parent "pwm2" # pwm2b + desc = "AT90PWM2B"; + id = "pwm2b"; + variants = + "AT90PWM2B: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM2B-16SU: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM2B-16SUR: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 168; + signature = 0x1e 0x93 0x83; + resetdelay = 15; + idr = 0x31; + ocdrev = 1; + + memory "eeprom" + readback = 0x00 0x00; + delay = 5; + ; + + memory "flash" + readback = 0x00 0x00; + delay = 10; + ; +; + +#------------------------------------------------------------ +# AT90PWM3 +#------------------------------------------------------------ + +# Completely identical to AT90PWM2 (including the signature!) + +part parent "pwm1" # pwm3 + desc = "AT90PWM3"; + id = "pwm3"; + variants = + "AT90PWM3: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM3-16MQ: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM3-16MQT: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 169; + stk500_devcode = 0x65; + pagel = 0xd8; + signature = 0x1e 0x93 0x81; + + memory "eeprom" + min_write_delay = 4000; + max_write_delay = 4500; + ; + + memory "lfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + bitmask = 0xf7; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; + ; +; + +#------------------------------------------------------------ +# AT90PWM3B +#------------------------------------------------------------ + +# Completely identical to AT90PWM2B (including the signature!) + +part parent "pwm3" # pwm3b + desc = "AT90PWM3B"; + id = "pwm3b"; + variants = + "AT90PWM3B: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM3B-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM3B-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 170; + signature = 0x1e 0x93 0x83; +; + +#------------------------------------------------------------ +# AT90PWM216 +#------------------------------------------------------------ +# Completely identical to AT90PWM316 (including the signature!) + +part parent ".classic" # pwm216 + desc = "AT90PWM216"; + id = "pwm216"; + variants = + "AT90PWM216: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM216-16SU: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM216-16SUR: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 179; + n_interrupts = 32; + n_boot_sections = 4; + boot_section_size = 512; + stk500_devcode = 0x65; + chip_erase_delay = 9000; + pagel = 0xd8; + bs2 = 0xe2; + signature = 0x1e 0x94 0x83; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x4000; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xf9; + bitmask = 0xf7; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 1024; + ; +; + +#------------------------------------------------------------ +# AT90PWM316 +#------------------------------------------------------------ + +# Similar to AT90PWM3B, but with 16 kiB flash, 512 B EEPROM, and 1024 B SRAM. + +part parent "pwm216" # pwm316 + desc = "AT90PWM316"; + id = "pwm316"; + variants = + "AT90PWM316: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90PWM316-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "AT90PWM316-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 180; +; + +#------------------------------------------------------------ +# AT90USB646 +#------------------------------------------------------------ + +part parent ".classic" # usb646 + desc = "AT90USB646"; + id = "usb646"; + variants = + "AT90USB646: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90USB646-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB646-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB646-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB646-MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 181; + n_interrupts = 38; + n_boot_sections = 4; + boot_section_size = 1024; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + signature = 0x1e 0x96 0x82; + usbpid = 0x2ff9; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 3; + + memory "eeprom" + size = 2048; + page_size = 8; + min_write_delay = 9000; + max_write_delay = 9000; + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x10000; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x5e; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0x9b; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xf3; + bitmask = 0x0f; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# AT90USB647 +#------------------------------------------------------------ +# identical to AT90USB646 + +part parent "usb646" # usb647 + desc = "AT90USB647"; + id = "usb647"; + variants = + "AT90USB647: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90USB647-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB647-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB647-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB647-MUR: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 182; +; + +#------------------------------------------------------------ +# AT90USB1286 +#------------------------------------------------------------ + +part parent "usb646" # usb1286 + desc = "AT90USB1286"; + id = "usb1286"; + variants = + "AT90USB1286: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90USB1286-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB1286-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB1286-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB1286-MUR: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 184; + signature = 0x1e 0x97 0x82; + usbpid = 0x2ffb; + rampz = 0x3b; + + memory "eeprom" + size = 4096; + read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x20000; + num_pages = 512; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "hfuse" + initval = 0x99; + ; + + memory "sram" + size = 8192; + ; +; + +#------------------------------------------------------------ +# AT90USB1287 +#------------------------------------------------------------ +# identical to AT90USB1286 + +part parent "usb646" # usb1287 + desc = "AT90USB1287"; + id = "usb1287"; + variants = + "AT90USB1287: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90USB1287-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB1287-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB1287-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB1287-MUR: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 185; + signature = 0x1e 0x97 0x82; + usbpid = 0x2ffb; + rampz = 0x3b; + + memory "eeprom" + size = 4096; + read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x20000; + num_pages = 512; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "hfuse" + initval = 0x99; + ; + + memory "sram" + size = 8192; + ; +; + +#------------------------------------------------------------ +# AT90USB82 +#------------------------------------------------------------ + +part parent ".classic" # usb82 + desc = "AT90USB82"; + id = "usb82"; + variants = + "AT90USB82: QFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90USB82-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB82-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 174; + n_interrupts = 29; + n_boot_sections = 4; + boot_section_size = 512; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xc6; + signature = 0x1e 0x93 0x82; + usbpid = 0x2ff7; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.aaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--0000.aaaa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x5e; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xd9; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xf4; + bitmask = 0x0f; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# AT90USB162 +#------------------------------------------------------------ + +part parent "usb82" # usb162 + desc = "AT90USB162"; + id = "usb162"; + variants = + "AT90USB162: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "AT90USB162-16AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB162-16AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB162-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "AT90USB162-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 178; + signature = 0x1e 0x94 0x82; + usbpid = 0x2ffa; + + memory "flash" + size = 0x4000; + num_pages = 128; ; ; @@ -4026,7 +7847,7 @@ part parent "89S51" # 89S52 # AT90S1200 #------------------------------------------------------------ -part # 1200 +part parent ".classic-nocal" # 1200 desc = "AT90S1200"; id = "1200"; variants = @@ -4120,17 +7941,15 @@ part # 1200 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x06; min_write_delay = 9000; max_write_delay = 20000; + read = NULL; write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; ; - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; + memory "io" + size = 64; ; memory "sram" @@ -4139,11 +7958,366 @@ part # 1200 ; ; +#------------------------------------------------------------ +# AT90S2313 +#------------------------------------------------------------ + +part parent ".classic-nocal" # 2313 + desc = "AT90S2313"; + id = "2313"; + variants = + "AT90S2313-10PC: DIP20, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S2313-10PI: DIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", + "AT90S2313-10SC: SOIC20, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S2313-10SI: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", + "AT90S2313-4PC: DIP20, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 6 V]", + "AT90S2313-4PI: DIP20, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]", + "AT90S2313-4SC: SOIC20, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 6 V]", + "AT90S2313-4SI: SOIC20, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP; + mcuid = 186; + n_interrupts = 11; + stk500_devcode = 0x40; + avr910_devcode = 0x20; + chip_erase_delay = 20000; + signature = 0x1e 0x91 0x01; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + programfusepulsewidth = 2; + programlockpolltimeout = 1; + factory_fcpu = 1000000; + chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; + pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + + memory "eeprom" + size = 128; + min_write_delay = 4000; + max_write_delay = 9000; + readback = 0x80 0x7f; + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + read = "1010.0000--xxxx.xxxx--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + size = 2048; + min_write_delay = 4000; + max_write_delay = 9000; + readback = 0x7f 0x7f; + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + write_lo = "0100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + write_hi = "0100.1000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + ; + + memory "fuse" + size = 1; + initval = 0xdf; + bitmask = 0x21; + ; + + memory "lock" + bitmask = 0x06; + min_write_delay = 9000; + max_write_delay = 9000; + read = NULL; + write = "1010.1100--111x.xiix--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 128; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# AT90S2323 +#------------------------------------------------------------ + +part parent ".classic-nocal" # 2323 + desc = "AT90S2323"; + id = "2323"; + variants = + "AT90S2323-10PC: DIP8, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S2323-10PI: DIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", + "AT90S2323-10SC: SOIC8, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S2323-10SI: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVSP; + mcuid = 187; + n_interrupts = 3; + stk500_devcode = 0x41; + avr910_devcode = 0x48; + chip_erase_delay = 18000; + signature = 0x1e 0x91 0x02; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + hvsp_controlstack = + 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x00, + 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, + 0x78, 0x00, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, + 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; + hventerstabdelay = 100; + latchcycles = 1; + poweroffdelay = 25; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + synchcycles = 6; + factory_fcpu = 1000000; + chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; + pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback = 0x00 0xff; + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + read = "1010.0000--0000.0000--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.0000--xaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback = 0xff 0xff; + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 128; + read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + write_lo = "0100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + write_hi = "0100.1000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + ; + + memory "fuse" + size = 1; + initval = 0xde; + bitmask = 0x21; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxox.xxxo"; + write = "1010.1100--1011.111i--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "lock" + bitmask = 0x06; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0 1 0 1 1 0 0 0 x x x x x x x x x x x x x x x x o1 o2 x x x x x x"; + write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 128; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# AT90S2343 (also AT90S2323 and ATtiny22) +#------------------------------------------------------------ + +part parent "2323" # 2343 + desc = "AT90S2343"; + id = "2343"; + variants = + "AT90S2343-10PC: DIP8, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S2343-10PI: DIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", + "AT90S2343-10SC: SOIC8, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S2343-10SI: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; + mcuid = 189; + stk500_devcode = 0x43; + avr910_devcode = 0x4c; + signature = 0x1e 0x91 0x03; +; + +#------------------------------------------------------------ +# AT90S2333 +#------------------------------------------------------------ + +part parent ".classic-nocal" # 2333 + desc = "AT90S2333"; + id = "2333"; + variants = + "AT90S2333-8AC: TQFP32, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S2333-8AI: TQFP32, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", + "AT90S2333-8PC: DIP28, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S2333-8PI: DIP28, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP; + mcuid = 188; + n_interrupts = 14; + stk500_devcode = 0x42; + avr910_devcode = 0x34; + chip_erase_delay = 20000; + signature = 0x1e 0x91 0x05; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + programfusepulsewidth = 2; + programlockpolltimeout = 1; + factory_fcpu = 1000000; + chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; + pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback = 0x00 0xff; + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + read = "1010.0000--xxxx.xxxx--xaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback = 0xff 0xff; + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + write_lo = "0100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + write_hi = "0100.1000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + ; + + memory "fuse" + size = 1; + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0101.0000--xxxx.xxxx--xxxx.xxxx--xxoo.oooo"; + write = "1010.1100--101i.iiii--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "lock" + initval = -1; + bitmask = 0x06; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xoox"; + write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 128; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# AT90S4433 +#------------------------------------------------------------ + +part parent "2333" # 4433 + desc = "AT90S4433"; + id = "4433"; + variants = + "AT90S4433-8AC: TQFP32, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S4433-8AI: TQFP32, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", + "AT90S4433-8PC: DIP28, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S4433-8PI: DIP28, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; + mcuid = 191; + stk500_devcode = 0x51; + avr910_devcode = 0x30; + signature = 0x1e 0x92 0x03; + + memory "eeprom" + size = 256; + read = "1010.0000--xxxx.xxxx--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxx--aaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + size = 4096; + read_lo = "0010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + write_lo = "0100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; + write_hi = "0100.1000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; + ; + + memory "fuse" + initval = 0xda; + ; + + memory "lock" + initval = 0xff; + ; +; + #------------------------------------------------------------ # AT90S4414 #------------------------------------------------------------ -part # 4414 +part parent ".classic-nocal" # 4414 desc = "AT90S4414"; id = "4414"; variants = @@ -4223,17 +8397,15 @@ part # 4414 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x06; min_write_delay = 9000; max_write_delay = 9000; + read = NULL; write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; ; - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; + memory "io" + size = 64; ; memory "sram" @@ -4242,582 +8414,42 @@ part # 4414 ; ; -#------------------------------------------------------------ -# AT90S2313 -#------------------------------------------------------------ - -part # 2313 - desc = "AT90S2313"; - id = "2313"; - variants = - "AT90S2313-10PC: DIP20, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S2313-10PI: DIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", - "AT90S2313-10SC: SOIC20, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S2313-10SI: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", - "AT90S2313-4PC: DIP20, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 6 V]", - "AT90S2313-4PI: DIP20, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]", - "AT90S2313-4SC: SOIC20, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 6 V]", - "AT90S2313-4SI: SOIC20, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP; - mcuid = 186; - n_interrupts = 11; - stk500_devcode = 0x40; - avr910_devcode = 0x20; - chip_erase_delay = 20000; - signature = 0x1e 0x91 0x01; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - programfusepulsewidth = 2; - programlockpolltimeout = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 128; - min_write_delay = 4000; - max_write_delay = 9000; - readback = 0x80 0x7f; - mode = 0x04; - delay = 12; - blocksize = 64; - readsize = 256; - read = "1010.0000--xxxx.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - size = 2048; - min_write_delay = 4000; - max_write_delay = 9000; - readback = 0x7f 0x7f; - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - write_lo = "0100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; - write_hi = "0100.1000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; - ; - - memory "fuse" - size = 1; - initval = 0xdf; - bitmask = 0x21; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x06; - min_write_delay = 9000; - max_write_delay = 9000; - write = "1010.1100--111x.xiix--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "sram" - size = 128; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# AT90S2333 -#------------------------------------------------------------ - -part # 2333 -##### WARNING: No XML file for device 'AT90S2333'! ##### - desc = "AT90S2333"; - id = "2333"; - variants = - "AT90S2333-8AC: TQFP32, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S2333-8AI: TQFP32, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", - "AT90S2333-8PC: DIP28, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S2333-8PI: DIP28, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP; - mcuid = 188; - n_interrupts = 14; - stk500_devcode = 0x42; - avr910_devcode = 0x34; - chip_erase_delay = 20000; - signature = 0x1e 0x91 0x05; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - programfusepulsewidth = 2; - programlockpolltimeout = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 128; - min_write_delay = 9000; - max_write_delay = 20000; - readback = 0x00 0xff; - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - read = "1010.0000--xxxx.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - size = 2048; - min_write_delay = 9000; - max_write_delay = 20000; - readback = 0xff 0xff; - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - write_lo = "0100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; - write_hi = "0100.1000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; - ; - - memory "fuse" - size = 1; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 20000; - pwroff_after_write = yes; - read = "0101.0000--xxxx.xxxx--xxxx.xxxx--xxoo.oooo"; - write = "1010.1100--101i.iiii--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "lock" - size = 1; - bitmask = 0x06; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xoox"; - write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "sram" - size = 128; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# AT90S2343 (also AT90S2323 and ATtiny22) -#------------------------------------------------------------ - -part # 2343 - desc = "AT90S2343"; - id = "2343"; - variants = - "AT90S2343-10PC: DIP8, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S2343-10PI: DIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", - "AT90S2343-10SC: SOIC8, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S2343-10SI: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVSP; - mcuid = 189; - n_interrupts = 3; - stk500_devcode = 0x43; - avr910_devcode = 0x4c; - chip_erase_delay = 18000; - signature = 0x1e 0x91 0x03; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x00, - 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, - 0x78, 0x00, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - latchcycles = 1; - poweroffdelay = 25; - resetdelayus = 50; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 128; - min_write_delay = 9000; - max_write_delay = 20000; - readback = 0x00 0xff; - mode = 0x04; - delay = 12; - blocksize = 64; - readsize = 256; - read = "1010.0000--0000.0000--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.0000--xaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - size = 2048; - min_write_delay = 9000; - max_write_delay = 20000; - readback = 0xff 0xff; - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 128; - read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - write_lo = "0100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; - write_hi = "0100.1000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; - ; - - memory "fuse" - size = 1; - initval = 0xde; - bitmask = 0x21; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxox.xxxo"; - write = "1010.1100--1011.111i--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x06; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0 1 0 1 1 0 0 0 x x x x x x x x x x x x x x x x o1 o2 x x x x x x"; - write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "sram" - size = 128; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# AT90S2323 -#------------------------------------------------------------ - -part parent "2343" # 2323 - desc = "AT90S2323"; - id = "2323"; - variants = - "AT90S2323-10PC: DIP8, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S2323-10PI: DIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", - "AT90S2323-10SC: SOIC8, Fmax=10 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S2323-10SI: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; - mcuid = 187; - stk500_devcode = 0x41; - avr910_devcode = 0x48; - signature = 0x1e 0x91 0x02; -; - -#------------------------------------------------------------ -# ATtiny22 -#------------------------------------------------------------ - -part parent "2343" # t22 - desc = "ATtiny22"; - id = "t22"; - variants = - "ATtiny22L-1PC: DIP8, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 6 V]", - "ATtiny22L-1PI: DIP8, Fmax=1 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]", - "ATtiny22L-1SC: SOIC8, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 6 V]", - "ATtiny22L-1SI: SOIC8, Fmax=1 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]"; - mcuid = 13; - stk500_devcode = 0x20; - avr910_devcode = 0x00; # Unknown - signature = 0x1e 0x91 0x06; - - memory "fuse" - initval = -1; - ; -; - -#------------------------------------------------------------ -# AT90S4433 -#------------------------------------------------------------ - -part parent "2333" # 4433 - desc = "AT90S4433"; - id = "4433"; - variants = - "AT90S4433-8AC: TQFP32, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S4433-8AI: TQFP32, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", - "AT90S4433-8PC: DIP28, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S4433-8PI: DIP28, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; - mcuid = 191; - stk500_devcode = 0x51; - avr910_devcode = 0x30; - signature = 0x1e 0x92 0x03; - - memory "eeprom" - size = 256; - read = "1010.0000--xxxx.xxxx--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxx--aaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - size = 4096; - read_lo = "0010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; - write_lo = "0100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; - write_hi = "0100.1000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; - ; - - memory "fuse" - initval = 0xda; - ; - - memory "lock" - initval = 0xff; - ; -; - #------------------------------------------------------------ # AT90S8515 #------------------------------------------------------------ -part # 8515 +part parent "4414" # 8515 desc = "AT90S8515"; id = "8515"; variants = "AT90S8515-8PC: DIP40, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 193; - n_interrupts = 13; stk500_devcode = 0x60; avr910_devcode = 0x38; - chip_erase_delay = 20000; signature = 0x1e 0x93 0x01; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; pp_controlstack = 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - hvleavestabdelay = 15; resetdelay = 15; - chiperasepulsewidth = 15; - programfusepulsewidth = 2; - programlockpolltimeout = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 512; min_write_delay = 4000; max_write_delay = 9000; - readback = 0x80 0x7f; - mode = 0x04; - delay = 12; blocksize = 128; - readsize = 256; - read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; ; memory "flash" size = 8192; min_write_delay = 4000; max_write_delay = 9000; - readback = 0x7f 0x7f; - mode = 0x04; - delay = 12; blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - write_lo = "0100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - write_hi = "0100.1000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - ; - - memory "fuse" - size = 1; - initval = 0xdf; - bitmask = 0x21; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x06; - min_write_delay = 9000; - max_write_delay = 9000; - write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; ; memory "sram" size = 512; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# AT90S8535 -#------------------------------------------------------------ - -part # 8535 - desc = "AT90S8535"; - id = "8535"; - variants = - "AT90S8535-8AC: TQFP44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S8535-8AI: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", - "AT90S8535-8JC: LCC44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S8535-8JI: LCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", - "AT90S8535-8PC: DIP40, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", - "AT90S8535-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP; - mcuid = 195; - n_interrupts = 17; - stk500_devcode = 0x61; - avr910_devcode = 0x68; - chip_erase_delay = 20000; - signature = 0x1e 0x93 0x03; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - programfusepulsewidth = 2; - programlockpolltimeout = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - min_write_delay = 9000; - max_write_delay = 20000; - readback = 0x00 0xff; - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - size = 8192; - min_write_delay = 9000; - max_write_delay = 20000; - readback = 0xff 0xff; - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - write_lo = "0100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - write_hi = "0100.1000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - ; - - memory "fuse" - size = 1; - initval = 0xdf; - bitmask = 0x21; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxox.xxxo"; - write = "1010.1100--1011.111i--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x06; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0 1 0 1 1 0 0 0 x x x x x x x x x x x x x x x x o1 o2 x x x x x x"; - write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "sram" - size = 512; - offset = 0x60; ; ; @@ -4825,10 +8457,7 @@ part # 8535 # AT90S4434 #------------------------------------------------------------ -# No XML file for device AT90S4434, so parenting off AT90S8535 -# with which it shares the datasheet. - -part parent "8535" # 4434 +part parent ".classic-nocal" # 4434 desc = "AT90S4434"; id = "4434"; variants = @@ -4838,19 +8467,57 @@ part parent "8535" # 4434 "AT90S4434-8JI: LCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", "AT90S4434-8PC: DIP40, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", "AT90S4434-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 192; + n_interrupts = 17; stk500_devcode = 0x52; avr910_devcode = 0x6c; + chip_erase_delay = 20000; signature = 0x1e 0x92 0x02; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + programfusepulsewidth = 2; + programlockpolltimeout = 1; + factory_fcpu = 1000000; + chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; + pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback = 0x00 0xff; + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; read = "1010.0000--xxxx.xxxx--aaaa.aaaa--oooo.oooo"; write = "1100.0000--xxxx.xxxx--aaaa.aaaa--iiii.iiii"; ; memory "flash" size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback = 0xff 0xff; + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; read_lo = "0010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; read_hi = "0010.1000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; write_lo = "0100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; @@ -4858,15 +8525,76 @@ part parent "8535" # 4434 ; memory "fuse" + size = 1; + initval = 0xdf; + bitmask = 0x21; + min_write_delay = 9000; max_write_delay = 20000; + read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxox.xxxo"; + write = "1010.1100--1011.111i--xxxx.xxxx--xxxx.xxxx"; ; memory "lock" + bitmask = 0x06; + min_write_delay = 9000; max_write_delay = 20000; + read = "0 1 0 1 1 0 0 0 x x x x x x x x x x x x x x x x o1 o2 x x x x x x"; + write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; + ; + + memory "io" + size = 64; ; memory "sram" size = 256; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# AT90S8535 +#------------------------------------------------------------ + +part parent "4434" # 8535 + desc = "AT90S8535"; + id = "8535"; + variants = + "AT90S8535-8AC: TQFP44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S8535-8AI: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", + "AT90S8535-8JC: LCC44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S8535-8JI: LCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]", + "AT90S8535-8PC: DIP40, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 6 V]", + "AT90S8535-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 6 V]"; + mcuid = 195; + stk500_devcode = 0x61; + avr910_devcode = 0x68; + signature = 0x1e 0x93 0x03; + + memory "eeprom" + size = 512; + read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + size = 8192; + read_lo = "0010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + write_lo = "0100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; + write_hi = "0100.1000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; + ; + + memory "fuse" + max_write_delay = 9000; + ; + + memory "lock" + max_write_delay = 9000; + ; + + memory "sram" + size = 512; ; ; @@ -4874,7 +8602,7 @@ part parent "8535" # 4434 # ATmega103 #------------------------------------------------------------ -part # m103 +part parent ".classic-nocal" # m103 desc = "ATmega103"; id = "m103"; variants = @@ -4956,8 +8684,6 @@ part # m103 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x06; min_write_delay = 9000; max_write_delay = 9000; @@ -4965,9 +8691,8 @@ part # m103 write = "1010.1100--1111.1ii1--xxxx.xxxx--xxxx.xxxx"; ; - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; + memory "io" + size = 64; ; memory "sram" @@ -4976,3028 +8701,11 @@ part # m103 ; ; -#------------------------------------------------------------ -# ATmega64 -#------------------------------------------------------------ - -part # m64 - desc = "ATmega64"; - id = "m64"; - variants = - "ATmega64: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega64-16AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", - "ATmega64-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.2 V, 5.5 V]", - "ATmega64-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.2 V, 5.5 V]", - "ATmega64-16MN: QFN64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", - "ATmega64-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega64-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega64L-8AN: TQFP64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8AQ: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8AQR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8MN: QFN64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8MQ: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8MQR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8MU: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64L-8MUR: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; - mcuid = 72; - n_interrupts = 35; - n_boot_sections = 4; - boot_section_size = 1024; - stk500_devcode = 0xa0; - avr910_devcode = 0x45; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x96 0x02; - reset = io; - allowfullpagebitstream = yes; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x22; - spmcr = 0x68; - eecr = 0x3c; - ocdrev = 2; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 2048; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - readback = 0xff 0xff; - mode = 0x04; - delay = 20; - blocksize = 64; - readsize = 256; - read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - paged = yes; - size = 0x10000; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback = 0xff 0x00; - mode = 0x21; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--xaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xe1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xfd; - bitmask = 0x03; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 4; - read = "0011.1000--xxxx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega64A -#------------------------------------------------------------ - -part parent "m64" # m64a - desc = "ATmega64A"; - id = "m64a"; - variants = - "ATmega64A-AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64A-ANR: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64A-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64A-MN: QFN64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64A-MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64A-MUR: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 73; -; - -#------------------------------------------------------------ -# ATmega128 -#------------------------------------------------------------ - -part # m128 - desc = "ATmega128"; - id = "m128"; - variants = - "ATmega128-16AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", - "ATmega128-16ANR: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", - "ATmega128-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega128-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega128-16MN: MLF64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", - "ATmega128-16MNR: MLF64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega128-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega128-16MUR: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega128L-8AN: TQFP64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[3 V, 5.5 V]", - "ATmega128L-8ANR: TQFP64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[3 V, 5.5 V]", - "ATmega128L-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128L-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128L-8MN: MLF64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[3 V, 5.5 V]", - "ATmega128L-8MNR: MLF64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega128L-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128L-8MUR: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; - mcuid = 85; - n_interrupts = 35; - n_boot_sections = 4; - boot_section_size = 1024; - stk500_devcode = 0xb2; - avr910_devcode = 0x43; - chip_erase_delay = 10000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x97 0x02; - reset = io; - allowfullpagebitstream = yes; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x22; - rampz = 0x3b; - spmcr = 0x68; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 4096; - page_size = 8; - min_write_delay = 10000; - max_write_delay = 10000; - readback = 0xff 0xff; - mode = 0x04; - delay = 20; - blocksize = 64; - readsize = 256; - read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - paged = yes; - size = 0x20000; - page_size = 256; - num_pages = 512; - min_write_delay = 5000; - max_write_delay = 5000; - readback = 0xff 0x00; - mode = 0x21; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xe1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xfd; - bitmask = 0x03; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 4; - read = "0011.1000--xxxx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega128A -#------------------------------------------------------------ - -part parent "m128" # m128a - desc = "ATmega128A"; - id = "m128a"; - variants = - "ATmega128A: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega128A-AN: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128A-ANR: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128A-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128A-MN: VQFN64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128A-MNR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega128A-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega128A-MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 86; -; - -#------------------------------------------------------------ -# AT90CAN128 -#------------------------------------------------------------ - -part # c128 - desc = "AT90CAN128"; - id = "c128"; - variants = - "AT90CAN128: N/A, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, N/A]", - "AT90CAN128-15AZ: TQFP64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN128-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN128-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN128-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN128-16MI: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN128-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN128-16MUR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; - mcuid = 176; - n_interrupts = 37; - n_boot_sections = 4; - boot_section_size = 1024; - stk500_devcode = 0xb3; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; -# avr910_devcode = 0x43; - signature = 0x1e 0x97 0x81; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - rampz = 0x3b; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 4096; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 8; - readsize = 256; - read = "1010.0000--000x.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x20000; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# AT90CAN64 -#------------------------------------------------------------ - -part # c64 - desc = "AT90CAN64"; - id = "c64"; - variants = - "AT90CAN64: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90CAN64-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN64-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN64-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN64-16MI: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN64-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN64-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 172; - n_interrupts = 37; - n_boot_sections = 4; - boot_section_size = 1024; - stk500_devcode = 0xb3; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; -# avr910_devcode = 0x43; - signature = 0x1e 0x96 0x81; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 2048; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 8; - readsize = 256; - read = "1010.0000--000x.xaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x10000; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# AT90CAN32 -#------------------------------------------------------------ - -part # c32 - desc = "AT90CAN32"; - id = "c32"; - variants = - "AT90CAN32: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90CAN32-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN32-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN32-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN32-16MI: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN32-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90CAN32-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 171; - n_interrupts = 37; - n_boot_sections = 4; - boot_section_size = 1024; - stk500_devcode = 0xb3; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; -# avr910_devcode = 0x43; - signature = 0x1e 0x95 0x81; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 1024; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 8; - readsize = 256; - read = "1010.0000--000x.xxaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.xxaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x8000; - page_size = 256; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 2048; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega16 -#------------------------------------------------------------ - -part # m16 - desc = "ATmega16"; - id = "m16"; - variants = - "ATmega16: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega16-16AQR: TQFP44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega16-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega16-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega16-16MQ: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega16-16MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega16-16MUR: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega16-16PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega16L-8AQ: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16L-8AQR: TQFP44, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega16L-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16L-8AUR: TQFP44, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega16L-8MU: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16L-8MUR: VQFN44, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega16L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; - mcuid = 49; - n_interrupts = 21; - n_boot_sections = 4; - boot_section_size = 256; - stk500_devcode = 0x82; - avr910_devcode = 0x74; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x94 0x03; - reset = io; - allowfullpagebitstream = yes; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 2; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 9000; - max_write_delay = 9000; - readback = 0xff 0xff; - mode = 0x04; - delay = 20; - blocksize = 128; - readsize = 256; - read = "1010.0000--00xx.xxaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.xxaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback = 0xff 0x00; - mode = 0x21; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xe1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 4; - read = "0011.1000--000x.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 1024; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATmega16A -#------------------------------------------------------------ - -part parent "m16" # m16a - desc = "ATmega16A"; - id = "m16a"; - variants = - "ATmega16A: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega16A-AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16A-AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16A-MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16A-MUR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega16A-PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 50; -; - -#------------------------------------------------------------ -# ATmega324P -#------------------------------------------------------------ - -part # m324p - desc = "ATmega324P"; - id = "m324p"; - variants = - "ATmega324P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega324P-20AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20AQ: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20AQR: TQFP44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20MN: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20MQR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324P-20PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega324PV-10AN: TQFP44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PV-10AU: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PV-10AUR: TQFP44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega324PV-10MN: VQFN44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PV-10MU: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PV-10PN: PDIP40, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PV-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 111; - n_interrupts = 31; - n_boot_sections = 4; - boot_section_size = 512; - stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one - avr910_devcode = 0x74; - chip_erase_delay = 55000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x95 0x08; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 1024; - page_size = 4; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--00xx.xaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.xaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xaaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x8000; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--0aaa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 2048; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega164P -#------------------------------------------------------------ - -part parent "m324p" # m164p - desc = "ATmega164P"; - id = "m164p"; - variants = - "ATmega164P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega164P-20AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20AQ: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20MN: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20MQ: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20PQ: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164P-20PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega164PV-10AN: TQFP44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PV-10AQ: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PV-10AU: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PV-10AUR: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PV-10MU: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PV-10MUR: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PV-10PN: PDIP40, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PV-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 93; - boot_section_size = 256; - signature = 0x1e 0x94 0x0a; - - memory "eeprom" - size = 512; - delay = 20; - ; - - memory "flash" - size = 0x4000; - num_pages = 128; - ; - - memory "sram" - size = 1024; - ; -; - -#------------------------------------------------------------ -# ATmega164PA -#------------------------------------------------------------ - -part parent "m164p" # m164pa - desc = "ATmega164PA"; - id = "m164pa"; - variants = - "ATmega164PA: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-ANR: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-CU: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-CUR: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-MCH: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-MCHR: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-MN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-MNR: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164PA-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 94; -; - -#------------------------------------------------------------ -# ATmega164A -#------------------------------------------------------------ - -part parent "m164p" # m164a - desc = "ATmega164A"; - id = "m164a"; - variants = - "ATmega164A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-CU: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-CUR: VFBGA49, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-MCH: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-MCHR: QFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-MU: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-MUR: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega164A-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 92; - signature = 0x1e 0x94 0x0f; -; - -#------------------------------------------------------------ -# ATmega324PB -#------------------------------------------------------------ - -part parent "m324p" # m324pb - desc = "ATmega324PB"; - id = "m324pb"; - variants = - "ATmega324PB-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PB-ANR: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PB-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PB-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PB-MN: QFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PB-MNR: QFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PB-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PB-MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 113; - n_interrupts = 51; - signature = 0x1e 0x95 0x17; - - memory "efuse" - initval = 0x07; - bitmask = 0x0f; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.iiii"; - ; - - memory "prodsig" - size = 24; - read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; - ; - - memory "sigrow" - alias "prodsig"; - ; - - memory "sernum" - size = 10; - offset = 0xe; # Sub-region of prodsig - read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; - ; -; - -#------------------------------------------------------------ -# ATmega324PA -#------------------------------------------------------------ - -part parent "m324p" # m324pa - desc = "ATmega324PA"; - id = "m324pa"; - variants = - "ATmega324PA: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-CU: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-MCH: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-MCHR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-MN: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-MNR: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324PA-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 112; - signature = 0x1e 0x95 0x11; -; - -#------------------------------------------------------------ -# ATmega324A -#------------------------------------------------------------ - -part parent "m324p" # m324a - desc = "ATmega324A"; - id = "m324a"; - variants = - "ATmega324A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega324A-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324A-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324A-CU: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324A-MCH: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324A-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega324A-MUR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega324A-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 110; - signature = 0x1e 0x95 0x15; -; - -#------------------------------------------------------------ -# ATmega644 -#------------------------------------------------------------ - -part # m644 - desc = "ATmega644"; - id = "m644"; - variants = - "ATmega644: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega644-20AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644-20AUR: TQFP44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega644-20MU: MLF44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644-20MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644-20PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644V-10AU: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644V-10AUR: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644V-10MU: MLF44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644V-10MUR: VQFN44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644V-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 127; - n_interrupts = 28; - n_boot_sections = 4; - boot_section_size = 1024; - stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one - avr910_devcode = 0x74; - chip_erase_delay = 55000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x96 0x09; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; - hventerstabdelay = 100; - latchcycles = 6; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 2048; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - read = "1010.0000--00xx.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x10000; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--00xx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--00xx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega644A -#------------------------------------------------------------ - -part parent "m644" # m644a - desc = "ATmega644A"; - id = "m644a"; - variants = - "ATmega644A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644A-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644A-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644A-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644A-MUR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644A-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 128; - n_interrupts = 31; -; - -#------------------------------------------------------------ -# ATmega644P -#------------------------------------------------------------ - -part parent "m644" # m644p - desc = "ATmega644P"; - id = "m644p"; - variants = - "ATmega644P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega644P-20AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20AQ: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20AQR: TQFP44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20MN: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20MQ: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20MQR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20MUR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20PQ: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644P-20PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega644PV-10AN: TQFP44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10AQ: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10AQR: TQFP44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10AU: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10AUR: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10MN: VQFN44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10MQ: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10MQR: VQFN44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10MU: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10MUR: VQFN44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10PN: PDIP40, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10PQ: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PV-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 129; - n_interrupts = 31; - signature = 0x1e 0x96 0x0a; -; - -#------------------------------------------------------------ -# ATmega644PA -#------------------------------------------------------------ - -part parent "m644" # m644pa - desc = "ATmega644PA"; - id = "m644pa"; - variants = - "ATmega644PA-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-ANR: TQFP44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-MN: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-MNR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-MU: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-MUR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega644PA-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 130; - n_interrupts = 31; - signature = 0x1e 0x96 0x0a; -; - -#------------------------------------------------------------ -# ATmega1284 -#------------------------------------------------------------ - -part # m1284 - desc = "ATmega1284"; - id = "m1284"; - variants = - "ATmega1284-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284-MU: MLF44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284-MUR: MLF44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega1284-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 140; - n_interrupts = 35; - n_boot_sections = 4; - boot_section_size = 1024; - stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one - avr910_devcode = 0x74; - chip_erase_delay = 55000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x97 0x06; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; - hventerstabdelay = 100; - latchcycles = 6; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - rampz = 0x3b; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 4096; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 128; - read = "1010.0000--00xx.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x20000; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 128; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--00xx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--00xx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 0x4000; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega1284P -#------------------------------------------------------------ - -part parent "m1284" # m1284p - desc = "ATmega1284P"; - id = "m1284p"; - variants = - "ATmega1284P-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284P-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284P-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284P-MN: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284P-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284P-MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284P-PN: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1284P-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 141; - signature = 0x1e 0x97 0x05; -; - -#------------------------------------------------------------ -# ATmega162 -#------------------------------------------------------------ - -part # m162 - desc = "ATmega162"; - id = "m162"; - variants = - "ATmega162: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega162-16AC: TQFP44, Fmax=16 MHz, T=[0 C, 70 C], Vcc=[4.5 V, 5.5 V]", - "ATmega162-16AI: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16AJ: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16MC: VFQFN44, Fmax=16 MHz, T=[0 C, 70 C], Vcc=[4.5 V, 5.5 V]", - "ATmega162-16MI: VFQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16MJ: VFQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16MU: VFQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16MUR: VFQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16PC: DIP40, Fmax=16 MHz, T=[0 C, 70 C], Vcc=[4.5 V, 5.5 V]", - "ATmega162-16PI: DIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16PJ: DIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162-16PU: DIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162L-8AC: TQFP44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162L-8AI: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162L-8MC: VFQFN44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162L-8MI: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162L-8PC: DIP40, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162L-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega162V-1AC: TQFP44, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 3.6 V]", - "ATmega162V-1MC: VFQFN44, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 3.6 V]", - "ATmega162V-1PC: DIP40, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 3.6 V]", - "ATmega162V-8AI: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8AJ: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8AUR: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8MI: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8MJ: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8MU: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8MUR: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8PJ: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega162V-8PU: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; - mcuid = 90; - n_interrupts = 28; - n_boot_sections = 4; - boot_section_size = 256; - stk500_devcode = 0x83; - avr910_devcode = 0x63; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x94 0x04; - reset = io; - allowfullpagebitstream = yes; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x04; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 2; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--00xx.xxaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.xxaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 16000; - max_write_delay = 16000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 16000; - max_write_delay = 16000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x1e; - min_write_delay = 16000; - max_write_delay = 16000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--111i.iii1"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 16000; - max_write_delay = 16000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--00xx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--00xx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 1024; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega163 -#------------------------------------------------------------ - -part # m163 - desc = "ATmega163"; - id = "m163"; - variants = - "ATmega163-8AC: TQFP44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 5.5 V]", - "ATmega163-8AI: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", - "ATmega163-8PC: DIP40, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 5.5 V]", - "ATmega163-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", - "ATmega163L-4AC: TQFP44, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATmega163L-4AI: TQFP44, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega163L-4PC: DIP40, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATmega163L-4PI: DIP40, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP; - mcuid = 91; - n_interrupts = 18; - n_boot_sections = 4; - boot_section_size = 256; - stk500_devcode = 0x81; - avr910_devcode = 0x64; - chip_erase_delay = 32000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x94 0x02; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - hvleavestabdelay = 15; - chiperasepolltimeout = 30; - programfusepolltimeout = 2; - programlockpolltimeout = 2; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - min_write_delay = 4000; - max_write_delay = 4000; - readback = 0xff 0xff; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 128; - num_pages = 128; - min_write_delay = 16000; - max_write_delay = 16000; - readback = 0xff 0xff; - mode = 0x11; - delay = 20; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--xxxa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xdf; - bitmask = 0xef; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0101.0000--0000.0000--xxxx.xxxx--ooxx.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--ii11.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0101.1000--0000.1000--xxxx.xxxx--xxxx.1ooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--1111.1iii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0101.1000--0000.0000--xxxx.0xxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "sram" - size = 1024; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATmega169 -#------------------------------------------------------------ - -part # m169 - desc = "ATmega169"; - id = "m169"; - variants = - "ATmega169: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega169-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169-16MI: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169-16MU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169L-4AC: TQFP64, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169L-4MC: VFQFN64, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169L-8AI: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169L-8MI: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169V-1AC: TQFP64, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169V-1MC: VFQFN64, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169V-8AI: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169V-8MI: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169V-8MU: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; - mcuid = 104; - n_interrupts = 23; - n_boot_sections = 4; - boot_section_size = 256; - stk500_devcode = 0x85; - avr910_devcode = 0x78; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x94 0x05; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 2; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 9000; - max_write_delay = 9000; - readback = 0xff 0xff; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback = 0xff 0xff; - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--xxxa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x0f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "sram" - size = 1024; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega169A -#------------------------------------------------------------ - -part parent "m169" # m169a - desc = "ATmega169A"; - id = "m169a"; - variants = - "ATmega169A-AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169A-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169A-MCH: DRQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169A-MN: QFN64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169A-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169A-MUR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 105; - signature = 0x1e 0x94 0x11; - reset = io; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelay = 15; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - readback = 0x00 0x00; - ; - - memory "flash" - readback = 0x00 0x00; - delay = 10; - ; - - memory "io" - size = 224; - offset = 0x20; - ; -; - -#------------------------------------------------------------ -# ATmega169P -#------------------------------------------------------------ - -part parent "m169" # m169p - desc = "ATmega169P"; - id = "m169p"; - variants = - "ATmega169P: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega169P-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169P-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169P-16MCH: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169P-16MCHR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega169P-16MCU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169P-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega169P-16MUR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega169PV-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PV-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PV-8MCH: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PV-8MCHR: QFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega169PV-8MCU: VQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PV-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PV-8MUR: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 106; - reset = io; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelay = 15; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - readback = 0x00 0x00; - ; - - memory "flash" - readback = 0x00 0x00; - delay = 10; - ; - - memory "io" - size = 224; - offset = 0x20; - ; -; - -#------------------------------------------------------------ -# ATmega169PA -#------------------------------------------------------------ - -part parent "m169" # m169pa - desc = "ATmega169PA"; - id = "m169pa"; - variants = - "ATmega169PA-AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PA-ANR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PA-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PA-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PA-MCH: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PA-MCHR: QFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega169PA-MN: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PA-MNR: QFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega169PA-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega169PA-MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 107; - reset = io; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelay = 15; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - readback = 0x00 0x00; - ; - - memory "flash" - readback = 0x00 0x00; - delay = 10; - ; - - memory "io" - size = 224; - offset = 0x20; - ; -; - -#------------------------------------------------------------ -# ATmega329 -#------------------------------------------------------------ - -part # m329 - desc = "ATmega329"; - id = "m329"; - variants = - "ATmega329: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega329-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega329-16AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega329-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega329-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega329V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329V-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 121; - n_interrupts = 23; - n_boot_sections = 4; - boot_section_size = 512; -# stk500_devcode = 0x85; # no STK500 support, only STK500v2 -# avr910_devcode = 0x?; # try the ATmega169 one: - avr910_devcode = 0x75; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x95 0x03; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 1024; - page_size = 4; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x8000; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--xaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 2048; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega329A -#------------------------------------------------------------ - -part parent "m329" # m329a - desc = "ATmega329A"; - id = "m329a"; - variants = - "ATmega329A-AN: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329A-AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329A-AUR: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega329A-MN: QFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329A-MU: VQFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 122; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega329P -#------------------------------------------------------------ - -part parent "m329" # m329p - desc = "ATmega329P"; - id = "m329p"; - variants = - "ATmega329P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega329P-20AN: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329P-20ANR: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega329P-20AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega329P-20AUR: TQFP64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega329P-20MN: VQFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega329P-20MNR: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega329P-20MU: MLF64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega329P-20MUR: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega329PV-10AU: TQFP64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PV-10AUR: TQFP64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PV-10MN: VQFN64, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PV-10MU: MLF64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PV-10MUR: VQFN64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 123; - signature = 0x1e 0x95 0x0b; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega329PA -#------------------------------------------------------------ - -part parent "m329" # m329pa - desc = "ATmega329PA"; - id = "m329pa"; - variants = - "ATmega329PA-AN: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PA-AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PA-AUR: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PA-MN: QFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PA-MU: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega329PA-MUR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; - mcuid = 124; - signature = 0x1e 0x95 0x0b; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega3290 -#------------------------------------------------------------ - -part parent "m329" # m3290 - desc = "ATmega3290"; - id = "m3290"; - variants = - "ATmega3290: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega3290-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega3290-16AUR: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega3290V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega3290V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 150; - n_interrupts = 25; - signature = 0x1e 0x95 0x04; -; - -#------------------------------------------------------------ -# ATmega3290A -#------------------------------------------------------------ - -part parent "m329" # m3290a - desc = "ATmega3290A"; - id = "m3290a"; - variants = - "ATmega3290A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega3290A-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega3290A-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 151; - n_interrupts = 25; - signature = 0x1e 0x95 0x04; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega3290P -#------------------------------------------------------------ - -part parent "m329" # m3290p - desc = "ATmega3290P"; - id = "m3290p"; - variants = - "ATmega3290P: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega3290P-20AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega3290P-20AUR: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega3290PV-10AU: TQFP100, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega3290PV-10AUR: TQFP100, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 152; - n_interrupts = 25; - signature = 0x1e 0x95 0x0c; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega3290PA -#------------------------------------------------------------ - -part parent "m329" # m3290pa - desc = "ATmega3290PA"; - id = "m3290pa"; - variants = - "ATmega3290PA: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega3290PA-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega3290PA-AUR: TQFP100, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; - mcuid = 153; - n_interrupts = 25; - signature = 0x1e 0x95 0x0c; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega649 -#------------------------------------------------------------ - -part # m649 - desc = "ATmega649"; - id = "m649"; - variants = - "ATmega649: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega649-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega649-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega649-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega649-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega649V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega649V-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega649V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega649V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 135; - n_interrupts = 23; - n_boot_sections = 4; - boot_section_size = 1024; -# stk500_devcode = 0x85; # no STK500 support, only STK500v2 -# avr910_devcode = 0x?; # try the ATmega169 one: - avr910_devcode = 0x75; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x96 0x03; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 2048; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x10000; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega649A -#------------------------------------------------------------ - -part parent "m649" # m649a - desc = "ATmega649A"; - id = "m649a"; - variants = - "ATmega649A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega649A-AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega649A-MU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega649A-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 136; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega649P -#------------------------------------------------------------ - -part parent "m649" # m649p - desc = "ATmega649P"; - id = "m649p"; - variants = - "ATmega649P-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega649P-AUR: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega649P-MU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega649P-MUR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; - mcuid = 137; - signature = 0x1e 0x96 0x0b; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega6490 -#------------------------------------------------------------ - -part parent "m649" # m6490 - desc = "ATmega6490"; - id = "m6490"; - variants = - "ATmega6490: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega6490-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega6490-16AUR: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega6490V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega6490V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 157; - n_interrupts = 25; - signature = 0x1e 0x96 0x04; -; - -#------------------------------------------------------------ -# ATmega6490A -#------------------------------------------------------------ - -part parent "m649" # m6490a - desc = "ATmega6490A"; - id = "m6490a"; - variants = - "ATmega6490A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega6490A-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega6490A-AUR: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 158; - n_interrupts = 25; - signature = 0x1e 0x96 0x04; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega6490P -#------------------------------------------------------------ - -part parent "m649" # m6490p - desc = "ATmega6490P"; - id = "m6490p"; - variants = - "ATmega6490P: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega6490P-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega6490P-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 159; - n_interrupts = 25; - signature = 0x1e 0x96 0x0c; - - memory "eeprom" - min_write_delay = 3600; - max_write_delay = 3600; - ; -; - -#------------------------------------------------------------ -# ATmega32 -#------------------------------------------------------------ - -part # m32 - desc = "ATmega32"; - id = "m32"; - variants = - "ATmega32: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega32-16AQ: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega32-16AQR: TQFP44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega32-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega32-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega32-16MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega32-16MUR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega32-16PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega32L-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32L-8AUR: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32L-8MU: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32L-8MUR: VQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; - mcuid = 58; - n_interrupts = 21; - n_boot_sections = 4; - boot_section_size = 512; - stk500_devcode = 0x91; - avr910_devcode = 0x72; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x95 0x02; - reset = io; - allowfullpagebitstream = yes; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 2; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 1024; - page_size = 4; - min_write_delay = 9000; - max_write_delay = 9000; - readback = 0xff 0xff; - mode = 0x04; - delay = 20; - blocksize = 64; - readsize = 256; - read = "1010.0000--00xx.xxaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.xxaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x8000; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback = 0xff 0x00; - mode = 0x21; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xe1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 4; - read = "0011.1000--00xx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 2048; - offset = 0x60; - ; -; - #------------------------------------------------------------ # ATmega161 #------------------------------------------------------------ -part # m161 +part parent ".classic-nocal" # m161 desc = "ATmega161"; id = "m161"; variants = @@ -8085,18 +8793,13 @@ part # m161 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; min_write_delay = 2000; max_write_delay = 2000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; ; - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; + memory "io" + size = 64; ; memory "sram" @@ -8106,31 +8809,529 @@ part # m161 ; #------------------------------------------------------------ -# ATmega32A +# ATmega162 #------------------------------------------------------------ -part parent "m32" # m32a - desc = "ATmega32A"; - id = "m32a"; +part parent ".classic" # m162 + desc = "ATmega162"; + id = "m162"; variants = - "ATmega32A-AN: TQFP44, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-ANR: TQFP44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-MN: VQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-MNR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-MUR: VQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-PN: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32A-PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 59; + "ATmega162: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega162-16AC: TQFP44, Fmax=16 MHz, T=[0 C, 70 C], Vcc=[4.5 V, 5.5 V]", + "ATmega162-16AI: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16AJ: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16MC: VFQFN44, Fmax=16 MHz, T=[0 C, 70 C], Vcc=[4.5 V, 5.5 V]", + "ATmega162-16MI: VFQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16MJ: VFQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16MU: VFQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16MUR: VFQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16PC: DIP40, Fmax=16 MHz, T=[0 C, 70 C], Vcc=[4.5 V, 5.5 V]", + "ATmega162-16PI: DIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16PJ: DIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162-16PU: DIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162L-8AC: TQFP44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162L-8AI: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162L-8MC: VFQFN44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162L-8MI: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162L-8PC: DIP40, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162L-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega162V-1AC: TQFP44, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 3.6 V]", + "ATmega162V-1MC: VFQFN44, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 3.6 V]", + "ATmega162V-1PC: DIP40, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 3.6 V]", + "ATmega162V-8AI: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8AJ: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8AUR: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8MI: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8MJ: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8MU: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8MUR: VFQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8PJ: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega162V-8PU: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; + mcuid = 90; + n_interrupts = 28; + n_boot_sections = 4; + boot_section_size = 256; + stk500_devcode = 0x83; + avr910_devcode = 0x63; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + signature = 0x1e 0x94 0x04; + reset = io; + allowfullpagebitstream = yes; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 6; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x04; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 2; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 9000; + max_write_delay = 9000; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--00xx.xxaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x4000; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 16000; + max_write_delay = 16000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0x99; + min_write_delay = 16000; + max_write_delay = 16000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x1e; + min_write_delay = 16000; + max_write_delay = 16000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--111i.iii1"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 16000; + max_write_delay = 16000; + ; + + memory "sram" + size = 1024; + ; +; + +#------------------------------------------------------------ +# ATmega163 +#------------------------------------------------------------ + +part parent ".classic" # m163 + desc = "ATmega163"; + id = "m163"; + variants = + "ATmega163-8AC: TQFP44, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 5.5 V]", + "ATmega163-8AI: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", + "ATmega163-8PC: DIP40, Fmax=8 MHz, T=[0 C, 70 C], Vcc=[4 V, 5.5 V]", + "ATmega163-8PI: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", + "ATmega163L-4AC: TQFP44, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATmega163L-4AI: TQFP44, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega163L-4PC: DIP40, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATmega163L-4PI: DIP40, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP; + mcuid = 91; + n_interrupts = 18; + n_boot_sections = 4; + boot_section_size = 256; + stk500_devcode = 0x81; + avr910_devcode = 0x64; + chip_erase_delay = 32000; + pagel = 0xd7; + bs2 = 0xa0; + signature = 0x1e 0x94 0x02; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + hvleavestabdelay = 15; + chiperasepolltimeout = 30; + programfusepolltimeout = 2; + programlockpolltimeout = 2; + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 4000; + readback = 0xff 0xff; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + paged = yes; + size = 0x4000; + page_size = 128; + num_pages = 128; + min_write_delay = 16000; + max_write_delay = 16000; + readback = 0xff 0xff; + mode = 0x11; + delay = 20; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--xxxa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0xdf; + bitmask = 0xef; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0101.0000--0000.0000--xxxx.xxxx--ooxx.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--ii11.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xff; + bitmask = 0x07; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0101.1000--0000.1000--xxxx.xxxx--xxxx.1ooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--1111.1iii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 2000; + max_write_delay = 2000; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 1024; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# ATmega8515 +#------------------------------------------------------------ + +part parent ".classic" # m8515 + desc = "ATmega8515"; + id = "m8515"; + variants = + "ATmega8515: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega8515-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8515-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8515-16JU: PLCC44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8515-16JUR: PLCC44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8515-16MU: QFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8515-16MUR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega8515-16PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8515L-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8515L-8AUR: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8515L-8JU: PLCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8515L-8JUR: PLCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8515L-8MU: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8515L-8MUR: VQFN44, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega8515L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP; + mcuid = 160; + n_interrupts = 17; + n_boot_sections = 4; + boot_section_size = 256; + stk500_devcode = 0x63; + avr910_devcode = 0x3a; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + signature = 0x1e 0x93 0x06; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 6; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback = 0xff 0xff; + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback = 0xff 0x00; + mode = 0x21; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0xe1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xd9; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 4; + read = "0011.1000--00xx.xxxx--0000.00aa--oooo.oooo"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 512; + offset = 0x60; + ; +; + +#------------------------------------------------------------ +# ATmega8535 +#------------------------------------------------------------ + +part parent ".classic" # m8535 + desc = "ATmega8535"; + id = "m8535"; + variants = + "ATmega8535: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega8535-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8535-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8535-16JU: PLCC44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8535-16JUR: PLCC44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8535-16MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8535-16MUR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega8535-16PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega8535L-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8535L-8AUR: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8535L-8JU: PLCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8535L-8JUR: PLCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8535L-8MU: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8535L-8MUR: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8535L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP; + mcuid = 161; + n_interrupts = 21; + n_boot_sections = 4; + boot_section_size = 256; + stk500_devcode = 0x64; + avr910_devcode = 0x69; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + signature = 0x1e 0x93 0x08; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 6; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback = 0xff 0xff; + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback = 0xff 0x00; + mode = 0x21; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0xe1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xd9; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 4; + read = "0011.1000--00xx.xxxx--0000.00aa--oooo.oooo"; + ; + + memory "io" + size = 64; + ; + + memory "sram" + size = 512; + offset = 0x60; + ; ; #------------------------------------------------------------ # ATmega8 #------------------------------------------------------------ -part # m8 +part parent ".classic" # m8 desc = "ATmega8"; id = "m8"; variants = @@ -8186,9 +9387,6 @@ part # m8 chiperasepolltimeout = 20; programfusepolltimeout = 10; programlockpolltimeout = 10; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 512; @@ -8242,18 +9440,9 @@ part # m8 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; min_write_delay = 4500; max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--00xx.xxxx--xxxx.xxaa--oooo.oooo"; ; memory "calibration" @@ -8263,7 +9452,6 @@ part # m8 memory "io" size = 64; - offset = 0x20; ; memory "sram" @@ -8295,178 +9483,432 @@ part parent "m8" # m8a ; #------------------------------------------------------------ -# ATmega8515 +# ATmega16 #------------------------------------------------------------ -part # m8515 - desc = "ATmega8515"; - id = "m8515"; +part parent "m8" # m16 + desc = "ATmega16"; + id = "m16"; variants = - "ATmega8515: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega8515-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8515-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8515-16JU: PLCC44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8515-16JUR: PLCC44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8515-16MU: QFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8515-16MUR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega8515-16PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8515L-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8515L-8AUR: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8515L-8JU: PLCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8515L-8JUR: PLCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8515L-8MU: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8515L-8MUR: VQFN44, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega8515L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP; - mcuid = 160; - n_interrupts = 17; - n_boot_sections = 4; - boot_section_size = 256; - stk500_devcode = 0x63; - avr910_devcode = 0x3a; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x93 0x06; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback = 0xff 0xff; - mode = 0x04; - delay = 20; - blocksize = 128; - readsize = 256; - read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback = 0xff 0x00; - mode = 0x21; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xe1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xd9; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 4; - read = "0011.1000--00xx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATmega8535 -#------------------------------------------------------------ - -part # m8535 - desc = "ATmega8535"; - id = "m8535"; - variants = - "ATmega8535: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega8535-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8535-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8535-16JU: PLCC44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8535-16JUR: PLCC44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8535-16MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8535-16MUR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega8535-16PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega8535L-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8535L-8AUR: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8535L-8JU: PLCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8535L-8JUR: PLCC44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8535L-8MU: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8535L-8MUR: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8535L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP; - mcuid = 161; + "ATmega16: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega16-16AQR: TQFP44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega16-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega16-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega16-16MQ: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega16-16MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega16-16MUR: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega16-16PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega16L-8AQ: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16L-8AQR: TQFP44, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega16L-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16L-8AUR: TQFP44, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega16L-8MU: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16L-8MUR: VQFN44, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega16L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; + mcuid = 49; n_interrupts = 21; + stk500_devcode = 0x82; + avr910_devcode = 0x74; + bs2 = 0xa0; + signature = 0x1e 0x94 0x03; + allowfullpagebitstream = yes; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 2; + + memory "eeprom" + read = "1010.0000--00xx.xxaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 0x4000; + page_size = 128; + blocksize = 128; + read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "hfuse" + initval = 0x99; + ; +; + +#------------------------------------------------------------ +# ATmega16A +#------------------------------------------------------------ + +part parent "m16" # m16a + desc = "ATmega16A"; + id = "m16a"; + variants = + "ATmega16A: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega16A-AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16A-AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16A-MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16A-MUR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega16A-PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 50; +; + +#------------------------------------------------------------ +# ATmega32 +#------------------------------------------------------------ + +part parent "m8" # m32 + desc = "ATmega32"; + id = "m32"; + variants = + "ATmega32: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega32-16AQ: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega32-16AQR: TQFP44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega32-16AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega32-16AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega32-16MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega32-16MUR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega32-16PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega32L-8AU: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32L-8AUR: TQFP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32L-8MU: MLF44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32L-8MUR: VQFN44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; + mcuid = 58; + n_interrupts = 21; + boot_section_size = 512; + stk500_devcode = 0x91; + avr910_devcode = 0x72; + bs2 = 0xa0; + signature = 0x1e 0x95 0x02; + allowfullpagebitstream = yes; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3c; + ocdrev = 2; + + memory "eeprom" + size = 1024; + blocksize = 64; + read = "1010.0000--00xx.xxaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 0x8000; + page_size = 128; + num_pages = 256; + read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "hfuse" + initval = 0x99; + ; + + memory "sram" + size = 2048; + ; +; + +#------------------------------------------------------------ +# ATmega32A +#------------------------------------------------------------ + +part parent "m32" # m32a + desc = "ATmega32A"; + id = "m32a"; + variants = + "ATmega32A-AN: TQFP44, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-ANR: TQFP44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-AU: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-AUR: TQFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-MN: VQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-MNR: VQFN44, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-MU: MLF44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-MUR: VQFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-PN: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32A-PU: PDIP40, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 59; +; + +#------------------------------------------------------------ +# ATmega64 +#------------------------------------------------------------ + +part parent "m8" # m64 + desc = "ATmega64"; + id = "m64"; + variants = + "ATmega64: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega64-16AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", + "ATmega64-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.2 V, 5.5 V]", + "ATmega64-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.2 V, 5.5 V]", + "ATmega64-16MN: QFN64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", + "ATmega64-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega64-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega64L-8AN: TQFP64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8AQ: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8AQR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8MN: QFN64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8MQ: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8MQR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8MU: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64L-8MUR: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; + mcuid = 72; + n_interrupts = 35; + boot_section_size = 1024; + stk500_devcode = 0xa0; + avr910_devcode = 0x45; + bs2 = 0xa0; + signature = 0x1e 0x96 0x02; + allowfullpagebitstream = yes; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x22; + spmcr = 0x68; + eecr = 0x3c; + ocdrev = 2; + + memory "eeprom" + size = 2048; + page_size = 8; + blocksize = 64; + read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + size = 0x10000; + page_size = 256; + num_pages = 256; + blocksize = 128; + read_lo = "0010.0000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--xaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "hfuse" + initval = 0x99; + ; + + memory "efuse" + size = 1; + initval = 0xfd; + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxii"; + ; + + memory "io" + size = 224; + ; + + memory "sram" + size = 4096; + offset = 0x100; + ; +; + +#------------------------------------------------------------ +# ATmega64A +#------------------------------------------------------------ + +part parent "m64" # m64a + desc = "ATmega64A"; + id = "m64a"; + variants = + "ATmega64A-AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64A-ANR: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64A-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64A-MN: QFN64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64A-MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64A-MUR: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 73; +; + +#------------------------------------------------------------ +# ATmega128 +#------------------------------------------------------------ + +part parent "m8" # m128 + desc = "ATmega128"; + id = "m128"; + variants = + "ATmega128-16AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", + "ATmega128-16ANR: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", + "ATmega128-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega128-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega128-16MN: MLF64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[4.5 V, 5.5 V]", + "ATmega128-16MNR: MLF64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega128-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega128-16MUR: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega128L-8AN: TQFP64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[3 V, 5.5 V]", + "ATmega128L-8ANR: TQFP64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[3 V, 5.5 V]", + "ATmega128L-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128L-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128L-8MN: MLF64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[3 V, 5.5 V]", + "ATmega128L-8MNR: MLF64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega128L-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128L-8MUR: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; + mcuid = 85; + n_interrupts = 35; + boot_section_size = 1024; + stk500_devcode = 0xb2; + avr910_devcode = 0x43; + chip_erase_delay = 10000; + bs2 = 0xa0; + signature = 0x1e 0x97 0x02; + allowfullpagebitstream = yes; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x22; + rampz = 0x3b; + spmcr = 0x68; + eecr = 0x3c; + ocdrev = 1; + + memory "eeprom" + size = 4096; + page_size = 8; + min_write_delay = 10000; + max_write_delay = 10000; + blocksize = 64; + read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; + ; + + memory "flash" + size = 0x20000; + page_size = 256; + num_pages = 512; + min_write_delay = 5000; + max_write_delay = 5000; + blocksize = 128; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "hfuse" + initval = 0x99; + ; + + memory "efuse" + size = 1; + initval = 0xfd; + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxii"; + ; + + memory "io" + size = 224; + ; + + memory "sram" + size = 4096; + offset = 0x100; + ; +; + +#------------------------------------------------------------ +# ATmega128A +#------------------------------------------------------------ + +part parent "m128" # m128a + desc = "ATmega128A"; + id = "m128a"; + variants = + "ATmega128A: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega128A-AN: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128A-ANR: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128A-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128A-MN: VQFN64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128A-MNR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega128A-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega128A-MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 86; +; + +#------------------------------------------------------------ +# ATmega640 +#------------------------------------------------------------ +# Almost same as ATmega1280, except for different memory sizes + +part parent ".classic" # m640 + desc = "ATmega640"; + id = "m640"; + variants = + "ATmega640: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega640-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega640-16AUR: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega640-16CU: CBGA100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega640V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega640V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega640V-8CU: CBGA100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega640V-8CUR: TFBGA100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 126; + n_interrupts = 57; n_boot_sections = 4; - boot_section_size = 256; - stk500_devcode = 0x64; - avr910_devcode = 0x69; + boot_section_size = 1024; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; chip_erase_delay = 9000; pagel = 0xd7; bs2 = 0xa0; - signature = 0x1e 0x93 0x08; + signature = 0x1e 0x96 0x08; + reset = io; timeout = 200; stabdelay = 100; cmdexedelay = 25; @@ -8475,332 +9917,997 @@ part # m8535 pollvalue = 0x53; predelay = 1; postdelay = 1; + pollmethod = 1; pp_controlstack = 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback = 0xff 0xff; - mode = 0x04; - delay = 20; - blocksize = 128; - readsize = 256; - read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback = 0xff 0x00; - mode = 0x21; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xe1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xd9; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 4; - read = "0011.1000--00xx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny26 -#------------------------------------------------------------ - -part # t26 - desc = "ATtiny26"; - id = "t26"; - variants = - "ATtiny26: N/A, Fmax=16 MHz, T=[N/A, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny26-16MU: MLF32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATtiny26-16MUR: VQFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATtiny26-16PU: PDIP20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATtiny26-16SU: SOIC20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATtiny26-16SUR: SOIC20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATtiny26L-8MU: MLF32, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny26L-8MUR: VQFN32, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny26L-8PU: PDIP20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny26L-8SU: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny26L-8SUR: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_ISP | PM_HVPP; - mcuid = 17; - n_interrupts = 12; - stk500_devcode = 0x21; - avr910_devcode = 0x5e; - chip_erase_delay = 9000; - pagel = 0xb3; - bs2 = 0xb2; - signature = 0x1e 0x91 0x09; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0xc4, 0xe4, 0xc4, 0xe4, 0xcc, 0xec, 0xcc, 0xec, - 0xd4, 0xf4, 0xd4, 0xf4, 0xdc, 0xfc, 0xdc, 0xfc, - 0xc8, 0xe8, 0xd8, 0xf8, 0x4c, 0x6c, 0x5c, 0x7c, - 0xec, 0xbc, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; latchcycles = 5; togglevtg = 1; poweroffdelay = 15; - resetdelayms = 2; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 3; + + memory "eeprom" + size = 4096; + page_size = 8; + min_write_delay = 9000; + max_write_delay = 9000; + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x10000; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0x99; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x07; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "io" + size = 480; + ; + + memory "sram" + size = 8192; + offset = 0x200; + ; +; + +#------------------------------------------------------------ +# ATmega1280 +#------------------------------------------------------------ + +part parent "m640" # m1280 + desc = "ATmega1280"; + id = "m1280"; + variants = + "ATmega1280: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega1280-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega1280-16AUR: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega1280-16CU: CBGA100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega1280V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1280V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega1280V-8CU: CBGA100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 138; + signature = 0x1e 0x97 0x03; + rampz = 0x3b; + + memory "flash" + size = 0x20000; + num_pages = 512; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; +; + +#------------------------------------------------------------ +# ATmega1281 +#------------------------------------------------------------ +# Identical to ATmega1280 + +part parent "m640" # m1281 + desc = "ATmega1281"; + id = "m1281"; + variants = + "ATmega1281: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega1281-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega1281-16AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega1281-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega1281-16MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega1281V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1281V-8AUR: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1281V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1281V-8MUR: MLF64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 139; + signature = 0x1e 0x97 0x04; + rampz = 0x3b; + + memory "flash" + size = 0x20000; + num_pages = 512; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; +; + +#------------------------------------------------------------ +# ATmega2560 +#------------------------------------------------------------ + +part parent "m640" # m2560 + desc = "ATmega2560"; + id = "m2560"; + variants = + "ATmega2560: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega2560-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega2560-16AUR: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega2560-16CU: CBGA100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega2560V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega2560V-8AUR: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega2560V-8CU: CBGA100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 143; + stk500_devcode = 0xb2; + signature = 0x1e 0x98 0x01; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; + latchcycles = 6; + rampz = 0x3b; + eind = 0x5c; + ocdrev = 4; + + memory "flash" + size = 0x40000; + num_pages = 1024; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + load_ext_addr = "0100.1101--0000.0000--0000.000a--0000.0000"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; +; + +#------------------------------------------------------------ +# ATmega2561 +#------------------------------------------------------------ + +part parent "m640" # m2561 + desc = "ATmega2561"; + id = "m2561"; + variants = + "ATmega2561: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega2561-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega2561-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega2561-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega2561-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", + "ATmega2561V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega2561V-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega2561V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega2561V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 144; + stk500_devcode = 0xb2; + signature = 0x1e 0x98 0x02; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; + latchcycles = 6; + rampz = 0x3b; + eind = 0x5c; + ocdrev = 4; + + memory "flash" + size = 0x40000; + num_pages = 1024; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + load_ext_addr = "0100.1101--0000.0000--0000.000a--0000.0000"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; +; + +#------------------------------------------------------------ +# ATmega164P +#------------------------------------------------------------ + +part parent ".classic" # m164p + desc = "ATmega164P"; + id = "m164p"; + variants = + "ATmega164P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega164P-20AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20AQ: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20MN: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20MQ: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20PQ: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164P-20PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega164PV-10AN: TQFP44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PV-10AQ: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PV-10AU: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PV-10AUR: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PV-10MU: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PV-10MUR: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PV-10PN: PDIP40, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PV-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 93; + n_interrupts = 31; + n_boot_sections = 4; + boot_section_size = 256; + stk500_devcode = 0x82; + avr910_devcode = 0x74; + chip_erase_delay = 55000; + pagel = 0xd7; + bs2 = 0xa0; + signature = 0x1e 0x94 0x0a; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 3; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 9000; + max_write_delay = 9000; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--00xx.xaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xaaa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x4000; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0x99; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x07; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 1024; + ; +; + +#------------------------------------------------------------ +# ATmega164A +#------------------------------------------------------------ + +part parent "m164p" # m164a + desc = "ATmega164A"; + id = "m164a"; + variants = + "ATmega164A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-CU: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-CUR: VFBGA49, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-MCH: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-MCHR: QFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-MU: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-MUR: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164A-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 92; + signature = 0x1e 0x94 0x0f; +; + +#------------------------------------------------------------ +# ATmega164PA +#------------------------------------------------------------ + +part parent "m164p" # m164pa + desc = "ATmega164PA"; + id = "m164pa"; + variants = + "ATmega164PA: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-ANR: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-CU: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-CUR: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-MCH: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-MCHR: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-MN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-MNR: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega164PA-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 94; +; + +#------------------------------------------------------------ +# ATmega324P +#------------------------------------------------------------ + +part parent "m164p" # m324p + desc = "ATmega324P"; + id = "m324p"; + variants = + "ATmega324P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega324P-20AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20AQ: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20AQR: TQFP44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20MN: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20MQR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324P-20PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega324PV-10AN: TQFP44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PV-10AU: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PV-10AUR: TQFP44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega324PV-10MN: VQFN44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PV-10MU: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PV-10PN: PDIP40, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PV-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 111; + boot_section_size = 512; + signature = 0x1e 0x95 0x08; + + memory "eeprom" + size = 1024; + delay = 10; + ; + + memory "flash" + size = 0x8000; + num_pages = 256; + ; + + memory "sram" + size = 2048; + ; +; + +#------------------------------------------------------------ +# ATmega324A +#------------------------------------------------------------ + +part parent "m324p" # m324a + desc = "ATmega324A"; + id = "m324a"; + variants = + "ATmega324A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega324A-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324A-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324A-CU: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324A-MCH: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324A-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324A-MUR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega324A-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 110; + signature = 0x1e 0x95 0x15; +; + +#------------------------------------------------------------ +# ATmega324PA +#------------------------------------------------------------ + +part parent "m324p" # m324pa + desc = "ATmega324PA"; + id = "m324pa"; + variants = + "ATmega324PA: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-CU: VFBGA49, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-MCH: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-MCHR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-MN: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-MNR: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PA-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 112; + signature = 0x1e 0x95 0x11; +; + +#------------------------------------------------------------ +# ATmega324PB +#------------------------------------------------------------ + +part parent "m324p" # m324pb + desc = "ATmega324PB"; + id = "m324pb"; + variants = + "ATmega324PB-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PB-ANR: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PB-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PB-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PB-MN: QFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PB-MNR: QFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PB-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega324PB-MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 113; + n_interrupts = 51; + signature = 0x1e 0x95 0x17; + + memory "efuse" + initval = 0x07; + bitmask = 0x0f; + write = "1010.1100--1010.0100--xxxx.xxxx--1111.iiii"; + ; + + memory "prodsig" + size = 24; + read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; + ; + + memory "sigrow" + alias "prodsig"; + ; + + memory "sernum" + size = 10; + offset = 0xe; # Sub-region of prodsig + read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega644 +#------------------------------------------------------------ + +part parent "m164p" # m644 + desc = "ATmega644"; + id = "m644"; + variants = + "ATmega644: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega644-20AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644-20AUR: TQFP44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega644-20MU: MLF44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644-20MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644-20PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644V-10AU: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644V-10AUR: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644V-10MU: MLF44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644V-10MUR: VQFN44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644V-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 127; + n_interrupts = 28; + boot_section_size = 1024; + signature = 0x1e 0x96 0x09; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; + latchcycles = 6; + + memory "eeprom" + size = 2048; + page_size = 8; + delay = 10; + blocksize = 8; + read = "1010.0000--00xx.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.aaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x10000; + page_size = 256; + num_pages = 256; + blocksize = 256; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--00xx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--00xx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# ATmega644P +#------------------------------------------------------------ + +part parent "m644" # m644p + desc = "ATmega644P"; + id = "m644p"; + variants = + "ATmega644P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega644P-20AN: TQFP44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20AQ: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20AQR: TQFP44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20MN: VQFN44, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20MQ: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20MQR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20MUR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20PQ: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644P-20PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega644PV-10AN: TQFP44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10AQ: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10AQR: TQFP44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10AU: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10AUR: TQFP44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10MN: VQFN44, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10MQ: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10MQR: VQFN44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10MU: VQFN44, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10MUR: VQFN44, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10PN: PDIP40, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10PQ: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PV-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 129; + n_interrupts = 31; + signature = 0x1e 0x96 0x0a; +; + +#------------------------------------------------------------ +# ATmega644A +#------------------------------------------------------------ + +part parent "m644" # m644a + desc = "ATmega644A"; + id = "m644a"; + variants = + "ATmega644A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644A-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644A-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644A-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644A-MUR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644A-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 128; + n_interrupts = 31; +; + +#------------------------------------------------------------ +# ATmega644PA +#------------------------------------------------------------ + +part parent "m644" # m644pa + desc = "ATmega644PA"; + id = "m644pa"; + variants = + "ATmega644PA-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-ANR: TQFP44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-MN: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-MNR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-MU: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-MUR: VQFN44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-PN: PDIP40, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega644PA-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 130; + n_interrupts = 31; + signature = 0x1e 0x96 0x0a; +; + +#------------------------------------------------------------ +# ATmega1284 +#------------------------------------------------------------ + +part parent "m164p" # m1284 + desc = "ATmega1284"; + id = "m1284"; + variants = + "ATmega1284-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284-MU: MLF44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284-MUR: MLF44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega1284-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 140; + n_interrupts = 35; + boot_section_size = 1024; + signature = 0x1e 0x97 0x06; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; + latchcycles = 6; + rampz = 0x3b; + + memory "eeprom" + size = 4096; + page_size = 8; + delay = 10; + blocksize = 8; + readsize = 128; + read = "1010.0000--00xx.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.aaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x20000; + page_size = 256; + num_pages = 512; + readsize = 128; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--00xx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--00xx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 0x4000; + ; +; + +#------------------------------------------------------------ +# ATmega1284P +#------------------------------------------------------------ + +part parent "m1284" # m1284p + desc = "ATmega1284P"; + id = "m1284p"; + variants = + "ATmega1284P-AN: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284P-AU: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284P-AUR: TQFP44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284P-MN: QFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284P-MU: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284P-MUR: VQFN44, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284P-PN: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega1284P-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 141; + signature = 0x1e 0x97 0x05; +; + +#------------------------------------------------------------ +# ATmega128RFA1 +#------------------------------------------------------------ +# Identical to ATmega2561 but half the ROM + +part parent ".classic" # m128rfa1 + desc = "ATmega128RFA1"; + id = "m128rfa1"; + variants = + "ATmega128RFA1: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFA1-ZF: VFQFN64, Fmax=N/A, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFA1-ZFR: VFQFN64, Fmax=N/A, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFA1-ZU: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFA1-ZU00: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFA1-ZUR: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFA1-ZUR-SL514: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFA1-ZUR00: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 87; + n_interrupts = 72; + n_boot_sections = 4; + boot_section_size = 1024; + stk500_devcode = 0xb2; + chip_erase_delay = 18500; + pagel = 0xd7; + bs2 = 0xe2; + signature = 0x1e 0xa7 0x01; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + rampz = 0x3b; + spmcr = 0x57; + eecr = 0x3f; + eind = 0x5c; + ocdrev = 3; + + memory "eeprom" + size = 4096; + page_size = 8; + min_write_delay = 13000; + max_write_delay = 13000; + mode = 0x41; + delay = 50; + blocksize = 8; + readsize = 256; + read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x20000; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 50; + blocksize = 256; + readsize = 256; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0x99; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x07; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "io" + size = 480; + ; + + memory "sram" + size = 0x4000; + offset = 0x200; + ; +; + +#------------------------------------------------------------ +# ATmega644RFR2 +#------------------------------------------------------------ + +part parent ".classic" # m644rfr2 + desc = "ATmega644RFR2"; + id = "m644rfr2"; + variants = + "ATmega644RFR2-ZF: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega644RFR2-ZFR: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega644RFR2-ZU: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega644RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 131; + n_interrupts = 77; + n_boot_sections = 4; + boot_section_size = 1024; + stk500_devcode = 0xb2; + chip_erase_delay = 18500; + pagel = 0xd7; + bs2 = 0xe2; + signature = 0x1e 0xa6 0x03; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; hvleavestabdelay = 15; resetdelay = 15; chiperasepolltimeout = 20; - programfusepolltimeout = 10; - programlockpolltimeout = 10; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 128; - min_write_delay = 9000; - max_write_delay = 9000; - readback = 0xff 0xff; - mode = 0x04; - delay = 20; - blocksize = 64; - readsize = 256; - read = "1010.0000--xxxx.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - ; - - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback = 0xff 0x00; - mode = 0x21; - delay = 10; - blocksize = 16; - readsize = 256; - read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxxx.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxxx.aaaa--iiii.iiii"; - writepage = "0100.1100--xxxx.xxaa--aaaa.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xe1; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xf7; - bitmask = 0x1f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--xxxi.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xxoo"; - write = "1010.1100--1111.11ii--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "calibration" - size = 4; - read = "0011.1000--xxxx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 128; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny261 -#------------------------------------------------------------ - -part # t261 - desc = "ATtiny261"; - id = "t261"; - variants = - "ATtiny261: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[N/A, N/A]", - "ATtiny261-20MU: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny261-20PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny261-20SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny261V-10MU: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261V-10PU: PDIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 30; - n_interrupts = 19; - chip_erase_delay = 4000; - pagel = 0xb3; - bs2 = 0xb2; -# stk500_devcode = 0x21; -# avr910_devcode = 0x5e; - signature = 0x1e 0x91 0x0c; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0xc4, 0xe4, 0xc4, 0xe4, 0xcc, 0xec, 0xcc, 0xec, - 0xd4, 0xf4, 0xd4, 0xf4, 0xdc, 0xfc, 0xdc, 0xfc, - 0xc8, 0xe8, 0xd8, 0xf8, 0x4c, 0x6c, 0x5c, 0x7c, - 0xec, 0xbc, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb4, 0x00, 0x10; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x00, 0xb4, 0x00, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; programfusepolltimeout = 5; programlockpolltimeout = 5; - idr = 0x20; + idr = 0x31; + rampz = 0x3b; spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + eecr = 0x3f; + eind = 0x5c; + ocdrev = 3; memory "eeprom" - size = 128; - page_size = 4; - num_pages = 32; - min_write_delay = 4000; - max_write_delay = 4000; + size = 2048; + page_size = 8; + min_write_delay = 13000; + max_write_delay = 13000; mode = 0x41; - delay = 10; - blocksize = 4; + delay = 50; + blocksize = 8; readsize = 256; - read = "1010.0000--xxxx.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; + read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; ; memory "flash" paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; + size = 0x10000; + page_size = 256; + num_pages = 256; min_write_delay = 4500; max_write_delay = 4500; mode = 0x41; - delay = 10; - blocksize = 32; + delay = 50; + blocksize = 256; readsize = 256; - read_lo = "0010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxxx.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxxx.aaaa--iiii.iiii"; - writepage = "0100.1100--xxxx.xxaa--aaaa.xxxx--xxxx.xxxx"; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--axxx.xxxx--xxxx.xxxx"; ; memory "lfuse" @@ -8814,7 +10921,7 @@ part # t261 memory "hfuse" size = 1; - initval = 0xdf; + initval = 0x99; min_write_delay = 4500; max_write_delay = 4500; read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; @@ -8823,501 +10930,1004 @@ part # t261 memory "efuse" size = 1; - initval = 0xff; - bitmask = 0x01; + initval = 0xfe; + bitmask = 0x07; min_write_delay = 4500; max_write_delay = 4500; read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; ; memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; + bitmask = 0x3f; min_write_delay = 4500; max_write_delay = 4500; - read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xxoo"; - write = "1010.1100--1111.11ii--xxxx.xxxx--xxxx.xxxx"; ; - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; + ##### + # Three separate flash pages + # - Offset 0x100 in signature row + # - Only programmable with JTAG or HVPP + # - Readable from an application + # - Cannot be read using ISP + # - Not erased by chip erase + # + memory "usersig" + paged = yes; + size = 768; + page_size = 256; + num_pages = 3; + offset = 0x100; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 50; + blocksize = 256; + readsize = 256; ; memory "io" - size = 64; - offset = 0x20; + size = 480; ; memory "sram" - size = 128; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny261A -#------------------------------------------------------------ - -part parent "t261" # t261a - desc = "ATtiny261A"; - id = "t261a"; - variants = - "ATtiny261A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-MF: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-MFR: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-MN: MLF32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-MNR: VQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-XU: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny261A-XUR: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 31; -; - -#------------------------------------------------------------ -# ATtiny461 -#------------------------------------------------------------ - -part # t461 - desc = "ATtiny461"; - id = "t461"; - variants = - "ATtiny461: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[N/A, N/A]", - "ATtiny461-20MU: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny461-20MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny461-20PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny461-20SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny461-20SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny461V-10MU: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny461V-10MUR: VQFN32, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny461V-10PU: PDIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny461V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny461V-10SUR: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 33; - n_interrupts = 19; - chip_erase_delay = 4000; - pagel = 0xb3; - bs2 = 0xb2; -# stk500_devcode = 0x21; -# avr910_devcode = 0x5e; - signature = 0x1e 0x92 0x08; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0xc4, 0xe4, 0xc4, 0xe4, 0xcc, 0xec, 0xcc, 0xec, - 0xd4, 0xf4, 0xd4, 0xf4, 0xdc, 0xfc, 0xdc, 0xfc, - 0xc8, 0xe8, 0xd8, 0xf8, 0x4c, 0x6c, 0x5c, 0x7c, - 0xec, 0xbc, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb4, 0x00, 0x10; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x00, 0xb4, 0x00, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x20; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 256; - page_size = 4; - num_pages = 64; - min_write_delay = 4000; - max_write_delay = 4000; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--xxxx.xxxx--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxx--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--xxxx.xaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xxoo"; - write = "1010.1100--1111.11ii--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 256; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny461A -#------------------------------------------------------------ - -part parent "t461" # t461a - desc = "ATtiny461A"; - id = "t461a"; - variants = - "ATtiny461A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny461A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny461A-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny461A-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny461A-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny461A-XU: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny461A-XUR: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 34; -; - -#------------------------------------------------------------ -# ATtiny861 -#------------------------------------------------------------ - -part # t861 - desc = "ATtiny861"; - id = "t861"; - variants = - "ATtiny861: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[N/A, N/A]", - "ATtiny861-20MU: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny861-20MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny861-20PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny861-20SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny861-20SUR: SOIC20, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATtiny861V-10MU: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861V-10MUR: VQFN32, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny861V-10PU: PDIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861V-10SUR: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 38; - n_interrupts = 19; - chip_erase_delay = 4000; - pagel = 0xb3; - bs2 = 0xb2; -# stk500_devcode = 0x21; -# avr910_devcode = 0x5e; - signature = 0x1e 0x93 0x0d; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0xc4, 0xe4, 0xc4, 0xe4, 0xcc, 0xec, 0xcc, 0xec, - 0xd4, 0xf4, 0xd4, 0xf4, 0xdc, 0xfc, 0xdc, 0xfc, - 0xc8, 0xe8, 0xd8, 0xf8, 0x4c, 0x6c, 0x5c, 0x7c, - 0xec, 0xbc, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb4, 0x00, 0x10; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x00, 0xb4, 0x00, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x20; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - num_pages = 128; - min_write_delay = 4000; - max_write_delay = 4000; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--xxxx.aaaa--aaax.xxxx--xxxx.xxxx"; + offset = 0x200; + ; +; + +#------------------------------------------------------------ +# ATmega1284RFR2 +#------------------------------------------------------------ + +part parent "m644rfr2" # m1284rfr2 + desc = "ATmega1284RFR2"; + id = "m1284rfr2"; + variants = + "ATmega1284RFR2-ZF: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega1284RFR2-ZFR: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega1284RFR2-ZU: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega1284RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; + mcuid = 142; + signature = 0x1e 0xa7 0x03; + + memory "eeprom" + size = 4096; + read = "1010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxa.aaaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xa.aaaa--aaaa.a000--xxxx.xxxx"; ; - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--xxxx.xxxx--xxxx.xxxx--xxxx.xxoo"; - write = "1010.1100--1111.11ii--xxxx.xxxx--xxxx.xxxx"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--0000.00aa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; + memory "flash" + size = 0x20000; + num_pages = 512; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; ; memory "sram" - size = 512; - offset = 0x60; + size = 0x4000; ; ; #------------------------------------------------------------ -# ATtiny861A +# ATmega2564RFR2 #------------------------------------------------------------ -part parent "t861" # t861a - desc = "ATtiny861A"; - id = "t861a"; +part parent "m644rfr2" # m2564rfr2 + desc = "ATmega2564RFR2"; + id = "m2564rfr2"; variants = - "ATtiny861A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny861A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861A-MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861A-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861A-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861A-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861A-XU: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny861A-XUR: TSSOP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 39; + "ATmega2564RFR2-ZF: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega2564RFR2-ZFR: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega2564RFR2-ZU: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega2564RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; + mcuid = 145; + signature = 0x1e 0xa8 0x03; + ocdrev = 4; + + memory "eeprom" + size = 8192; + read = "1010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxa.aaaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xa.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x40000; + num_pages = 1024; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + load_ext_addr = "0100.1101--0000.0000--0000.000a--0000.0000"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 0x8000; + ; ; #------------------------------------------------------------ -# ATtiny28 +# ATmega64RFR2 #------------------------------------------------------------ -# This is an HVPP-only device. - -part # t28 - desc = "ATtiny28"; - id = "t28"; +part parent ".classic" # m64rfr2 + desc = "ATmega64RFR2"; + id = "m64rfr2"; variants = - "ATtiny28: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATtiny28L-4AU: TQFP32, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny28L-4MU: MLF32, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny28L-4MUR: VQFN32, Fmax=4 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATtiny28L-4PU: PDIP28, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny28V-1AU: TQFP32, Fmax=1.2 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny28V-1AUR: TQFP32, Fmax=1 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny28V-1MU: MLF32, Fmax=1.2 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny28V-1MUR: VQFN32, Fmax=1 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny28V-1PU: PDIP28, Fmax=1.2 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_HVPP; - mcuid = 18; - n_interrupts = 6; - stk500_devcode = 0x22; - avr910_devcode = 0x5c; - signature = 0x1e 0x91 0x07; - serial = no; + "ATmega64RFR2-ZF: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega64RFR2-ZFR: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega64RFR2-ZU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega64RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 78; + n_interrupts = 77; + n_boot_sections = 4; + boot_section_size = 1024; + stk500_devcode = 0xb2; + chip_erase_delay = 18500; + pagel = 0xd7; + bs2 = 0xe2; + signature = 0x1e 0xa6 0x02; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; pp_controlstack = 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 20; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + rampz = 0x3b; + spmcr = 0x57; + eecr = 0x3f; + eind = 0x5c; + ocdrev = 3; + + memory "eeprom" + size = 2048; + page_size = 8; + min_write_delay = 13000; + max_write_delay = 13000; + mode = 0x41; + delay = 50; + blocksize = 8; + readsize = 256; + read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x10000; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 50; + blocksize = 256; + readsize = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0x99; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xfe; + bitmask = 0x07; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + ##### + # Three separate flash pages + # - Offset 0x100 in signature row + # - Only programmable with JTAG or HVPP + # - Readable from an application + # - Cannot be read using ISP + # - Not erased by chip erase + # + memory "usersig" + paged = yes; + size = 768; + page_size = 256; + num_pages = 3; + offset = 0x100; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 50; + blocksize = 256; + readsize = 256; + ; + + memory "io" + size = 480; + ; + + memory "sram" + size = 8192; + offset = 0x200; + ; +; + +#------------------------------------------------------------ +# ATmega128RFR2 +#------------------------------------------------------------ + +part parent "m64rfr2" # m128rfr2 + desc = "ATmega128RFR2"; + id = "m128rfr2"; + variants = + "ATmega128RFR2-ZF: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFR2-ZFR: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFR2-ZU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega128RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; + mcuid = 88; + signature = 0x1e 0xa7 0x02; + + memory "eeprom" + size = 4096; + read = "1010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxa.aaaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xa.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x20000; + num_pages = 512; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 0x4000; + ; +; + +#------------------------------------------------------------ +# ATmega256RFR2 +#------------------------------------------------------------ + +part parent "m64rfr2" # m256rfr2 + desc = "ATmega256RFR2"; + id = "m256rfr2"; + variants = + "ATmega256RFR2-ZF: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega256RFR2-ZFR: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", + "ATmega256RFR2-ZU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", + "ATmega256RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; + mcuid = 108; + signature = 0x1e 0xa8 0x02; + ocdrev = 4; + + memory "eeprom" + size = 8192; + read = "1010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxa.aaaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xa.aaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x40000; + num_pages = 1024; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + load_ext_addr = "0100.1101--0000.0000--0000.000a--0000.0000"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "sram" + size = 0x8000; + ; +; + +#------------------------------------------------------------ +# ATmega165 +#------------------------------------------------------------ + +part parent ".classic" # m165 + desc = "ATmega165"; + id = "m165"; + variants = + "ATmega165: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega165-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega165-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega165-16MI: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega165-16MU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega165V-8AI: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165V-8MI: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165V-8MU: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 95; + n_interrupts = 22; + n_boot_sections = 4; + boot_section_size = 256; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + signature = 0x1e 0x94 0x07; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + latchcycles = 6; hvleavestabdelay = 15; resetdelay = 15; chiperasepolltimeout = 10; programfusepolltimeout = 5; programlockpolltimeout = 5; - factory_fcpu = 1200000; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 3; - memory "flash" - size = 2048; - page_size = 2; - delay = 5; + memory "eeprom" + size = 512; + page_size = 4; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + mode = 0x41; + delay = 20; + blocksize = 4; readsize = 256; + read = "1010.0000--0000.00xa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.00xa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--0000.00xa--aaaa.aa00--xxxx.xxxx"; ; - memory "fuse" + memory "flash" + paged = yes; + size = 0x4000; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--xxxa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" size = 1; - initval = 0x12; - bitmask = 0x1f; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0x99; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x0f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; ; memory "lock" - size = 1; - initval = 0x06; - bitmask = 0x06; - ; - - memory "signature" - size = 3; - ; - - memory "calibration" - size = 1; - ; - - memory "io" - size = 64; - offset = 0x20; + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; ; memory "sram" - size = 32; - offset = 0x60; + size = 1024; ; ; +#------------------------------------------------------------ +# ATmega165P +#------------------------------------------------------------ + +part parent "m165" # m165p + desc = "ATmega165P"; + id = "m165p"; + variants = + "ATmega165P: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega165P-16AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega165P-16ANR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega165P-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega165P-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega165P-16MN: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega165P-16MNR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega165P-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega165P-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega165PV-8AN: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165PV-8ANR: TQFP64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega165PV-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165PV-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165PV-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165PV-8MUR: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 97; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega165A +#------------------------------------------------------------ + +part parent "m165" # m165a + desc = "ATmega165A"; + id = "m165a"; + variants = + "ATmega165A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega165A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165A-AUR: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega165A-MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165A-MUR: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; + mcuid = 96; + signature = 0x1e 0x94 0x10; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega165PA +#------------------------------------------------------------ + +part parent "m165" # m165pa + desc = "ATmega165PA"; + id = "m165pa"; + variants = + "ATmega165PA: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega165PA-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165PA-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165PA-MN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega165PA-MNR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega165PA-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 98; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega325 +#------------------------------------------------------------ + +part parent "m165" # m325 + desc = "ATmega325"; + id = "m325"; + variants = + "ATmega325: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega325-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega325-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega325-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega325-16MUR: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega325V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325V-8AUR: TQFP64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega325V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 114; + boot_section_size = 512; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x95 0x05; + + memory "eeprom" + size = 1024; + num_pages = 0; + delay = 10; + read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 0x8000; + num_pages = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--aaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--aaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--aaaa.aaaa--xxxx.xxxx"; + ; + + memory "lfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + bitmask = 0x07; + min_write_delay = 9000; + max_write_delay = 9000; + write = "1010.1100--1010.0100--0000.0000--1111.1iii"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 2048; + ; +; + +#------------------------------------------------------------ +# ATmega325P +#------------------------------------------------------------ + +part parent "m325" # m325p + desc = "ATmega325P"; + id = "m325p"; + variants = + "ATmega325P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega325P-20AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega325P-20AUR: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega325P-20MU: MLF64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega325PV-10AU: TQFP64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325PV-10AUR: TQFP64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325PV-10MU: MLF64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325PV-10MUR: VQFN64, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 116; + signature = 0x1e 0x95 0x0d; +; + +#------------------------------------------------------------ +# ATmega325A +#------------------------------------------------------------ + +part parent "m325" # m325a + desc = "ATmega325A"; + id = "m325a"; + variants = + "ATmega325A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega325A-AN: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325A-ANR: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325A-AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325A-AUR: TQFP64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega325A-MN: VQFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325A-MNR: VQFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325A-MU: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325A-MUR: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 115; +; + +#------------------------------------------------------------ +# ATmega325PA +#------------------------------------------------------------ + +part parent "m325" # m325pa + desc = "ATmega325PA"; + id = "m325pa"; + variants = + "ATmega325PA: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega325PA-AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325PA-AUR: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega325PA-MU: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega325PA-MUR: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 117; + signature = 0x1e 0x95 0x0d; +; + +#------------------------------------------------------------ +# ATmega3250 +#------------------------------------------------------------ + +part parent "m165" # m3250 + desc = "ATmega3250"; + id = "m3250"; + variants = + "ATmega3250: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega3250-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega3250-16AUR: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega3250V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega3250V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 146; + n_interrupts = 25; + boot_section_size = 512; + avr910_devcode = 0x74; + signature = 0x1e 0x95 0x06; + + memory "eeprom" + size = 1024; + num_pages = 0; + delay = 10; + read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 0x8000; + num_pages = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--aaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--aaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--aaaa.aaaa--xxxx.xxxx"; + ; + + memory "lfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + bitmask = 0x07; + min_write_delay = 9000; + max_write_delay = 9000; + write = "1010.1100--1010.0100--0000.0000--1111.1iii"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 2048; + ; +; + +#------------------------------------------------------------ +# ATmega3250P +#------------------------------------------------------------ + +part parent "m3250" # m3250p + desc = "ATmega3250P"; + id = "m3250p"; + variants = + "ATmega3250P: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega3250P-20AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega3250P-20AUR: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega3250PV-10AU: TQFP100, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega3250PV-10AUR: TQFP100, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 148; + signature = 0x1e 0x95 0x0e; +; + +#------------------------------------------------------------ +# ATmega3250A +#------------------------------------------------------------ + +part parent "m3250" # m3250a + desc = "ATmega3250A"; + id = "m3250a"; + variants = + "ATmega3250A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega3250A-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega3250A-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 147; +; + +#------------------------------------------------------------ +# ATmega3250PA +#------------------------------------------------------------ + +part parent "m3250" # m3250pa + desc = "ATmega3250PA"; + id = "m3250pa"; + variants = + "ATmega3250PA: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega3250PA-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega3250PA-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 149; + signature = 0x1e 0x95 0x0e; +; + +#------------------------------------------------------------ +# ATmega645 +#------------------------------------------------------------ + +part parent "m165" # m645 + desc = "ATmega645"; + id = "m645"; + variants = + "ATmega645: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega645-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega645-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega645-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega645-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega645V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega645V-8AUR: TQFP64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega645V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega645V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 132; + boot_section_size = 1024; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x96 0x05; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + + memory "eeprom" + size = 2048; + page_size = 8; + num_pages = 0; + delay = 10; + read = "1010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.0aaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--0000.0aaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x10000; + page_size = 256; + num_pages = 256; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--aaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--aaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--aaaa.aaaa--0000.0000"; + ; + + memory "lfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + bitmask = 0x07; + min_write_delay = 9000; + max_write_delay = 9000; + write = "1010.1100--1010.0100--0000.0000--1111.1iii"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# ATmega645P +#------------------------------------------------------------ + +part parent "m645" # m645p + desc = "ATmega645P"; + id = "m645p"; + variants = + "ATmega645P: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega645P-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega645P-AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega645P-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega645P-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 134; + signature = 0x1e 0x96 0x0d; +; + +#------------------------------------------------------------ +# ATmega645A +#------------------------------------------------------------ + +part parent "m645" # m645a + desc = "ATmega645A"; + id = "m645a"; + variants = + "ATmega645A: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega645A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega645A-AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega645A-MU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega645A-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 133; +; + +#------------------------------------------------------------ +# ATmega6450 +#------------------------------------------------------------ + +part parent "m165" # m6450 + desc = "ATmega6450"; + id = "m6450"; + variants = + "ATmega6450: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega6450-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega6450-16AUR: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega6450V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega6450V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 154; + n_interrupts = 25; + boot_section_size = 1024; + avr910_devcode = 0x74; + signature = 0x1e 0x96 0x06; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + + memory "eeprom" + size = 2048; + page_size = 8; + num_pages = 0; + delay = 10; + read = "1010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.0aaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--0000.0aaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x10000; + page_size = 256; + num_pages = 256; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--aaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--aaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--aaaa.aaaa--0000.0000"; + ; + + memory "lfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + bitmask = 0x07; + min_write_delay = 9000; + max_write_delay = 9000; + write = "1010.1100--1010.0100--0000.0000--1111.1iii"; + ; + + memory "lock" + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# ATmega6450P +#------------------------------------------------------------ + +part parent "m6450" # m6450p + desc = "ATmega6450P"; + id = "m6450p"; + variants = + "ATmega6450P: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega6450P-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega6450P-AUR: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 156; + signature = 0x1e 0x96 0x0e; +; + +#------------------------------------------------------------ +# ATmega6450A +#------------------------------------------------------------ + +part parent "m6450" # m6450a + desc = "ATmega6450A"; + id = "m6450a"; + variants = + "ATmega6450A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega6450A-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega6450A-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 155; +; + #------------------------------------------------------------ # ATmega48 #------------------------------------------------------------ -part # m48 +part parent ".classic" # m48 desc = "ATmega48"; id = "m48"; variants = @@ -9380,9 +11990,6 @@ part # m48 spmcr = 0x57; eecr = 0x3f; ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 256; @@ -9446,55 +12053,16 @@ part # m48 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x03; min_write_delay = 4500; max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--0000.0000--0000.00aa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" size = 512; - offset = 0x100; ; ; -#------------------------------------------------------------ -# ATmega48A -#------------------------------------------------------------ - -part parent "m48" # m48a - desc = "ATmega48A"; - id = "m48a"; - variants = - "ATmega48A-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48A-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48A-CCU: UFBGA32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48A-MMH: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48A-MMHR: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48A-MUR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega48A-PU: PDIP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 68; -; - #------------------------------------------------------------ # ATmega48P #------------------------------------------------------------ @@ -9521,6 +12089,25 @@ part parent "m48" # m48p signature = 0x1e 0x92 0x0a; ; +#------------------------------------------------------------ +# ATmega48A +#------------------------------------------------------------ + +part parent "m48" # m48a + desc = "ATmega48A"; + id = "m48a"; + variants = + "ATmega48A-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48A-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48A-CCU: UFBGA32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48A-MMH: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48A-MMHR: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48A-MUR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega48A-PU: PDIP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 68; +; + #------------------------------------------------------------ # ATmega48PA #------------------------------------------------------------ @@ -9549,33 +12136,11 @@ part parent "m48" # m48pa signature = 0x1e 0x92 0x0a; ; -#------------------------------------------------------------ -# ATmega48PB -#------------------------------------------------------------ - -part parent "m48" # m48pb - desc = "ATmega48PB"; - id = "m48pb"; - variants = - "ATmega48PB-AN: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48PB-ANR: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48PB-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48PB-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48PB-MN: VQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48PB-MNR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega48PB-MU: VFQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega48PB-MUR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; - mcuid = 71; - n_interrupts = 27; - chip_erase_delay = 10500; - signature = 0x1e 0x92 0x10; -; - #------------------------------------------------------------ # ATmega88 #------------------------------------------------------------ -part # m88 +part parent "m48" # m88 desc = "ATmega88"; id = "m88"; variants = @@ -9590,167 +12155,44 @@ part # m88 "ATmega88V-10MU: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega88V-10MUR: VQFN32, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", "ATmega88V-10PU: PDIP28, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 79; - n_interrupts = 26; n_boot_sections = 4; boot_section_size = 256; stk500_devcode = 0x73; chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc2; # avr910_devcode = 0x??; signature = 0x1e 0x93 0x0a; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 512; - page_size = 4; - min_write_delay = 3600; - max_write_delay = 3600; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" - paged = yes; size = 8192; - page_size = 64; num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; ; - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - memory "efuse" - size = 1; initval = 0xf9; bitmask = 0x07; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" size = 1024; - offset = 0x100; ; ; -#------------------------------------------------------------ -# ATmega88A -#------------------------------------------------------------ - -part parent "m88" # m88a - desc = "ATmega88A"; - id = "m88a"; - variants = - "ATmega88A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega88A-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88A-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88A-CCU: UFBGA32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88A-MMH: QFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88A-MMHR: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88A-MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88A-PU: PDIP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 80; -; - #------------------------------------------------------------ # ATmega88P #------------------------------------------------------------ @@ -9773,6 +12215,26 @@ part parent "m88" # m88p signature = 0x1e 0x93 0x0f; ; +#------------------------------------------------------------ +# ATmega88A +#------------------------------------------------------------ + +part parent "m88" # m88a + desc = "ATmega88A"; + id = "m88a"; + variants = + "ATmega88A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega88A-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88A-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88A-CCU: UFBGA32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88A-MMH: QFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88A-MMHR: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88A-MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88A-PU: PDIP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 80; +; + #------------------------------------------------------------ # ATmega88PA #------------------------------------------------------------ @@ -9803,33 +12265,11 @@ part parent "m88" # m88pa signature = 0x1e 0x93 0x0f; ; -#------------------------------------------------------------ -# ATmega88PB -#------------------------------------------------------------ - -part parent "m88" # m88pb - desc = "ATmega88PB"; - id = "m88pb"; - variants = - "ATmega88PB-AN: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88PB-ANR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88PB-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88PB-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88PB-MN: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88PB-MNR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega88PB-MU: VFQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega88PB-MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 83; - n_interrupts = 27; - chip_erase_delay = 10500; - signature = 0x1e 0x93 0x16; -; - #------------------------------------------------------------ # ATmega168 #------------------------------------------------------------ -part # m168 +part parent "m48" # m168 desc = "ATmega168"; id = "m168"; variants = @@ -9849,81 +12289,26 @@ part # m168 "ATmega168V-10MU: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega168V-10MUR: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega168V-10PU: PDIP28, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 99; - n_interrupts = 26; n_boot_sections = 4; boot_section_size = 256; stk500_devcode = 0x86; chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc2; # avr910_devcode = 0x??; signature = 0x1e 0x94 0x06; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 512; - page_size = 4; - min_write_delay = 3600; - max_write_delay = 3600; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" - paged = yes; size = 0x4000; page_size = 128; num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; blocksize = 128; - readsize = 256; read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; @@ -9931,85 +12316,21 @@ part # m168 writepage = "0100.1100--000a.aaaa--aaxx.xxxx--xxxx.xxxx"; ; - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - memory "efuse" - size = 1; initval = 0xf9; bitmask = 0x07; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" size = 1024; - offset = 0x100; ; ; -#------------------------------------------------------------ -# ATmega168A -#------------------------------------------------------------ - -part parent "m168" # m168a - desc = "ATmega168A"; - id = "m168a"; - variants = - "ATmega168A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega168A-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168A-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168A-CCU: UFBGA32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168A-MMH: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168A-MMHR: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168A-MUR: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168A-PU: PDIP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 100; -; - #------------------------------------------------------------ # ATmega168P #------------------------------------------------------------ @@ -10037,6 +12358,26 @@ part parent "m168" # m168p signature = 0x1e 0x94 0x0b; ; +#------------------------------------------------------------ +# ATmega168A +#------------------------------------------------------------ + +part parent "m168" # m168a + desc = "ATmega168A"; + id = "m168a"; + variants = + "ATmega168A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega168A-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168A-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168A-CCU: UFBGA32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168A-MMH: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168A-MMHR: VQFN28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168A-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168A-MUR: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168A-PU: PDIP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 100; +; + #------------------------------------------------------------ # ATmega168PA #------------------------------------------------------------ @@ -10063,829 +12404,11 @@ part parent "m168" # m168pa signature = 0x1e 0x94 0x0b; ; -#------------------------------------------------------------ -# ATmega168PB -#------------------------------------------------------------ - -part parent "m168" # m168pb - desc = "ATmega168PB"; - id = "m168pb"; - variants = - "ATmega168PB-AN: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168PB-ANR: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168PB-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168PB-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168PB-MN: VQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168PB-MU: VFQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega168PB-MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 103; - n_interrupts = 27; - chip_erase_delay = 10500; - signature = 0x1e 0x94 0x15; -; - -#------------------------------------------------------------ -# ATtiny828 -#------------------------------------------------------------ - -part # t828 - desc = "ATtiny828"; - id = "t828"; - variants = - "ATtiny828: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.62 V, 5.5 V]", - "ATtiny828-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny828-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny828-MU: QFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny828-MUR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 35; - n_interrupts = 26; - n_boot_sections = 4; - boot_section_size = 256; - stk500_devcode = 0x86; - chip_erase_delay = 15000; - pagel = 0xd7; - bs2 = 0xc2; -# avr910_devcode = 0x??; - signature = 0x1e 0x93 0x14; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 256; - page_size = 4; - min_write_delay = 3600; - max_write_delay = 3600; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x6e; - bitmask = 0xf3; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0xf7; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.1iii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATtiny828R -#------------------------------------------------------------ - -part parent "t828" # t828r - desc = "ATtiny828R"; - id = "t828r"; - variants = - "ATtiny828R-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny828R-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]"; - mcuid = 36; -; - -#------------------------------------------------------------ -# ATtiny87 -#------------------------------------------------------------ - -part # t87 - desc = "ATtiny87"; - id = "t87"; - variants = - "ATtiny87: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny87-MU: VQFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny87-MUR: VQFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny87-SU: SOIC20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny87-SUR: SOIC20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny87-XU: TSSOP20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny87-XUR: TSSOP20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 27; - n_interrupts = 20; -# no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 15000; - pagel = 0xb3; - bs2 = 0xb2; - signature = 0x1e 0x93 0x87; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, - 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, - 0x06, 0x16, 0x46, 0x56, 0x0a, 0x1a, 0x4a, 0x5a, - 0x1e, 0x7c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 128; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--xxxx.xxii"; - ; - - # ATtiny87 has signature bytes 0x1E 0x93 0x87 - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATtiny167 -#------------------------------------------------------------ - -part # t167 - desc = "ATtiny167"; - id = "t167"; - variants = - "ATtiny167: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny167-A15XD: TSSOP20, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny167-MMU: WQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny167-MMUR: WQFN20, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATtiny167-MU: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny167-MUR: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny167-SU: SOIC20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny167-SUR: SOIC20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny167-XU: TSSOP20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny167-XUR: TSSOP20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 29; - n_interrupts = 20; -# no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -# avr910_devcode = 0x??; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 15000; - pagel = 0xb3; - bs2 = 0xb2; - signature = 0x1e 0x94 0x87; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, - 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, - 0x06, 0x16, 0x46, 0x56, 0x0a, 0x1a, 0x4a, 0x5a, - 0x1e, 0x7c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--000a.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--xxxx.xxii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATtiny48 -#------------------------------------------------------------ - -part # t48 - desc = "ATtiny48"; - id = "t48"; - variants = - "ATtiny48-AU: TQFP32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-AUR: TQFP32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-CCU: UFBGA32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-MMH: VQFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-MMHR: VQFN28, Fmax=12 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-MMU: MLF28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-MMUR: VQFN28, Fmax=12 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-MU: MLF32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-MUR: VQFN32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny48-PU: PDIP28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 23; - n_interrupts = 20; - stk500_devcode = 0x73; - chip_erase_delay = 15000; - pagel = 0xd7; - bs2 = 0xc2; -# avr910_devcode = 0x??; - signature = 0x1e 0x92 0x09; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 64; - page_size = 4; - min_write_delay = 3600; - max_write_delay = 3600; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x6e; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 256; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATtiny88 -#------------------------------------------------------------ - -part # t88 - desc = "ATtiny88"; - id = "t88"; - variants = - "ATtiny88-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-AUR: TQFP32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-CCU: UFBGA32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-MMH: VQFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-MMHR: VQFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-MMU: QFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-MMUR: QFN28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-MU: QFN32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-MUR: VQFN32, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny88-PU: PDIP28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 28; - n_interrupts = 20; - stk500_devcode = 0x73; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc2; -# avr910_devcode = 0x??; - signature = 0x1e 0x93 0x11; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 64; - page_size = 4; - min_write_delay = 3600; - max_write_delay = 3600; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x6e; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - #------------------------------------------------------------ # ATmega328 #------------------------------------------------------------ -part # m328 +part parent "m48" # m328 desc = "ATmega328"; id = "m328"; variants = @@ -10896,81 +12419,26 @@ part # m328 "ATmega328-MU: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega328-MUR: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega328-PU: PDIP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 118; - n_interrupts = 26; n_boot_sections = 4; boot_section_size = 512; stk500_devcode = 0x86; chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc2; # avr910_devcode = 0x??; signature = 0x1e 0x95 0x14; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 1024; - page_size = 4; - min_write_delay = 3600; - max_write_delay = 3600; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; read = "1010.0000--000x.xxaa--aaaa.aaaa--oooo.oooo"; write = "1100.0000--000x.xxaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" - paged = yes; size = 0x8000; page_size = 128; num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; blocksize = 128; - readsize = 256; read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; @@ -10978,62 +12446,21 @@ part # m328 writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; ; - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - memory "hfuse" - size = 1; initval = 0xd9; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; ; memory "efuse" - size = 1; - initval = 0xff; bitmask = 0x07; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" size = 2048; - offset = 0x100; ; ; @@ -11063,6 +12490,71 @@ part parent "m328" # m328p signature = 0x1e 0x95 0x0f; ; +#------------------------------------------------------------ +# ATmega48PB +#------------------------------------------------------------ + +part parent "m48" # m48pb + desc = "ATmega48PB"; + id = "m48pb"; + variants = + "ATmega48PB-AN: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48PB-ANR: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48PB-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48PB-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48PB-MN: VQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48PB-MNR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega48PB-MU: VFQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega48PB-MUR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; + mcuid = 71; + n_interrupts = 27; + chip_erase_delay = 10500; + signature = 0x1e 0x92 0x10; +; + +#------------------------------------------------------------ +# ATmega88PB +#------------------------------------------------------------ + +part parent "m88" # m88pb + desc = "ATmega88PB"; + id = "m88pb"; + variants = + "ATmega88PB-AN: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88PB-ANR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88PB-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88PB-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88PB-MN: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88PB-MNR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega88PB-MU: VFQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega88PB-MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 83; + n_interrupts = 27; + chip_erase_delay = 10500; + signature = 0x1e 0x93 0x16; +; + +#------------------------------------------------------------ +# ATmega168PB +#------------------------------------------------------------ + +part parent "m168" # m168pb + desc = "ATmega168PB"; + id = "m168pb"; + variants = + "ATmega168PB-AN: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168PB-ANR: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168PB-AU: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168PB-AUR: TQFP32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168PB-MN: VQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168PB-MU: VFQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega168PB-MUR: VQFN32, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 103; + n_interrupts = 27; + chip_erase_delay = 10500; + signature = 0x1e 0x94 0x15; +; + #------------------------------------------------------------ # ATmega328PB #------------------------------------------------------------ @@ -11107,26 +12599,39 @@ part parent "m328" # m328pb ; #------------------------------------------------------------ -# ATmega64M1 +# ATmega169 #------------------------------------------------------------ -part # m64m1 - desc = "ATmega64M1"; - id = "m64m1"; +part parent ".classic" # m169 + desc = "ATmega169"; + id = "m169"; variants = - "ATmega64M1-15MD: VQFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega64M1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64M1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 76; - n_interrupts = 31; + "ATmega169: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega169-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169-16MI: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169-16MU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169L-4AC: TQFP64, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169L-4MC: VFQFN64, Fmax=4 MHz, T=[0 C, 70 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169L-8AI: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169L-8MI: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169V-1AC: TQFP64, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169V-1MC: VFQFN64, Fmax=1 MHz, T=[0 C, 70 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169V-8AI: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169V-8MI: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169V-8MU: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; + mcuid = 104; + n_interrupts = 23; n_boot_sections = 4; - boot_section_size = 1024; + boot_section_size = 256; + stk500_devcode = 0x85; + avr910_devcode = 0x78; chip_erase_delay = 9000; pagel = 0xd7; - bs2 = 0xe2; - signature = 0x1e 0x96 0x84; - reset = io; + bs2 = 0xa0; + signature = 0x1e 0x94 0x05; timeout = 200; stabdelay = 100; cmdexedelay = 25; @@ -11141,60 +12646,53 @@ part # m64m1 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; hventerstabdelay = 100; latchcycles = 5; togglevtg = 1; poweroffdelay = 15; resetdelayms = 1; hvleavestabdelay = 15; - resetdelay = 15; chiperasepolltimeout = 10; programfusepolltimeout = 5; programlockpolltimeout = 5; idr = 0x31; spmcr = 0x57; eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + ocdrev = 2; memory "eeprom" - size = 2048; - page_size = 8; - min_write_delay = 3600; - max_write_delay = 3600; + size = 512; + page_size = 4; + min_write_delay = 9000; + max_write_delay = 9000; + readback = 0xff 0xff; mode = 0x41; - delay = 10; - blocksize = 8; + delay = 20; + blocksize = 4; readsize = 256; - read = "1010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.0aaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--0000.0aaa--aaaa.a000--xxxx.xxxx"; + read = "1010.0000--xxxx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" paged = yes; - size = 0x10000; - page_size = 256; - num_pages = 256; + size = 0x4000; + page_size = 128; + num_pages = 128; min_write_delay = 4500; max_write_delay = 4500; + readback = 0xff 0xff; mode = 0x41; - delay = 10; - blocksize = 256; + delay = 6; + blocksize = 128; readsize = 256; - read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.0000--0aaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.0000--0aaa.aaaa--iiii.iiii"; - writepage = "0100.1100--0aaa.aaaa--a000.0000--xxxx.xxxx"; + read_lo = "0010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--xxxa.aaaa--aaxx.xxxx--xxxx.xxxx"; ; memory "lfuse" @@ -11208,7 +12706,7 @@ part # m64m1 memory "hfuse" size = 1; - initval = 0xd9; + initval = 0x99; min_write_delay = 4500; max_write_delay = 4500; read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; @@ -11218,79 +12716,198 @@ part # m64m1 memory "efuse" size = 1; initval = 0xff; - bitmask = 0x3f; + bitmask = 0x0f; min_write_delay = 4500; max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--11oo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--11ii.iiii"; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; min_write_delay = 4500; max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" - size = 4096; - offset = 0x100; + size = 1024; ; ; #------------------------------------------------------------ -# ATmega32M1 +# ATmega169P #------------------------------------------------------------ -part parent "m64m1" # m32m1 - desc = "ATmega32M1"; - id = "m32m1"; +part parent "m169" # m169p + desc = "ATmega169P"; + id = "m169p"; variants = - "ATmega32M1: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega32M1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32M1-AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32M1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 63; + "ATmega169P: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega169P-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169P-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169P-16MCH: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169P-16MCHR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega169P-16MCU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169P-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega169P-16MUR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega169PV-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PV-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PV-8MCH: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PV-8MCHR: QFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega169PV-8MCU: VQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PV-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PV-8MUR: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 106; + reset = io; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelay = 15; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + readback = 0x00 0x00; + ; + + memory "flash" + readback = 0x00 0x00; + delay = 10; + ; +; + +#------------------------------------------------------------ +# ATmega169A +#------------------------------------------------------------ + +part parent "m169" # m169a + desc = "ATmega169A"; + id = "m169a"; + variants = + "ATmega169A-AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169A-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169A-MCH: DRQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169A-MN: QFN64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169A-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169A-MUR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 105; + signature = 0x1e 0x94 0x11; + reset = io; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelay = 15; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + readback = 0x00 0x00; + ; + + memory "flash" + readback = 0x00 0x00; + delay = 10; + ; +; + +#------------------------------------------------------------ +# ATmega169PA +#------------------------------------------------------------ + +part parent "m169" # m169pa + desc = "ATmega169PA"; + id = "m169pa"; + variants = + "ATmega169PA-AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PA-ANR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PA-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PA-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PA-MCH: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PA-MCHR: QFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega169PA-MN: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PA-MNR: QFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega169PA-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega169PA-MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 107; + reset = io; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelay = 15; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + readback = 0x00 0x00; + ; + + memory "flash" + readback = 0x00 0x00; + delay = 10; + ; +; + +#------------------------------------------------------------ +# ATmega329 +#------------------------------------------------------------ + +part parent "m169" # m329 + desc = "ATmega329"; + id = "m329"; + variants = + "ATmega329: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega329-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega329-16AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega329-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega329-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega329V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329V-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 121; boot_section_size = 512; - signature = 0x1e 0x95 0x84; + stk500_devcode = 0x00; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x95 0x03; + reset = io; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelay = 15; + ocdrev = 3; memory "eeprom" size = 1024; - page_size = 4; - blocksize = 4; - read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; + readback = 0x00 0x00; + delay = 10; + read = "1010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" size = 0x8000; - page_size = 128; - blocksize = 128; - read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.0000--00aa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.0000--00aa.aaaa--iiii.iiii"; - writepage = "0100.1100--00aa.aaaa--aa00.0000--xxxx.xxxx"; + num_pages = 256; + readback = 0x00 0x00; + delay = 10; + read_lo = "0010.0000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--xaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "efuse" + bitmask = 0x07; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; ; memory "sram" @@ -11299,349 +12916,417 @@ part parent "m64m1" # m32m1 ; #------------------------------------------------------------ -# ATmega16M1 +# ATmega329P #------------------------------------------------------------ -part parent "m32m1" # m16m1 - desc = "ATmega16M1"; - id = "m16m1"; +part parent "m329" # m329p + desc = "ATmega329P"; + id = "m329p"; variants = - "ATmega16M1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16M1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 54; - signature = 0x1e 0x94 0x84; + "ATmega329P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega329P-20AN: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329P-20ANR: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega329P-20AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega329P-20AUR: TQFP64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega329P-20MN: VQFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", + "ATmega329P-20MNR: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega329P-20MU: MLF64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega329P-20MUR: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega329PV-10AU: TQFP64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PV-10AUR: TQFP64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PV-10MN: VQFN64, Fmax=10 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PV-10MU: MLF64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PV-10MUR: VQFN64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 123; + signature = 0x1e 0x95 0x0b; memory "eeprom" - size = 512; - read = "1010.0000--0000.000a--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.000a--aaaa.aaaa--iiii.iiii"; - writepage = "1100.0010--0000.000a--aaaa.aa00--xxxx.xxxx"; + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega329A +#------------------------------------------------------------ + +part parent "m329" # m329a + desc = "ATmega329A"; + id = "m329a"; + variants = + "ATmega329A-AN: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329A-AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329A-AUR: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega329A-MN: QFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329A-MU: VQFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 122; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega329PA +#------------------------------------------------------------ + +part parent "m329" # m329pa + desc = "ATmega329PA"; + id = "m329pa"; + variants = + "ATmega329PA-AN: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PA-AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PA-AUR: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PA-MN: QFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PA-MU: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega329PA-MUR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; + mcuid = 124; + signature = 0x1e 0x95 0x0b; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega3290 +#------------------------------------------------------------ + +part parent "m169" # m3290 + desc = "ATmega3290"; + id = "m3290"; + variants = + "ATmega3290: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega3290-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega3290-16AUR: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega3290V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega3290V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 150; + n_interrupts = 25; + boot_section_size = 512; + stk500_devcode = 0x00; + avr910_devcode = 0x75; + signature = 0x1e 0x95 0x04; + reset = io; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelay = 15; + ocdrev = 3; + + memory "eeprom" + size = 1024; + readback = 0x00 0x00; + delay = 10; + read = "1010.0000--xxxx.xxaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xxaa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" - size = 0x4000; - num_pages = 128; - read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; - writepage = "0100.1100--000a.aaaa--aa00.0000--xxxx.xxxx"; + size = 0x8000; + num_pages = 256; + readback = 0x00 0x00; + delay = 10; + read_lo = "0010.0000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--xaaa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--xaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "efuse" + bitmask = 0x07; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; ; memory "sram" - size = 1024; + size = 2048; ; ; #------------------------------------------------------------ -# ATmega32C1 +# ATmega3290P #------------------------------------------------------------ -part parent "m32m1" # m32c1 - desc = "ATmega32C1"; - id = "m32c1"; +part parent "m3290" # m3290p + desc = "ATmega3290P"; + id = "m3290p"; variants = - "ATmega32C1-15AD: TQFP32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32C1-15AZ: TQFP32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32C1-15MD: VQFN32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32C1-15MZ: VQFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32C1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32C1-ESAD: TQFP32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32C1-ESMD: VQFN32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32C1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 62; - signature = 0x1e 0x95 0x86; -; - -#------------------------------------------------------------ -# ATmega64C1 -#------------------------------------------------------------ - -part parent "m64m1" # m64c1 - desc = "ATmega64C1"; - id = "m64c1"; - variants = - "ATmega64C1-15AD: TQFP32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64C1-15AZ: TQFP32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64C1-15MD: VQFN32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64C1-15MZ: VQFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64C1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64C1-ESAZ: TQFP32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64C1-ESMZ: VQFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATmega64C1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 75; - signature = 0x1e 0x96 0x86; -; - -#------------------------------------------------------------ -# ATA5505 -#------------------------------------------------------------ - -part parent "t167" # ata5505 - desc = "ATA5505"; - id = "ata5505"; - variants = - "ATA5505: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATA5505-P3QW: VFQFN38, Fmax=N/A, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 198; - chip_erase_delay = 4000; - reset = dedicated; + "ATmega3290P: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega3290P-20AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega3290P-20AUR: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega3290PV-10AU: TQFP100, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega3290PV-10AUR: TQFP100, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 152; + signature = 0x1e 0x95 0x0c; memory "eeprom" - max_write_delay = 4000; - ; - - memory "lfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "hfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "efuse" - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--1111.111o"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; - ; - - memory "lock" - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--1111.11oo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; + min_write_delay = 3600; + max_write_delay = 3600; ; ; #------------------------------------------------------------ -# ATA6612C +# ATmega3290A #------------------------------------------------------------ -part parent "m88" # ata6612c - desc = "ATA6612C"; - id = "ata6612c"; +part parent "m3290" # m3290a + desc = "ATmega3290A"; + id = "m3290a"; variants = - "ATA6612C-PLQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATA6612C-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 216; - chip_erase_delay = 4000; + "ATmega3290A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega3290A-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega3290A-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 151; memory "eeprom" - min_write_delay = 4000; - max_write_delay = 4000; - ; - - memory "efuse" - read = "0101.0000--0000.1000--xxxx.xxxx--1111.1ooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; - ; - - memory "lock" - read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; + min_write_delay = 3600; + max_write_delay = 3600; ; ; #------------------------------------------------------------ -# ATA6613C +# ATmega3290PA #------------------------------------------------------------ -part parent "m168" # ata6613c - desc = "ATA6613C"; - id = "ata6613c"; +part parent "m3290" # m3290pa + desc = "ATmega3290PA"; + id = "m3290pa"; variants = - "ATA6613C-PLQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATA6613C-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 217; - - memory "efuse" - read = "0101.0000--0000.1000--xxxx.xxxx--1111.1ooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; - ; - - memory "lock" - read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; - ; -; - -#------------------------------------------------------------ -# ATA6614Q -#------------------------------------------------------------ - -part parent "m328" # ata6614q - desc = "ATA6614Q"; - id = "ata6614q"; - variants = - "ATA6614Q-PLQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATA6614Q-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 218; - signature = 0x1e 0x95 0x0f; - - memory "efuse" - read = "0101.0000--0000.1000--xxxx.xxxx--1111.1ooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; - ; - - memory "lock" - read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; - ; -; - -#------------------------------------------------------------ -# ATA6616C -#------------------------------------------------------------ - -part parent "t87" # ata6616c - desc = "ATA6616C"; - id = "ata6616c"; - variants = - "ATA6616C-P3PW: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATA6616C-P3QW: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATA6616C-P3QW-1: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 219; - chip_erase_delay = 4000; - reset = dedicated; + "ATmega3290PA: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega3290PA-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega3290PA-AUR: TQFP100, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; + mcuid = 153; + signature = 0x1e 0x95 0x0c; memory "eeprom" - max_write_delay = 4000; + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega649 +#------------------------------------------------------------ + +part parent "m169" # m649 + desc = "ATmega649"; + id = "m649"; + variants = + "ATmega649: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega649-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega649-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega649-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega649-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega649V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega649V-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", + "ATmega649V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega649V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 135; + boot_section_size = 1024; + stk500_devcode = 0x00; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x96 0x03; + reset = io; + resetdelay = 15; + ocdrev = 3; + + memory "eeprom" + size = 2048; + page_size = 8; + readback = 0x00 0x00; + delay = 10; + read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; ; memory "flash" - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - writepage = "0100.1100--0000.aaaa--aa00.0000--xxxx.xxxx"; - ; - - memory "lfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "hfuse" - min_write_delay = 4500; - max_write_delay = 4500; + size = 0x10000; + page_size = 256; + num_pages = 256; + readback = 0x00 0x00; + delay = 10; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; ; memory "efuse" - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--1111.111o"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; + bitmask = 0x07; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; ; - memory "lock" - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--1111.11oo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; + memory "sram" + size = 4096; ; ; #------------------------------------------------------------ -# ATA6617C +# ATmega649P #------------------------------------------------------------ -part parent "t167" # ata6617c - desc = "ATA6617C"; - id = "ata6617c"; +part parent "m649" # m649p + desc = "ATmega649P"; + id = "m649p"; variants = - "ATA6617C-P3QW: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATA6617C-P3QW-1: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 220; - chip_erase_delay = 4000; - reset = dedicated; + "ATmega649P-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega649P-AUR: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", + "ATmega649P-MU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega649P-MUR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; + mcuid = 137; + signature = 0x1e 0x96 0x0b; memory "eeprom" - max_write_delay = 4000; - ; - - memory "lfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "hfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "efuse" - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--1111.111o"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; - ; - - memory "lock" - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--1111.11oo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; + min_write_delay = 3600; + max_write_delay = 3600; ; ; #------------------------------------------------------------ -# ATA664251 +# ATmega649A #------------------------------------------------------------ -part parent "t167" # ata664251 - desc = "ATA664251"; - id = "ata664251"; +part parent "m649" # m649a + desc = "ATmega649A"; + id = "m649a"; variants = - "ATA664251: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATA664251-WGQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATA664251-WGQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 225; - chip_erase_delay = 4000; - reset = dedicated; + "ATmega649A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega649A-AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega649A-MU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega649A-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 136; memory "eeprom" - max_write_delay = 4000; - ; - - memory "lfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "hfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "efuse" - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--1111.111o"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; - ; - - memory "lock" - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--1111.11oo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; + min_write_delay = 3600; + max_write_delay = 3600; ; ; #------------------------------------------------------------ -# ATmega16HVA +# ATmega6490 #------------------------------------------------------------ -part # m16hva - desc = "ATmega16HVA"; - id = "m16hva"; +part parent "m169" # m6490 + desc = "ATmega6490"; + id = "m6490"; variants = - "ATmega16HVA: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 4.5 V]", - "ATmega16HVA-4CKU: WFLGA36, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", - "ATmega16HVA-4CKUR: WFLGA36, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", - "ATmega16HVA-4TU: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", - "ATmega16HVA-4TUR: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]"; + "ATmega6490: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega6490-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", + "ATmega6490-16AUR: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega6490V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega6490V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; + mcuid = 157; + n_interrupts = 25; + boot_section_size = 1024; + stk500_devcode = 0x00; + avr910_devcode = 0x75; + signature = 0x1e 0x96 0x04; + reset = io; + resetdelay = 15; + ocdrev = 3; + + memory "eeprom" + size = 2048; + page_size = 8; + readback = 0x00 0x00; + delay = 10; + read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x10000; + page_size = 256; + num_pages = 256; + readback = 0x00 0x00; + delay = 10; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; + ; + + memory "efuse" + bitmask = 0x07; + write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# ATmega6490P +#------------------------------------------------------------ + +part parent "m6490" # m6490p + desc = "ATmega6490P"; + id = "m6490p"; + variants = + "ATmega6490P: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega6490P-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega6490P-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; + mcuid = 159; + signature = 0x1e 0x96 0x0c; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega6490A +#------------------------------------------------------------ + +part parent "m6490" # m6490a + desc = "ATmega6490A"; + id = "m6490a"; + variants = + "ATmega6490A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATmega6490A-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", + "ATmega6490A-AUR: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; + mcuid = 158; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; +; + +#------------------------------------------------------------ +# ATmega8HVA +#------------------------------------------------------------ + +part parent ".classic" # m8hva + desc = "ATmega8HVA"; + id = "m8hva"; + variants = + "ATmega8HVA: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 4.5 V]", + "ATmega8HVA-4CKU: WFLGA36, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", + "ATmega8HVA-4CKUR: WFLGA36, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", + "ATmega8HVA-4TU: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", + "ATmega8HVA-4TUR: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; - mcuid = 51; + mcuid = 47; n_interrupts = 21; chip_erase_delay = 4000; - signature = 0x1e 0x94 0x0c; + signature = 0x1e 0x93 0x10; reset = io; timeout = 200; stabdelay = 100; @@ -11679,9 +13364,6 @@ part # m16hva spmcr = 0x57; eecr = 0x3f; ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 256; @@ -11700,20 +13382,20 @@ part # m16hva memory "flash" paged = yes; - size = 0x4000; + size = 8192; page_size = 128; - num_pages = 128; + num_pages = 64; min_write_delay = 4500; max_write_delay = 4500; mode = 0x41; delay = 10; blocksize = 128; readsize = 256; - read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; loadpage_lo = "0100.0000--0000.0000--00aa.aaaa--iiii.iiii"; loadpage_hi = "0100.1000--0000.0000--00aa.aaaa--iiii.iiii"; - writepage = "0100.1100--000a.aaaa--aa00.0000--xxxx.xxxx"; + writepage = "0100.1100--0000.aaaa--aa00.0000--xxxx.xxxx"; ; memory "fuse" @@ -11726,8 +13408,6 @@ part # m16hva ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x03; min_write_delay = 4500; max_write_delay = 4500; @@ -11735,49 +13415,272 @@ part # m16hva write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; ; - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - memory "sram" size = 512; - offset = 0x100; ; ; #------------------------------------------------------------ -# ATmega8HVA +# ATmega16HVA #------------------------------------------------------------ -part parent "m16hva" # m8hva - desc = "ATmega8HVA"; - id = "m8hva"; +part parent "m8hva" # m16hva + desc = "ATmega16HVA"; + id = "m16hva"; variants = - "ATmega8HVA: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 4.5 V]", - "ATmega8HVA-4CKU: WFLGA36, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", - "ATmega8HVA-4CKUR: WFLGA36, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", - "ATmega8HVA-4TU: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", - "ATmega8HVA-4TUR: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]"; - mcuid = 47; - signature = 0x1e 0x93 0x10; + "ATmega16HVA: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 4.5 V]", + "ATmega16HVA-4CKU: WFLGA36, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", + "ATmega16HVA-4CKUR: WFLGA36, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", + "ATmega16HVA-4TU: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", + "ATmega16HVA-4TUR: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]"; + mcuid = 51; + signature = 0x1e 0x94 0x0c; memory "flash" - size = 8192; - num_pages = 64; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - writepage = "0100.1100--0000.aaaa--aa00.0000--xxxx.xxxx"; + size = 0x4000; + num_pages = 128; + read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--000a.aaaa--aa00.0000--xxxx.xxxx"; + ; +; + +#------------------------------------------------------------ +# ATmega32HVE2 +#------------------------------------------------------------ + +part parent ".classic" # m32hve2 + desc = "ATmega32HVE2"; + id = "m32hve2"; + variants = + "ATmega32HVE2-PLPW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]", + "ATmega32HVE2-PLQW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; + mcuid = 379; + n_interrupts = 25; + n_boot_sections = 4; + boot_section_size = 512; + chip_erase_delay = 4000; + signature = 0x1e 0x95 0x13; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + hvsp_controlstack = + 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, + 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, + 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, + 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0f; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 70; + hvleavestabdelay = 101; + resetdelay = 26; + chiperasepolltimeout = 40; + chiperasetime = 1; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + synchcycles = 6; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 1024; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x8000; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--00aa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--00aa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--aa00.0000--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0xd7; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xf9; + bitmask = 0x0f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--1111.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--1111.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# ATmega64HVE2 +#------------------------------------------------------------ + +part parent ".classic" # m64hve2 + desc = "ATmega64HVE2"; + id = "m64hve2"; + variants = + "ATmega64HVE2: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[3.0 V, 3.6 V]", + "ATmega64HVE2-PLPW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]", + "ATmega64HVE2-PLQW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; + mcuid = 77; + n_interrupts = 25; + n_boot_sections = 4; + boot_section_size = 1024; + chip_erase_delay = 4000; + signature = 0x1e 0x96 0x10; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + hvsp_controlstack = + 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, + 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, + 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, + 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0f; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 70; + hvleavestabdelay = 101; + resetdelay = 26; + chiperasepolltimeout = 40; + chiperasetime = 1; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + synchcycles = 6; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 1024; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x10000; + page_size = 128; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--00aa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--00aa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--aa00.0000--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0xd7; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xf9; + bitmask = 0x0f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--1111.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--1111.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; + ; + + memory "sram" + size = 4096; ; ; @@ -11785,7 +13688,7 @@ part parent "m16hva" # m8hva # ATmega16HVB #------------------------------------------------------------ -part # m16hvb +part parent ".classic" # m16hvb desc = "ATmega16HVB"; id = "m16hvb"; variants = @@ -11832,9 +13735,6 @@ part # m16hvb spmcr = 0x57; eecr = 0x3f; ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 512; @@ -11889,33 +13789,14 @@ part # m16hvb ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; min_write_delay = 4500; max_write_delay = 4500; read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" size = 1024; - offset = 0x100; ; ; @@ -11978,536 +13859,24 @@ part parent "m32hvb" # m32hvbrevb ; #------------------------------------------------------------ -# ATmega64HVE2 +# ATmega16M1 #------------------------------------------------------------ -part # m64hve2 - desc = "ATmega64HVE2"; - id = "m64hve2"; +part parent ".classic" # m16m1 + desc = "ATmega16M1"; + id = "m16m1"; variants = - "ATmega64HVE2: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[3.0 V, 3.6 V]", - "ATmega64HVE2-PLPW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]", - "ATmega64HVE2-PLQW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; - mcuid = 77; - n_interrupts = 25; + "ATmega16M1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16M1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 54; + n_interrupts = 31; n_boot_sections = 4; - boot_section_size = 1024; - chip_erase_delay = 4000; - signature = 0x1e 0x96 0x10; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, - 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0f; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 1; - resetdelayus = 70; - hvleavestabdelay = 101; - resetdelay = 26; - chiperasepolltimeout = 40; - chiperasetime = 1; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 1024; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4000; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x10000; - page_size = 128; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.0000--00aa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.0000--00aa.aaaa--iiii.iiii"; - writepage = "0100.1100--0aaa.aaaa--aa00.0000--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0xd7; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xf9; - bitmask = 0x0f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--1111.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--1111.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega32HVE2 -#------------------------------------------------------------ - -part parent "m64hve2" # m32hve2 - desc = "ATmega32HVE2"; - id = "m32hve2"; - variants = - "ATmega32HVE2-PLPW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]", - "ATmega32HVE2-PLQW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]"; - mcuid = 379; boot_section_size = 512; - signature = 0x1e 0x95 0x13; - - memory "flash" - size = 0x8000; - num_pages = 256; - ; -; - -#------------------------------------------------------------ -# ATtiny2313 -#------------------------------------------------------------ - -part # t2313 - desc = "ATtiny2313"; - id = "t2313"; - variants = - "ATtiny2313: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny2313-20MUR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny2313-20PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny2313-20SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny2313-20SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny2313V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313V-10MUR: WQFN20, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313V-10PU: PDIP20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313V-10SUR: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 42; - n_interrupts = 19; - stk500_devcode = 0x23; -# Use the ATtiny26 devcode: - avr910_devcode = 0x5e; - chip_erase_delay = 9000; - pagel = 0xd4; - bs2 = 0xd6; - signature = 0x1e 0x91 0x0a; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, - 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, - 0x26, 0x36, 0x66, 0x76, 0x2a, 0x3a, 0x6a, 0x7a, - 0x2e, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb2, 0x0f, 0x1f; - eeprom_instr = - 0xbb, 0xfe, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xba, 0x0f, 0xb2, 0x0f, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x1f; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 0; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 128; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 32; - readsize = 256; - read_lo = "0010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.00aa--aaaa.aaaa--oooo.oooo"; -# The information in the data sheet of April/2004 is wrong, this works: - loadpage_lo = "0100.0000--000x.xxxx--xxxx.aaaa--iiii.iiii"; -# The information in the data sheet of April/2004 is wrong, this works: - loadpage_hi = "0100.1000--000x.xxxx--xxxx.aaaa--iiii.iiii"; -# The information in the data sheet of April/2004 is wrong, this works: - writepage = "0100.1100--0000.00aa--aaaa.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x64; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - # ATtiny2313 has signature bytes 0x1E 0x91 0x0A - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - -# The Tiny2313 has calibration data for both 4 MHz and 8 MHz. -# The information in the data sheet of April/2004 is wrong, this works: - - memory "calibration" - size = 2; - read = "0011.1000--000x.xxxx--0000.000a--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 128; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny2313A -#------------------------------------------------------------ - -part parent "t2313" # t2313a - desc = "ATtiny2313A"; - id = "t2313a"; - variants = - "ATtiny2313A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313A-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313A-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313A-MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313A-MUR: WQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313A-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313A-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny2313A-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 43; - n_interrupts = 21; - idr = 0x27; - - memory "lfuse" - initval = 0x62; - ; -; - -#------------------------------------------------------------ -# ATtiny4313 -#------------------------------------------------------------ - -part # t4313 - desc = "ATtiny4313"; - id = "t4313"; - variants = - "ATtiny4313: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny4313-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny4313-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny4313-MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny4313-MUR: MLF20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny4313-PU: PDIP20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny4313-SU: SOIC20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny4313-SUR: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 44; - n_interrupts = 21; - stk500_devcode = 0x23; -# Use the ATtiny26 devcode: - avr910_devcode = 0x5e; - chip_erase_delay = 9000; - pagel = 0xd4; - bs2 = 0xd6; - signature = 0x1e 0x92 0x0d; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, - 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, - 0x26, 0x36, 0x66, 0x76, 0x2a, 0x3a, 0x6a, 0x7a, - 0x2e, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb2, 0x0f, 0x1f; - eeprom_instr = - 0xbb, 0xfe, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xba, 0x0f, 0xb2, 0x0f, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x27; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 0; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 256; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 32; - readsize = 256; - read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.0aaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - # ATtiny4313 has signature bytes 0x1E 0x92 0x0D - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 2; - read = "0011.1000--000x.xxxx--0000.000a--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 256; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# AT90PWM1 -#------------------------------------------------------------ - -part # pwm1 - desc = "AT90PWM1"; - id = "pwm1"; - variants = - "AT90PWM1: SOIC24, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM1-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM1-16MUR: QFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM1-16SU: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 166; - n_interrupts = 32; - n_boot_sections = 4; - boot_section_size = 256; chip_erase_delay = 9000; pagel = 0xd7; bs2 = 0xe2; - signature = 0x1e 0x93 0x83; + signature = 0x1e 0x94 0x84; reset = io; timeout = 200; stabdelay = 100; @@ -12542,9 +13911,6 @@ part # pwm1 spmcr = 0x57; eecr = 0x3f; ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 512; @@ -12552,390 +13918,7 @@ part # pwm1 min_write_delay = 3600; max_write_delay = 3600; mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - read = "1010.0000--0000.000a--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.000a--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.000a--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.0000--000a.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.0000--000a.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaa0.0000--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf9; - bitmask = 0xb7; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--o1oo.1ooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--i1ii.1iii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# AT90PWM2 -#------------------------------------------------------------ - -part # pwm2 - desc = "AT90PWM2"; - id = "pwm2"; - variants = - "AT90PWM2: SOIC24, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM2-16SQ: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM2-16SQR: SOIC24, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 167; - n_interrupts = 32; - n_boot_sections = 4; - boot_section_size = 256; - stk500_devcode = 0x65; - chip_erase_delay = 9000; - pagel = 0xd8; - bs2 = 0xe2; -# avr910_devcode = ?; - signature = 0x1e 0x93 0x81; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - spmcr = 0x57; - eecr = 0x3f; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback = 0xff 0xff; - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback = 0xff 0xff; - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf9; - bitmask = 0xf7; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - # AT90PWM2 has signature bytes 0x1E 0x93 0x81 - memory "signature" - size = 3; - read = "0011.0000--00xx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# AT90PWM3 -#------------------------------------------------------------ - -# Completely identical to AT90PWM2 (including the signature!) - -part parent "pwm2" # pwm3 - desc = "AT90PWM3"; - id = "pwm3"; - variants = - "AT90PWM3: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM3-16MQ: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM3-16MQT: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 169; - resetdelay = 15; - idr = 0x31; - ocdrev = 1; - - memory "eeprom" - readback = 0x00 0x00; - delay = 5; - ; - - memory "flash" - readback = 0x00 0x00; - delay = 10; - ; - - memory "io" - size = 224; - offset = 0x20; - ; -; - -#------------------------------------------------------------ -# AT90PWM2B -#------------------------------------------------------------ -# Same as AT90PWM2 but different signature. - -part parent "pwm2" # pwm2b - desc = "AT90PWM2B"; - id = "pwm2b"; - variants = - "AT90PWM2B: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM2B-16SU: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM2B-16SUR: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 168; - signature = 0x1e 0x93 0x83; - resetdelay = 15; - idr = 0x31; - ocdrev = 1; - - memory "eeprom" - readback = 0x00 0x00; - delay = 5; - ; - - memory "flash" - readback = 0x00 0x00; - delay = 10; - ; - - memory "io" - size = 224; - offset = 0x20; - ; -; - -#------------------------------------------------------------ -# AT90PWM3B -#------------------------------------------------------------ - -# Completely identical to AT90PWM2B (including the signature!) - -part parent "pwm2b" # pwm3b - desc = "AT90PWM3B"; - id = "pwm3b"; - variants = - "AT90PWM3B: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM3B-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM3B-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 170; -; - -#------------------------------------------------------------ -# AT90PWM161 -#------------------------------------------------------------ - -part # pwm161 - desc = "AT90PWM161"; - id = "pwm161"; - variants = - "AT90PWM161: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM161-16MN: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM161-16MNR: QFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM161-16SN: SOIC20, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM161-16SNR: SOIC20, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 177; - n_interrupts = 20; - n_boot_sections = 4; - boot_section_size = 256; - chip_erase_delay = 9000; - pagel = 0xe2; - bs2 = 0xd6; - signature = 0x1e 0x94 0x8b; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0xc4, 0xe4, 0xc4, 0xe4, 0xcc, 0xec, 0xcc, 0xec, - 0xd4, 0xf4, 0xd4, 0xf4, 0xdc, 0xfc, 0xdc, 0xfc, - 0xc8, 0xe8, 0xd8, 0xf8, 0x4c, 0x6c, 0x5c, 0x7c, - 0xec, 0xbc, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 3600; - max_write_delay = 3600; - mode = 0x41; - delay = 5; blocksize = 4; readsize = 256; read = "1010.0000--0000.000a--aaaa.aaaa--oooo.oooo"; @@ -12953,7 +13936,7 @@ part # pwm161 max_write_delay = 4500; mode = 0x41; delay = 10; - blocksize = 64; + blocksize = 128; readsize = 256; read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; @@ -12982,101 +13965,365 @@ part # pwm161 memory "efuse" size = 1; - initval = 0xfd; + initval = 0xff; + bitmask = 0x3f; min_write_delay = 4500; max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; + read = "0101.0000--0000.1000--xxxx.xxxx--11oo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--11ii.iiii"; ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; min_write_delay = 4500; max_write_delay = 4500; read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" size = 1024; - offset = 0x100; ; ; #------------------------------------------------------------ -# AT90PWM81 +# ATmega32C1 #------------------------------------------------------------ -part parent "pwm161" # pwm81 - desc = "AT90PWM81"; - id = "pwm81"; +part parent "m16m1" # m32c1 + desc = "ATmega32C1"; + id = "m32c1"; variants = - "AT90PWM81: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM81-16MF: QFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM81-16MN: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM81-16SF: SOIC20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM81-16SN: SOIC20, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM81EP-16MN: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 173; - signature = 0x1e 0x93 0x88; + "ATmega32C1-15AD: TQFP32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32C1-15AZ: TQFP32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32C1-15MD: VQFN32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32C1-15MZ: VQFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32C1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32C1-ESAD: TQFP32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32C1-ESMD: VQFN32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32C1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 62; + signature = 0x1e 0x95 0x86; - memory "flash" - size = 8192; - page_size = 64; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.0000--000a.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.0000--000a.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaa0.0000--xxxx.xxxx"; + memory "eeprom" + size = 1024; + read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; ; - memory "sram" - size = 256; - ; -; - -#------------------------------------------------------------ -# AT90PWM316 -#------------------------------------------------------------ - -# Similar to AT90PWM3B, but with 16 kiB flash, 512 B EEPROM, and 1024 B SRAM. - -part parent "pwm3b" # pwm316 - desc = "AT90PWM316"; - id = "pwm316"; - variants = - "AT90PWM316: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM316-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM316-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 180; - boot_section_size = 512; - signature = 0x1e 0x94 0x83; - memory "flash" - size = 0x4000; - page_size = 128; + size = 0x8000; + num_pages = 256; read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--00xx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; + writepage = "0100.1100--00aa.aaaa--aa00.0000--xxxx.xxxx"; + ; + + memory "sram" + size = 2048; + ; +; + +#------------------------------------------------------------ +# ATmega32M1 +#------------------------------------------------------------ + +part parent "m16m1" # m32m1 + desc = "ATmega32M1"; + id = "m32m1"; + variants = + "ATmega32M1: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega32M1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32M1-AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32M1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 63; + signature = 0x1e 0x95 0x84; + + memory "eeprom" + size = 1024; + read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; + writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + size = 0x8000; + num_pages = 256; + read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--00aa.aaaa--aa00.0000--xxxx.xxxx"; + ; + + memory "sram" + size = 2048; + ; +; + +#------------------------------------------------------------ +# ATmega64C1 +#------------------------------------------------------------ + +part parent "m16m1" # m64c1 + desc = "ATmega64C1"; + id = "m64c1"; + variants = + "ATmega64C1-15AD: TQFP32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64C1-15AZ: TQFP32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64C1-15MD: VQFN32, Fmax=16 MHz, T=[-40 C, 150 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64C1-15MZ: VQFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64C1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64C1-ESAZ: TQFP32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64C1-ESMZ: VQFN32, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64C1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 75; + boot_section_size = 1024; + signature = 0x1e 0x96 0x86; + + memory "eeprom" + size = 2048; + page_size = 8; + blocksize = 8; + read = "1010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.0aaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--0000.0aaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x10000; + page_size = 256; + num_pages = 256; + blocksize = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--0aaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--0aaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--a000.0000--xxxx.xxxx"; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# ATmega64M1 +#------------------------------------------------------------ + +part parent "m16m1" # m64m1 + desc = "ATmega64M1"; + id = "m64m1"; + variants = + "ATmega64M1-15MD: VQFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATmega64M1-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega64M1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 76; + boot_section_size = 1024; + signature = 0x1e 0x96 0x84; + + memory "eeprom" + size = 2048; + page_size = 8; + blocksize = 8; + read = "1010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.0aaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; + writepage = "1100.0010--0000.0aaa--aaaa.a000--xxxx.xxxx"; + ; + + memory "flash" + size = 0x10000; + page_size = 256; + num_pages = 256; + blocksize = 256; + read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--0000.0000--0aaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--0000.0000--0aaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0aaa.aaaa--a000.0000--xxxx.xxxx"; + ; + + memory "sram" + size = 4096; + ; +; + +#------------------------------------------------------------ +# ATmega8U2 +#------------------------------------------------------------ + +part parent ".classic" # m8u2 + desc = "ATmega8U2"; + id = "m8u2"; + variants = + "ATmega8U2-AU: LQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8U2-AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8U2-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega8U2-MUR: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 48; + n_interrupts = 29; + n_boot_sections = 4; + boot_section_size = 512; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xc6; + signature = 0x1e 0x93 0x89; + usbpid = 0x2fee; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--0000.aaaa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--0000.aaaa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--aaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x5e; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xd9; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xf4; + bitmask = 0x0f; + min_write_delay = 9000; + max_write_delay = 9000; + read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATmega16U2 +#------------------------------------------------------------ + +part parent "m8u2" # m16u2 + desc = "ATmega16U2"; + id = "m16u2"; + variants = + "ATmega16U2-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16U2-AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16U2-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega16U2-MUR: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 56; + signature = 0x1e 0x94 0x89; + usbpid = 0x2fef; + + memory "flash" + size = 0x4000; + num_pages = 128; + ; +; + +#------------------------------------------------------------ +# ATmega32U2 +#------------------------------------------------------------ + +part parent "m8u2" # m32u2 + desc = "ATmega32U2"; + id = "m32u2"; + variants = + "ATmega32U2-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32U2-AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32U2-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", + "ATmega32U2-MUR: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 64; + signature = 0x1e 0x95 0x8a; + usbpid = 0x2ff0; + + memory "eeprom" + size = 1024; + num_pages = 256; + ; + + memory "flash" + size = 0x8000; + num_pages = 256; ; memory "sram" @@ -13084,2126 +14331,11 @@ part parent "pwm3b" # pwm316 ; ; -#------------------------------------------------------------ -# AT90PWM216 -#------------------------------------------------------------ -# Completely identical to AT90PWM316 (including the signature!) - -part parent "pwm316" # pwm216 - desc = "AT90PWM216"; - id = "pwm216"; - variants = - "AT90PWM216: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90PWM216-16SU: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "AT90PWM216-16SUR: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 179; -; - -#------------------------------------------------------------ -# ATtiny25 -#------------------------------------------------------------ - -part # t25 - desc = "ATtiny25"; - id = "t25"; - variants = - "ATtiny25: N/A, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[N/A, N/A]", - "ATtiny25-15ST: SOIC8, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20MF: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20MFR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20MUR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SN: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SNR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SSH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SSHR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SSN: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SSNR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SSU: SOIC8N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SSUR: SOIC8N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25-20SUR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-10MF: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10MFR: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10MUR: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10PU: PDIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SH: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SN: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SNR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SSH: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SSHR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SSN: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SSNR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SSU: SOIC8N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SSUR: SOIC8N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SU: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-10SUR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny25V-20MF: MLF20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-20SH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-20SN: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-20SSH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-20SSN: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-20SSU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny25V-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; - mcuid = 16; - n_interrupts = 15; -# no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -# avr910_devcode = ?; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 4500; - signature = 0x1e 0x91 0x08; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, - 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - flash_instr = 0xb4, 0x02, 0x12; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x02, 0xb4, 0x02, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 1; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - idr = 0x22; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 128; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 32; - readsize = 256; - read_lo = "0010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.00aa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxx.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxx.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.00aa--aaaa.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - # ATtiny25 has signature bytes 0x1E 0x91 0x08 - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 2; - read = "0011.1000--000x.xxxx--0000.000a--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 128; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny45 -#------------------------------------------------------------ - -part # t45 - desc = "ATtiny45"; - id = "t45"; - variants = - "ATtiny45: N/A, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[N/A, N/A]", - "ATtiny45-15SZ: SOIC8, Fmax=N/A, T=[-40 C, 85 C], Vcc=[N/A, N/A]", - "ATtiny45-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45-20MUR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45-20SUR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45-20XU: TSSOP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45-20XUR: TSSOP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny45V-10MUR: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny45V-10PU: PDIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny45V-10SH: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny45V-10SU: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny45V-10SUR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny45V-10XU: TSSOP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny45V-10XUR: TSSOP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny45V-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45V-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45V-20SH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45V-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny45V-20XU: TSSOP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; - mcuid = 22; - n_interrupts = 15; - stk500_devcode = 0x14; -# avr910_devcode = ?; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 4500; - signature = 0x1e 0x92 0x06; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, - 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - flash_instr = 0xb4, 0x02, 0x12; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x02, 0xb4, 0x02, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 1; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - idr = 0x22; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 256; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.0aaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - # ATtiny45 has signature bytes 0x1E 0x92 0x08 (data sheet 2586C-AVR-06/05 doc2586.pdf indicates otherwise) - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 2; - read = "0011.1000--000x.xxxx--0000.000a--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 256; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny85 -#------------------------------------------------------------ - -part # t85 - desc = "ATtiny85"; - id = "t85"; - variants = - "ATtiny85: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[N/A, N/A]", - "ATtiny85-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85-20MUR: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85-20SF: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny85-20SFR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85-20SUR: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny85V-10MUR: MLF20, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny85V-10PU: PDIP8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny85V-10SH: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny85V-10SU: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny85V-10SUR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny85V-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85V-20PU: PDIP8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85V-20SH: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny85V-20SU: SOIC8, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; - mcuid = 26; - n_interrupts = 15; -# no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -# avr910_devcode = ?; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 4500; - signature = 0x1e 0x93 0x0b; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, - 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - flash_instr = 0xb4, 0x02, 0x12; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x02, 0xb4, 0x02, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 1; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - idr = 0x22; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - # ATtiny85 has signature bytes 0x1E 0x93 0x08 - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 2; - read = "0011.1000--000x.xxxx--0000.000a--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATmega640 -#------------------------------------------------------------ -# Almost same as ATmega1280, except for different memory sizes - -part # m640 - desc = "ATmega640"; - id = "m640"; - variants = - "ATmega640: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega640-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega640-16AUR: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega640-16CU: CBGA100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega640V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega640V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega640V-8CU: CBGA100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega640V-8CUR: TFBGA100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 126; - n_interrupts = 57; - n_boot_sections = 4; - boot_section_size = 1024; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x96 0x08; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 4096; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x10000; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--0aaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 480; - offset = 0x20; - ; - - memory "sram" - size = 8192; - offset = 0x200; - ; -; - -#------------------------------------------------------------ -# ATmega1280 -#------------------------------------------------------------ - -part # m1280 - desc = "ATmega1280"; - id = "m1280"; - variants = - "ATmega1280: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega1280-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega1280-16AUR: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega1280-16CU: CBGA100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega1280V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1280V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega1280V-8CU: CBGA100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 138; - n_interrupts = 57; - n_boot_sections = 4; - boot_section_size = 1024; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x97 0x03; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - rampz = 0x3b; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 4096; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x20000; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 480; - offset = 0x20; - ; - - memory "sram" - size = 8192; - offset = 0x200; - ; -; - -#------------------------------------------------------------ -# ATmega1281 -#------------------------------------------------------------ -# Identical to ATmega1280 - -part parent "m1280" # m1281 - desc = "ATmega1281"; - id = "m1281"; - variants = - "ATmega1281: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega1281-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega1281-16AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega1281-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega1281-16MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega1281V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1281V-8AUR: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1281V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega1281V-8MUR: MLF64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 139; - signature = 0x1e 0x97 0x04; -; - -#------------------------------------------------------------ -# ATmega2560 -#------------------------------------------------------------ - -part # m2560 - desc = "ATmega2560"; - id = "m2560"; - variants = - "ATmega2560: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega2560-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega2560-16AUR: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega2560-16CU: CBGA100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega2560V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega2560V-8AUR: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega2560V-8CU: CBGA100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 143; - n_interrupts = 57; - n_boot_sections = 4; - boot_section_size = 1024; - stk500_devcode = 0xb2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x98 0x01; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; - hventerstabdelay = 100; - latchcycles = 6; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - rampz = 0x3b; - spmcr = 0x57; - eecr = 0x3f; - eind = 0x5c; - ocdrev = 4; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 4096; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x40000; - page_size = 256; - num_pages = 1024; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - load_ext_addr = "0100.1101--0000.0000--0000.000a--0000.0000"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x07; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 480; - offset = 0x20; - ; - - memory "sram" - size = 8192; - offset = 0x200; - ; -; - -#------------------------------------------------------------ -# ATmega2561 -#------------------------------------------------------------ - -part parent "m2560" # m2561 - desc = "ATmega2561"; - id = "m2561"; - variants = - "ATmega2561: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega2561-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega2561-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega2561-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[4.5 V, 5.5 V]", - "ATmega2561-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[4.5 V, 5.5 V]", - "ATmega2561V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega2561V-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega2561V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega2561V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 144; - signature = 0x1e 0x98 0x02; -; - -#------------------------------------------------------------ -# ATmega128RFA1 -#------------------------------------------------------------ -# Identical to ATmega2561 but half the ROM - -part parent "m2561" # m128rfa1 - desc = "ATmega128RFA1"; - id = "m128rfa1"; - variants = - "ATmega128RFA1: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFA1-ZF: VFQFN64, Fmax=N/A, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFA1-ZFR: VFQFN64, Fmax=N/A, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFA1-ZU: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFA1-ZU00: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFA1-ZUR: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFA1-ZUR-SL514: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFA1-ZUR00: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; - mcuid = 87; - n_interrupts = 72; - chip_erase_delay = 18500; - bs2 = 0xe2; - signature = 0x1e 0xa7 0x01; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - latchcycles = 5; - ocdrev = 3; - - memory "eeprom" - min_write_delay = 13000; - max_write_delay = 13000; - delay = 50; - ; - - memory "flash" - size = 0x20000; - num_pages = 512; - delay = 50; - load_ext_addr = NULL; - ; - - memory "lfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "hfuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "efuse" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "lock" - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "sram" - size = 0x4000; - ; -; - -#------------------------------------------------------------ -# ATmega256RFR2 -#------------------------------------------------------------ - -part parent "m128rfa1" # m256rfr2 - desc = "ATmega256RFR2"; - id = "m256rfr2"; - variants = - "ATmega256RFR2-ZF: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega256RFR2-ZFR: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega256RFR2-ZU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega256RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; - mcuid = 108; - n_interrupts = 77; - signature = 0x1e 0xa8 0x02; - chiperasepolltimeout = 20; - ocdrev = 4; - - memory "eeprom" - size = 8192; - read = "1010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxa.aaaa--aaaa.aaaa--iiii.iiii"; - writepage = "1100.0010--00xa.aaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - size = 0x40000; - num_pages = 1024; - load_ext_addr = "0100.1101--0000.0000--0000.000a--0000.0000"; - ; - - memory "efuse" - initval = 0xfe; - ; - - ##### - # Three separate flash pages - # - Offset 0x100 in signature row - # - Only programmable with JTAG or HVPP - # - Readable from an application - # - Cannot be read using ISP - # - Not erased by chip erase - # - memory "usersig" - paged = yes; - size = 768; - page_size = 256; - num_pages = 3; - offset = 0x100; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 50; - blocksize = 256; - readsize = 256; - ; - - memory "sram" - size = 0x8000; - ; -; - -#------------------------------------------------------------ -# ATmega128RFR2 -#------------------------------------------------------------ - -part parent "m256rfr2" # m128rfr2 - desc = "ATmega128RFR2"; - id = "m128rfr2"; - variants = - "ATmega128RFR2-ZF: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFR2-ZFR: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFR2-ZU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega128RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; - mcuid = 88; - signature = 0x1e 0xa7 0x02; - ocdrev = 3; - - memory "eeprom" - size = 4096; - ; - - memory "flash" - size = 0x20000; - num_pages = 512; - load_ext_addr = NULL; - ; - - memory "sram" - size = 0x4000; - ; -; - -#------------------------------------------------------------ -# ATmega64RFR2 -#------------------------------------------------------------ - -part parent "m128rfr2" # m64rfr2 - desc = "ATmega64RFR2"; - id = "m64rfr2"; - variants = - "ATmega64RFR2-ZF: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega64RFR2-ZFR: VFQFN64, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega64RFR2-ZU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega64RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; - mcuid = 78; - signature = 0x1e 0xa6 0x02; - - memory "eeprom" - size = 2048; - read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; - writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - size = 0x10000; - num_pages = 256; - read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - writepage = "0100.1100--0aaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "sram" - size = 8192; - ; -; - -#------------------------------------------------------------ -# ATmega2564RFR2 -#------------------------------------------------------------ - -part parent "m256rfr2" # m2564rfr2 - desc = "ATmega2564RFR2"; - id = "m2564rfr2"; - variants = - "ATmega2564RFR2-ZF: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega2564RFR2-ZFR: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega2564RFR2-ZU: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega2564RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; - mcuid = 145; - signature = 0x1e 0xa8 0x03; -; - -#------------------------------------------------------------ -# ATmega1284RFR2 -#------------------------------------------------------------ - -part parent "m128rfr2" # m1284rfr2 - desc = "ATmega1284RFR2"; - id = "m1284rfr2"; - variants = - "ATmega1284RFR2-ZF: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega1284RFR2-ZFR: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega1284RFR2-ZU: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega1284RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; - mcuid = 142; - signature = 0x1e 0xa7 0x03; -; - -#------------------------------------------------------------ -# ATmega644RFR2 -#------------------------------------------------------------ - -part parent "m64rfr2" # m644rfr2 - desc = "ATmega644RFR2"; - id = "m644rfr2"; - variants = - "ATmega644RFR2-ZF: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega644RFR2-ZFR: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 3.6 V]", - "ATmega644RFR2-ZU: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", - "ATmega644RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; - mcuid = 131; - signature = 0x1e 0xa6 0x03; -; - -#------------------------------------------------------------ -# ATtiny24 -#------------------------------------------------------------ - -part # t24 - desc = "ATtiny24"; - id = "t24"; - variants = - "ATtiny24: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24-20MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny24-20MUR: WQFN20, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATtiny24-20PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny24-20SSU: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny24-20SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny24V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24V-10MUR: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24V-10PU: PDIP14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24V-10SSU: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24V-10SSUR: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; - mcuid = 14; - n_interrupts = 17; -# no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -# avr910_devcode = ?; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 4500; - signature = 0x1e 0x91 0x0b; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, - 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0f; - flash_instr = 0xb4, 0x07, 0x17; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x07, 0xb4, 0x07, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 50; - resetdelayus = 3; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - hvspcmdexedelay = 50; - idr = 0x27; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 128; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--xaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--xaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 32; - readsize = 256; - read_lo = "0010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.00aa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxx.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxx.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.00aa--aaaa.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--xxxx.xxii"; - ; - - # ATtiny24 has signature bytes 0x1E 0x91 0x0B - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 128; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny24A -#------------------------------------------------------------ - -part parent "t24" # t24a - desc = "ATtiny24A"; - id = "t24a"; - variants = - "ATtiny24A: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-CCU: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-CCUR: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-MF: QFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-MFR: QFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-MM8: VQFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-MM8R: VQFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-MUR: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-SSF: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-SSFR: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny24A-SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 15; -; - -#------------------------------------------------------------ -# ATtiny44 -#------------------------------------------------------------ - -part # t44 - desc = "ATtiny44"; - id = "t44"; - variants = - "ATtiny44: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44-20MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny44-20MUR: WQFN20, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATtiny44-20PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny44-20SSU: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny44-20SSUR: SOIC14N, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATtiny44V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44V-10MUR: WQFN20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44V-10PU: PDIP14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44V-10SSU: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44V-10SSUR: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; - mcuid = 20; - n_interrupts = 17; -# no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -# avr910_devcode = ?; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 4500; - signature = 0x1e 0x92 0x07; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, - 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0f; - flash_instr = 0xb4, 0x07, 0x17; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x07, 0xb4, 0x07, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 50; - resetdelayus = 3; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - hvspcmdexedelay = 50; - idr = 0x27; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 256; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.0aaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--xxxx.xxii"; - ; - - # ATtiny44 has signature bytes 0x1E 0x92 0x07 - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 256; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny44A -#------------------------------------------------------------ - -part parent "t44" # t44a - desc = "ATtiny44A"; - id = "t44a"; - variants = - "ATtiny44A: N/A, Fmax=20 MHz, T=[-40 C, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-CCU: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-CCUR: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-MF: QFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-MFR: QFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-MUR: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-SSF: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-SSFR: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny44A-SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = XVII + IV; # 21; - - -; - -#------------------------------------------------------------ -# ATtiny84 -#------------------------------------------------------------ - -part # t84 - desc = "ATtiny84"; - id = "t84"; - variants = - "ATtiny84: N/A, Fmax=20 MHz, T=[N/A, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84-15MZ: MLF20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny84-20MU: MLF20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny84-20MUR: WQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny84-20PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny84-20SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny84-20SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny84V-10MU: MLF20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84V-10MUR: WQFN20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84V-10PU: PDIP14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84V-10SSU: SOIC14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84V-10SSUR: SOIC14, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; - mcuid = 24; - n_interrupts = 17; -# no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -# avr910_devcode = ?; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 4500; - signature = 0x1e 0x93 0x0c; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - hvsp_controlstack = - 0x4c, 0x0c, 0x1c, 0x2c, 0x3c, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7a, 0x6a, 0x68, 0x78, - 0x78, 0x7d, 0x6d, 0x0c, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0f; - flash_instr = 0xb4, 0x07, 0x17; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x07, 0xb4, 0x07, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 50; - resetdelayus = 3; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - synchcycles = 6; - hvspcmdexedelay = 50; - idr = 0x27; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--xxxx.xxii"; - ; - - # ATtiny84 has signature bytes 0x1E 0x93 0x0C - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x60; - ; -; - -#------------------------------------------------------------ -# ATtiny84A -#------------------------------------------------------------ - -part parent "t84" # t84a - desc = "ATtiny84A"; - id = "t84a"; - variants = - "ATtiny84A-CCU: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-CCUR: UFBGA15, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-MF: WQFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-MFR: WQFN20, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-MMH: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-MMHR: VQFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-MU: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-MUR: QFN20, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-PU: PDIP14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-SSF: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-SSFR: SOIC14, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny84A-SSUR: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 25; -; - -#------------------------------------------------------------ -# ATtiny441 -#------------------------------------------------------------ - -part parent "t44" # t441 - desc = "ATtiny441"; - id = "t441"; - variants = - "ATtiny441-MMH: VQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny441-MMHR: VQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny441-MU: QFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny441-MUR: QFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny441-SSU: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny441-SSUR: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]"; - mcuid = 32; - n_interrupts = 30; - n_page_erase = 4; - signature = 0x1e 0x92 0x15; - poweroffdelay = 25; - resetdelayms = 1; - resetdelayus = 0; - hvspcmdexedelay = 0; - - memory "flash" - page_size = 16; - num_pages = 256; - blocksize = 16; - loadpage_lo = "0100.0000--000x.xxxx--xxxx.xaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxx.xaaa--iiii.iiii"; - writepage = "0100.1100--0000.0aaa--aaaa.axxx--xxxx.xxxx"; - ; - - memory "lfuse" - bitmask = 0xdf; - ; - - memory "efuse" - bitmask = 0xff; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; - ; - - memory "io" - size = 224; - ; - - memory "sram" - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATtiny841 -#------------------------------------------------------------ - -part parent "t84" # t841 - desc = "ATtiny841"; - id = "t841"; - variants = - "ATtiny841-MMH: VQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny841-MMHR: VQFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny841-MU: QFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny841-MUR: QFN20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny841-SSU: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]", - "ATtiny841-SSUR: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]"; - mcuid = 37; - n_interrupts = 30; - n_page_erase = 4; - signature = 0x1e 0x93 0x15; - poweroffdelay = 25; - resetdelayms = 1; - resetdelayus = 0; - hvspcmdexedelay = 0; - - memory "flash" - page_size = 16; - num_pages = 512; - blocksize = 16; - loadpage_lo = "0100.0000--000x.xxxx--xxxx.xaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxx.xaaa--iiii.iiii"; - writepage = "0100.1100--0000.aaaa--aaaa.axxx--xxxx.xxxx"; - ; - - memory "lfuse" - bitmask = 0xdf; - ; - - memory "efuse" - bitmask = 0xff; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; - ; - - memory "io" - size = 224; - ; - - memory "sram" - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATtiny43U -#------------------------------------------------------------ - -part # t43u - desc = "ATtiny43U"; - id = "t43u"; - variants = - "ATtiny43U: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[0.7 V, 5.5 V]", - "ATtiny43U-MU: QFN20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny43U-MUR: WQFN20, Fmax=8 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATtiny43U-SU: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATtiny43U-SUR: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 19; - n_interrupts = 16; - stk500_devcode = 0x14; -# avr910_devcode = ?; -# Try the AT90S2313 devcode: - avr910_devcode = 0x20; - chip_erase_delay = 1000; - pagel = 0xa3; - bs2 = 0xa2; - signature = 0x1e 0x92 0x0c; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, - 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, - 0x06, 0x16, 0x46, 0x56, 0x0a, 0x1a, 0x4a, 0x5a, - 0x1e, 0x7c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb4, 0x07, 0x17; - eeprom_instr = - 0xbb, 0xff, 0xbb, 0xee, 0xbb, 0xcc, 0xb2, 0x0d, - 0xbc, 0x07, 0xb4, 0x07, 0xba, 0x0d, 0xbb, 0xbc, - 0x99, 0xe1, 0xbb, 0xac; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 20; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x27; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 64; - page_size = 4; - num_pages = 16; - min_write_delay = 4000; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxx--00aa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxx--00aa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxx--00aa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 64; - readsize = 256; - read_lo = "0010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; - writepage = "0100.1100--0000.0aaa--aaax.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x01; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.xxxi"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 64; - offset = 0x20; - ; - - memory "sram" - size = 256; - offset = 0x60; - ; -; - #------------------------------------------------------------ # ATmega16u4 #------------------------------------------------------------ -part # m16u4 +part parent ".classic" # m16u4 desc = "ATmega16U4"; id = "m16u4"; variants = @@ -15253,9 +14385,6 @@ part # m16u4 spmcr = 0x57; eecr = 0x3f; ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 512; @@ -15319,33 +14448,14 @@ part # m16u4 ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; min_write_delay = 9000; max_write_delay = 9000; read = "0101.1000--0000.0000--xxxx.xxxx--00oo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" size = 1280; - offset = 0x100; ; ; @@ -15353,7 +14463,7 @@ part # m16u4 # ATmega32u4 #------------------------------------------------------------ -part # m32u4 +part parent "m16u4" # m32u4 desc = "ATmega32U4"; id = "m32u4"; variants = @@ -15365,1286 +14475,52 @@ part # m32u4 "ATmega32U4RC-AUR: QFP44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", "ATmega32U4RC-MU: QFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", "ATmega32U4RC-MUR: QFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 65; - n_interrupts = 43; - n_boot_sections = 4; - boot_section_size = 512; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; signature = 0x1e 0x95 0x87; - usbpid = 0x2ff4; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 5; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; memory "eeprom" size = 1024; - page_size = 4; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; writepage = "1100.0010--00xx.xaaa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" - paged = yes; size = 0x8000; - page_size = 128; num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x52; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xfb; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--1111.iiii"; ; memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--xxxx.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; ; memory "sram" size = 2560; - offset = 0x100; ; ; #------------------------------------------------------------ -# AT90USB646 +# ATmega406 #------------------------------------------------------------ -part # usb646 - desc = "AT90USB646"; - id = "usb646"; +part parent ".classic" # m406 + desc = "ATmega406"; + id = "m406"; variants = - "AT90USB646: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90USB646-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB646-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB646-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB646-MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 181; - n_interrupts = 38; + "ATmega406: N/A, Fmax=1 MHz, T=[N/A, N/A], Vcc=[3.3 V, 3.3 V]", + "ATmega406-1AAU: LQFP48, Fmax=1 MHz, T=[-30 C, 85 C], Vcc=[4 V, 25 V]"; + prog_modes = PM_SPM | PM_HVPP | PM_JTAG; + mcuid = 125; + n_interrupts = 23; n_boot_sections = 4; - boot_section_size = 1024; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xd7; + boot_section_size = 512; + # STK500 parameters (parallel programming IO lines) + pagel = 0xa7; bs2 = 0xa0; - signature = 0x1e 0x96 0x82; - usbpid = 0x2ff9; + signature = 0x1e 0x95 0x07; reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 2048; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - read = "1010.0000--xxxx.xaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.xaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.xaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x10000; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--0aaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x5e; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x9b; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf3; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# AT90USB647 -#------------------------------------------------------------ -# identical to AT90USB646 - -part parent "usb646" # usb647 - desc = "AT90USB647"; - id = "usb647"; - variants = - "AT90USB647: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90USB647-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB647-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB647-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB647-MUR: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 182; -; - -#------------------------------------------------------------ -# AT90USB1286 -#------------------------------------------------------------ - -part # usb1286 - desc = "AT90USB1286"; - id = "usb1286"; - variants = - "AT90USB1286: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90USB1286-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB1286-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB1286-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB1286-MUR: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 184; - n_interrupts = 38; - n_boot_sections = 4; - boot_section_size = 1024; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x97 0x82; - usbpid = 0x2ffb; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - rampz = 0x3b; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 4096; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - read = "1010.0000--xxxx.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--xxxx.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--00xx.aaaa--aaaa.a000--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x20000; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--axxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x5e; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf3; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--xxxx.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 8192; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# AT90USB1287 -#------------------------------------------------------------ -# identical to AT90USB1286 - -part parent "usb1286" # usb1287 - desc = "AT90USB1287"; - id = "usb1287"; - variants = - "AT90USB1287: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90USB1287-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB1287-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB1287-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB1287-MUR: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - mcuid = 185; -; - -#------------------------------------------------------------ -# AT90USB162 -#------------------------------------------------------------ - -part # usb162 - desc = "AT90USB162"; - id = "usb162"; - variants = - "AT90USB162: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90USB162-16AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB162-16AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB162-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB162-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 178; - n_interrupts = 29; - n_boot_sections = 4; - boot_section_size = 512; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc6; - signature = 0x1e 0x94 0x82; - usbpid = 0x2ffa; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - num_pages = 128; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.aaaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x5e; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xd9; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf4; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# AT90USB82 -#------------------------------------------------------------ - -part # usb82 - desc = "AT90USB82"; - id = "usb82"; - variants = - "AT90USB82: QFN32, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "AT90USB82-16MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "AT90USB82-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 174; - n_interrupts = 29; - n_boot_sections = 4; - boot_section_size = 512; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc6; - signature = 0x1e 0x93 0x82; - usbpid = 0x2ff7; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - num_pages = 128; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.aaaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 128; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x5e; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xd9; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf4; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega32U2 -#------------------------------------------------------------ - -part # m32u2 - desc = "ATmega32U2"; - id = "m32u2"; - variants = - "ATmega32U2-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32U2-AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32U2-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega32U2-MUR: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 64; - n_interrupts = 29; - n_boot_sections = 4; - boot_section_size = 512; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc6; - signature = 0x1e 0x95 0x8a; - usbpid = 0x2ff0; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 1024; - page_size = 4; - num_pages = 256; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.aaaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x8000; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x5e; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xd9; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf4; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 1024; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega16U2 -#------------------------------------------------------------ - -part # m16u2 - desc = "ATmega16U2"; - id = "m16u2"; - variants = - "ATmega16U2-AU: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16U2-AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16U2-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega16U2-MUR: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 56; - n_interrupts = 29; - n_boot_sections = 4; - boot_section_size = 512; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc6; - signature = 0x1e 0x94 0x89; - usbpid = 0x2fef; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - num_pages = 128; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.aaaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x5e; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xd9; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf4; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega8U2 -#------------------------------------------------------------ - -part # m8u2 - desc = "ATmega8U2"; - id = "m8u2"; - variants = - "ATmega8U2-AU: LQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8U2-AUR: TQFP32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8U2-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega8U2-MUR: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 48; - n_interrupts = 29; - n_boot_sections = 4; - boot_section_size = 512; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xc6; - signature = 0x1e 0x93 0x89; - usbpid = 0x2fee; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 512; - page_size = 4; - num_pages = 128; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.aaaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.aaaa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 128; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--xxxx.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x5e; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xd9; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xf4; - bitmask = 0x0f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--iiii.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 512; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega165P -#------------------------------------------------------------ - -part # m165p - desc = "ATmega165P"; - id = "m165p"; - variants = - "ATmega165P: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega165P-16AN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", - "ATmega165P-16ANR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega165P-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega165P-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega165P-16MN: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega165P-16MNR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega165P-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega165P-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega165PV-8AN: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165PV-8ANR: TQFP64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega165PV-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165PV-8AUR: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165PV-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165PV-8MUR: QFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 97; - n_interrupts = 22; - n_boot_sections = 4; - boot_section_size = 256; -# stk500_devcode = 0x??; -# avr910_devcode = 0x??; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x94 0x07; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; + serial = no; + # STK500v2 HV programming parameters, from XML pp_controlstack = 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, @@ -16661,234 +14537,557 @@ part # m165p spmcr = 0x57; eecr = 0x3f; ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + chip_erase = NULL; + pgm_enable = NULL; memory "eeprom" size = 512; page_size = 4; num_pages = 128; + blocksize = 4; + readsize = 4; + ; + + memory "flash" + paged = yes; + size = 0xa000; + page_size = 128; + num_pages = 320; + blocksize = 128; + readsize = 128; + ; + + memory "lfuse" + size = 1; + initval = 0xcd; + ; + + memory "hfuse" + size = 1; + initval = 0xfe; + bitmask = 0x03; + ; + + memory "lock" = NULL; + + memory "lockbits" + size = 1; + initval = 0xff; + bitmask = 0x3f; + ; + + memory "signature" + read = NULL; + ; + + memory "calibration" + read = NULL; + ; +; + +#------------------------------------------------------------ +# ATA6612C +#------------------------------------------------------------ + +part parent ".classic" # ata6612c + desc = "ATA6612C"; + id = "ata6612c"; + variants = + "ATA6612C-PLQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATA6612C-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 216; + n_interrupts = 26; + n_boot_sections = 4; + boot_section_size = 256; + stk500_devcode = 0x73; + chip_erase_delay = 4000; + pagel = 0xd7; + bs2 = 0xc2; + signature = 0x1e 0x93 0x0a; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxxa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aaax.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xf9; + bitmask = 0x07; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--1111.1ooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; + ; + + memory "lock" + bitmask = 0x3f; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; + ; + + memory "sram" + size = 1024; + ; +; + +#------------------------------------------------------------ +# ATA6613C +#------------------------------------------------------------ + +part parent "ata6612c" # ata6613c + desc = "ATA6613C"; + id = "ata6613c"; + variants = + "ATA6613C-PLQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATA6613C-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 217; + stk500_devcode = 0x86; + chip_erase_delay = 9000; + signature = 0x1e 0x94 0x06; + + memory "eeprom" + min_write_delay = 3600; + max_write_delay = 3600; + ; + + memory "flash" + size = 0x4000; + page_size = 128; + blocksize = 128; + read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--000a.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; +; + +#------------------------------------------------------------ +# ATA6616C +#------------------------------------------------------------ + +part parent ".classic" # ata6616c + desc = "ATA6616C"; + id = "ata6616c"; + variants = + "ATA6616C-P3PW: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATA6616C-P3QW: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATA6616C-P3QW-1: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 219; + n_interrupts = 20; + stk500_devcode = 0x14; + avr910_devcode = 0x20; + chip_erase_delay = 4000; + pagel = 0xb3; + bs2 = 0xb2; + signature = 0x1e 0x93 0x87; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, + 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, + 0x06, 0x16, 0x46, 0x56, 0x0a, 0x1a, 0x4a, 0x5a, + 0x1e, 0x7c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--0000.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--0000.aaaa--aa00.0000--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--1111.111o"; + write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--1111.11oo"; + write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATA6617C +#------------------------------------------------------------ + +part parent "ata6616c" # ata6617c + desc = "ATA6617C"; + id = "ata6617c"; + variants = + "ATA6617C-P3QW: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATA6617C-P3QW-1: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; + mcuid = 220; + signature = 0x1e 0x94 0x87; + + memory "flash" + size = 0x4000; + num_pages = 128; + read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + writepage = "0100.1100--000a.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; +; + +#------------------------------------------------------------ +# ATA5505 +#------------------------------------------------------------ + +part parent ".classic" # ata5505 + desc = "ATA5505"; + id = "ata5505"; + variants = + "ATA5505: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", + "ATA5505-P3QW: VFQFN38, Fmax=N/A, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 198; + n_interrupts = 20; + stk500_devcode = 0x14; + avr910_devcode = 0x20; + chip_erase_delay = 4000; + pagel = 0xb3; + bs2 = 0xb2; + signature = 0x1e 0x94 0x87; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, + 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, + 0x06, 0x16, 0x46, 0x56, 0x0a, 0x1a, 0x4a, 0x5a, + 0x1e, 0x7c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; + ; + + memory "flash" + paged = yes; + size = 0x4000; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--000a.aaaa--aaxx.xxxx--xxxx.xxxx"; + ; + + memory "lfuse" + size = 1; + initval = 0x62; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; + ; + + memory "hfuse" + size = 1; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; + ; + + memory "efuse" + size = 1; + initval = 0xff; + bitmask = 0x01; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--1111.111o"; + write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--1111.11oo"; + write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# ATA6614Q +#------------------------------------------------------------ + +part parent ".classic" # ata6614q + desc = "ATA6614Q"; + id = "ata6614q"; + variants = + "ATA6614Q-PLQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATA6614Q-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 218; + n_interrupts = 26; + n_boot_sections = 4; + boot_section_size = 512; + stk500_devcode = 0x86; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xc2; + signature = 0x1e 0x95 0x0f; + reset = io; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + pp_controlstack = + 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, + 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, + 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, + 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; + hventerstabdelay = 100; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepolltimeout = 10; + programfusepolltimeout = 5; + programlockpolltimeout = 5; + idr = 0x31; + spmcr = 0x57; + eecr = 0x3f; + ocdrev = 1; + + memory "eeprom" + size = 1024; + page_size = 4; min_write_delay = 3600; max_write_delay = 3600; mode = 0x41; delay = 20; blocksize = 4; readsize = 256; - read = "1010.0000--0000.00xa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.00xa--aaaa.aaaa--iiii.iiii"; + read = "1010.0000--000x.xxaa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--000x.xxaa--aaaa.aaaa--iiii.iiii"; loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.00xa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - read_lo = "0010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.xxxx--xxaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.xxxx--xxaa.aaaa--iiii.iiii"; - writepage = "0100.1100--xxxa.aaaa--aaxx.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0x99; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x0f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--0000.0000--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 1024; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATmega165A -#------------------------------------------------------------ - -part parent "m165p" # m165a - desc = "ATmega165A"; - id = "m165a"; - variants = - "ATmega165A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega165A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165A-AUR: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega165A-MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165A-MUR: TQFP64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; - mcuid = 96; - signature = 0x1e 0x94 0x10; -; - -#------------------------------------------------------------ -# ATmega165 -#------------------------------------------------------------ - -part parent "m165p" # m165 - desc = "ATmega165"; - id = "m165"; - variants = - "ATmega165: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[N/A, N/A]", - "ATmega165-16AI: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega165-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega165-16MI: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega165-16MU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega165V-8AI: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165V-8MI: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165V-8MU: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 95; - - memory "eeprom" - min_write_delay = 9000; - max_write_delay = 9000; - ; -; - -#------------------------------------------------------------ -# ATmega165PA -#------------------------------------------------------------ - -part parent "m165p" # m165pa - desc = "ATmega165PA"; - id = "m165pa"; - variants = - "ATmega165PA: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega165PA-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165PA-AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165PA-MN: TQFP64, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega165PA-MNR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega165PA-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 98; -; - -#------------------------------------------------------------ -# ATmega325 -#------------------------------------------------------------ - -part # m325 - desc = "ATmega325"; - id = "m325"; - variants = - "ATmega325: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega325-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega325-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega325-16MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega325-16MUR: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega325V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325V-8AUR: TQFP64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega325V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 114; - n_interrupts = 22; - n_boot_sections = 4; - boot_section_size = 512; -# stk500_devcode = 0x??; # No STK500v1 support? -# avr910_devcode = 0x??; # Try the ATmega16 one - avr910_devcode = 0x74; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x95 0x05; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--0000.0000--0000.0000"; - pgm_enable = "1010.1100--0101.0011--0000.0000--0000.0000"; - - memory "eeprom" - size = 1024; - page_size = 4; - min_write_delay = 9000; - max_write_delay = 9000; - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - read = "1010.0000--0000.00aa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.00aa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--0000.00aa--aaaa.aa00--xxxx.xxxx"; + writepage = "1100.0010--00xx.xxaa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" @@ -16902,159 +15101,69 @@ part # m325 delay = 10; blocksize = 128; readsize = 256; - read_lo = "0010.0000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--0aaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.0000--aaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.0000--aaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--0aaa.aaaa--aaaa.aaaa--xxxx.xxxx"; + read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--00aa.aaaa--aaxx.xxxx--xxxx.xxxx"; ; memory "lfuse" size = 1; initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--1010.0000--0000.0000--iiii.iiii"; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; ; memory "hfuse" size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--0000.0000--oooo.oooo"; - write = "1010.1100--1010.1000--0000.0000--iiii.iiii"; + initval = 0xd9; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; ; memory "efuse" size = 1; initval = 0xff; bitmask = 0x07; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--0000.0000--oooo.oooo"; - write = "1010.1100--1010.0100--0000.0000--1111.1iii"; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--1111.1ooo"; + write = "1010.1100--1010.0100--xxxx.xxxx--1111.1iii"; ; memory "lock" - size = 1; - initval = 0xff; bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1110.0000--0000.0000--11ii.iiii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--0000.0000--0000.00aa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 2048; - offset = 0x100; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--11oo.oooo"; ; ; #------------------------------------------------------------ -# ATmega325A +# ATA664251 #------------------------------------------------------------ -part parent "m325" # m325a - desc = "ATmega325A"; - id = "m325a"; +part parent ".classic" # ata664251 + desc = "ATA664251"; + id = "ata664251"; variants = - "ATmega325A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega325A-AN: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325A-ANR: TQFP64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325A-AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325A-AUR: TQFP64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega325A-MN: VQFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325A-MNR: VQFN64, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325A-MU: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325A-MUR: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 115; -; - -#------------------------------------------------------------ -# ATmega325P -#------------------------------------------------------------ - -part parent "m325" # m325p - desc = "ATmega325P"; - id = "m325p"; - variants = - "ATmega325P: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega325P-20AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega325P-20AUR: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega325P-20MU: MLF64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega325PV-10AU: TQFP64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325PV-10AUR: TQFP64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325PV-10MU: MLF64, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325PV-10MUR: VQFN64, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 116; - signature = 0x1e 0x95 0x0d; -; - -#------------------------------------------------------------ -# ATmega325PA -#------------------------------------------------------------ - -part parent "m325" # m325pa - desc = "ATmega325PA"; - id = "m325pa"; - variants = - "ATmega325PA: N/A, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega325PA-AU: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325PA-AUR: TQFP64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega325PA-MU: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega325PA-MUR: VQFN64, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 117; - signature = 0x1e 0x95 0x0d; -; - -#------------------------------------------------------------ -# ATmega645 -#------------------------------------------------------------ - -part # m645 - desc = "ATmega645"; - id = "m645"; - variants = - "ATmega645: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega645-16AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega645-16AUR: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega645-16MU: MLF64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega645-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega645V-8AU: TQFP64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega645V-8AUR: TQFP64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega645V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega645V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; - mcuid = 132; - n_interrupts = 22; - n_boot_sections = 4; - boot_section_size = 1024; -# stk500_devcode = 0x??; # No STK500v1 support? -# avr910_devcode = 0x??; # Try the ATmega16 one - avr910_devcode = 0x74; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - signature = 0x1e 0x96 0x05; - reset = io; + "ATA664251: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", + "ATA664251-WGQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", + "ATA664251-WGQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; + prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; + mcuid = 225; + n_interrupts = 20; + stk500_devcode = 0x14; + avr910_devcode = 0x20; + chip_erase_delay = 4000; + pagel = 0xb3; + bs2 = 0xb2; + signature = 0x1e 0x94 0x87; timeout = 200; stabdelay = 100; cmdexedelay = 25; @@ -17063,12 +15172,16 @@ part # m645 pollvalue = 0x53; predelay = 1; postdelay = 1; - pollmethod = 1; pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + 0x0e, 0x1e, 0x0e, 0x1e, 0x2e, 0x3e, 0x2e, 0x3e, + 0x4e, 0x5e, 0x4e, 0x5e, 0x6e, 0x7e, 0x6e, 0x7e, + 0x06, 0x16, 0x46, 0x56, 0x0a, 0x1a, 0x4a, 0x5a, + 0x1e, 0x7c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + flash_instr = 0xb6, 0x01, 0x11; + eeprom_instr = + 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, + 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, + 0x99, 0xf9, 0xbb, 0xaf; hventerstabdelay = 100; latchcycles = 5; togglevtg = 1; @@ -17082,252 +15195,258 @@ part # m645 idr = 0x31; spmcr = 0x57; eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - chip_erase = "1010.1100--1000.0000--0000.0000--0000.0000"; - pgm_enable = "1010.1100--0101.0011--0000.0000--0000.0000"; + ocdrev = 1; memory "eeprom" - size = 2048; - page_size = 8; - min_write_delay = 9000; - max_write_delay = 9000; + size = 512; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; mode = 0x41; delay = 10; blocksize = 4; readsize = 256; - read = "1010.0000--0000.0aaa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--0000.0aaa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.0aaa--iiii.iiii"; - writepage = "1100.0010--0000.0aaa--aaaa.a000--xxxx.xxxx"; + read = "1010.0000--00xx.xxxa--aaaa.aaaa--oooo.oooo"; + write = "1100.0000--00xx.xxxa--aaaa.aaaa--iiii.iiii"; + loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; + writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; ; memory "flash" paged = yes; - size = 0x10000; - page_size = 256; - num_pages = 256; + size = 0x4000; + page_size = 128; + num_pages = 128; min_write_delay = 4500; max_write_delay = 4500; mode = 0x41; delay = 10; - blocksize = 128; + blocksize = 64; readsize = 256; - read_lo = "0010.0000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--aaaa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--0000.0000--aaaa.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--0000.0000--aaaa.aaaa--iiii.iiii"; - writepage = "0100.1100--aaaa.aaaa--aaaa.aaaa--0000.0000"; + read_lo = "0010.0000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + read_hi = "0010.1000--000a.aaaa--aaaa.aaaa--oooo.oooo"; + loadpage_lo = "0100.0000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + loadpage_hi = "0100.1000--000x.xxxx--xxaa.aaaa--iiii.iiii"; + writepage = "0100.1100--000a.aaaa--aaxx.xxxx--xxxx.xxxx"; ; memory "lfuse" size = 1; initval = 0x62; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.0000--0000.0000--oooo.oooo"; - write = "1010.1100--1010.0000--0000.0000--iiii.iiii"; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; ; memory "hfuse" size = 1; - initval = 0x99; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.1000--0000.0000--oooo.oooo"; - write = "1010.1100--1010.1000--0000.0000--iiii.iiii"; + initval = 0xdf; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; + write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; ; memory "efuse" size = 1; initval = 0xff; - bitmask = 0x07; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.0000--0000.1000--0000.0000--oooo.oooo"; - write = "1010.1100--1010.0100--0000.0000--1111.1iii"; + bitmask = 0x01; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.0000--0000.1000--xxxx.xxxx--1111.111o"; + write = "1010.1100--1010.0100--xxxx.xxxx--1111.111i"; + ; + + memory "lock" + bitmask = 0x03; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0101.1000--0000.0000--xxxx.xxxx--1111.11oo"; + write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; + ; + + memory "sram" + size = 512; + ; +; + +#------------------------------------------------------------ +# Logic Green parts +#------------------------------------------------------------ + +part parent "m88" # lgt8f88p + desc = "LGT8F88P"; + id = "lgt8f88p"; + mcuid = 227; + signature = 0x1e 0x93 0x0f; + autobaud_sync = 0x1c; + + memory "lfuse" + initval = -1; + ; + + memory "hfuse" + initval = -1; + ; + + memory "efuse" + initval = -1; + bitmask = -1; + ; + + memory "lock" + initval = -1; + bitmask = -1; + ; +; + +#------------------------------------------------------------ +# LGT8F168P +#------------------------------------------------------------ + +part parent "m168" # lgt8f168p + desc = "LGT8F168P"; + id = "lgt8f168p"; + mcuid = 228; + signature = 0x1e 0x94 0x0b; + autobaud_sync = 0x1c; + + memory "lfuse" + initval = -1; + ; + + memory "hfuse" + initval = -1; + ; + + memory "efuse" + initval = -1; + bitmask = -1; + ; + + memory "lock" + initval = -1; + bitmask = -1; + ; +; + +#------------------------------------------------------------ +# LGT8F328P +#------------------------------------------------------------ + +part parent "m328" # lgt8f328p + desc = "LGT8F328P"; + id = "lgt8f328p"; + mcuid = 229; + signature = 0x1e 0x95 0x0f; + autobaud_sync = 0x1c; + + memory "lfuse" + initval = -1; + ; + + memory "hfuse" + initval = -1; + ; + + memory "efuse" + initval = -1; + bitmask = -1; + ; + + memory "lock" + initval = -1; + bitmask = -1; + ; +; + +#------------------------------------------------------------ +# AT89S51 +#------------------------------------------------------------ + +# Nonstandard part +# - Tested with -c avrisp +# - USBASP programmers may require different firmware + +part # 89S51 + desc = "AT89S51"; + id = "89S51"; + variants = + "AT89S51: N/A, Fmax=33 MHz, T=[N/A, N/A], Vcc=[4 V, 5.5 V]", + "AT89S51-24AU: TQFP44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", + "AT89S51-24JU: PLCC44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", + "AT89S51-24PU: PDIP40, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]"; + prog_modes = PM_ISP | PM_HVPP; + mcuid = 372; + stk500_devcode = 0xe0; + chip_erase_delay = 250000; + signature = 0x1e 0x51 0x06; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + pollindex = 4; + pollvalue = 0x69; + predelay = 1; + postdelay = 1; + chiperasepulsewidth = 15; + programfusepulsewidth = 2; + programlockpolltimeout = 1; + chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; + pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; + + memory "flash" + size = 4096; + min_write_delay = 4500; + max_write_delay = 4500; + readback = 0xff 0xff; + mode = 0x02; + delay = 10; + blocksize = 256; + read = "0010.0000--xxxa.aaaa--aaaa.aaaa--oooo.oooo"; + write = "0100.0000--xxxa.aaaa--aaaa.aaaa--iiii.iiii"; + # Nonstandard page mode is available but not implemented ; memory "lock" size = 1; - initval = 0xff; - bitmask = 0x3f; - min_write_delay = 9000; - max_write_delay = 9000; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1110.0000--0000.0000--11ii.iiii"; + read = "0010.0100--xxxx.xxxx--xxxx.xxxx--xxxo.ooxx"; + # Nonstandard write: expect verification errors + # See datasheet Page 20, Note 1 https://ww1.microchip.com/downloads/en/DeviceDoc/doc2487.pdf + # Activate lock mode 0 through chip erase: avrdude -e + # Activate lock mode 1: avrdude -e -V -U lock:w:1:m + # Activate lock mode 2: avrdude -e -V -U lock:w:1:m -U lock:w:2:m + # Activate lock mode 3: avrdude -e -V -U lock:w:1:m -U lock:w:2:m -U lock:w:3:m + write = "1010.1100--1110.00ii--xxxx.xxxx--xxxx.xxxx"; ; memory "signature" size = 3; - read = "0011.0000--0000.0000--0000.00aa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 4096; - offset = 0x100; + read = "0 0 1 0 1 0 0 0 x x x x x x a1 a0 x x x x x x x 0 o o o o o o o o"; ; ; #------------------------------------------------------------ -# ATmega645A +# AT89S52 #------------------------------------------------------------ -part parent "m645" # m645a - desc = "ATmega645A"; - id = "m645a"; +part parent "89S51" # 89S52 + desc = "AT89S52"; + id = "89S52"; variants = - "ATmega645A: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega645A-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega645A-AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega645A-MU: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega645A-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 133; -; + "AT89S52: N/A, Fmax=33 MHz, T=[N/A, N/A], Vcc=[4 V, 5.5 V]", + "AT89S52-24AU: TQFP44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", + "AT89S52-24AUR: TQFP44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", + "AT89S52-24JU: PLCC44, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]", + "AT89S52-24PU: PDIP40, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]"; + mcuid = 373; + stk500_devcode = 0xe1; + signature = 0x1e 0x52 0x06; -#------------------------------------------------------------ -# ATmega645P -#------------------------------------------------------------ - -part parent "m645" # m645p - desc = "ATmega645P"; - id = "m645p"; - variants = - "ATmega645P: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega645P-AU: TQFP64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega645P-AUR: TQFP64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega645P-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega645P-MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 134; - signature = 0x1e 0x96 0x0d; -; - -#------------------------------------------------------------ -# ATmega3250 -#------------------------------------------------------------ - -part parent "m325" # m3250 - desc = "ATmega3250"; - id = "m3250"; - variants = - "ATmega3250: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega3250-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega3250-16AUR: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega3250V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega3250V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 146; - n_interrupts = 25; - signature = 0x1e 0x95 0x06; -; - -#------------------------------------------------------------ -# ATmega3250A -#------------------------------------------------------------ - -part parent "m325" # m3250a - desc = "ATmega3250A"; - id = "m3250a"; - variants = - "ATmega3250A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega3250A-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega3250A-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 147; - n_interrupts = 25; - signature = 0x1e 0x95 0x06; -; - -#------------------------------------------------------------ -# ATmega3250P -#------------------------------------------------------------ - -part parent "m325" # m3250p - desc = "ATmega3250P"; - id = "m3250p"; - variants = - "ATmega3250P: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega3250P-20AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega3250P-20AUR: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega3250PV-10AU: TQFP100, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega3250PV-10AUR: TQFP100, Fmax=10 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 148; - n_interrupts = 25; - signature = 0x1e 0x95 0x0e; -; - -#------------------------------------------------------------ -# ATmega3250PA -#------------------------------------------------------------ - -part parent "m325" # m3250pa - desc = "ATmega3250PA"; - id = "m3250pa"; - variants = - "ATmega3250PA: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega3250PA-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega3250PA-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 149; - n_interrupts = 25; - signature = 0x1e 0x95 0x0e; -; - -#------------------------------------------------------------ -# ATmega6450 -#------------------------------------------------------------ - -part parent "m645" # m6450 - desc = "ATmega6450"; - id = "m6450"; - variants = - "ATmega6450: N/A, Fmax=16 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega6450-16AU: TQFP100, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", - "ATmega6450-16AUR: TQFP100, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]", - "ATmega6450V-8AU: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega6450V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 154; - n_interrupts = 25; - signature = 0x1e 0x96 0x06; -; - -#------------------------------------------------------------ -# ATmega6450A -#------------------------------------------------------------ - -part parent "m645" # m6450a - desc = "ATmega6450A"; - id = "m6450a"; - variants = - "ATmega6450A: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega6450A-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega6450A-AUR: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 155; - n_interrupts = 25; - signature = 0x1e 0x96 0x06; -; - -#------------------------------------------------------------ -# ATmega6450P -#------------------------------------------------------------ - -part parent "m645" # m6450p - desc = "ATmega6450P"; - id = "m6450p"; - variants = - "ATmega6450P: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATmega6450P-AU: TQFP100, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATmega6450P-AUR: TQFP100, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; - mcuid = 156; - n_interrupts = 25; - signature = 0x1e 0x96 0x0e; + memory "flash" + size = 8192; + ; ; #------------------------------------------------------------ @@ -20078,583 +18197,6 @@ part # uc3a0512 ; ; -#------------------------------------------------------------ -# ATtiny1634 -#------------------------------------------------------------ - -part # t1634 - desc = "ATtiny1634"; - id = "t1634"; - variants = - "ATtiny1634: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634-MN: WQFN20, Fmax=12 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634-MNR: WQFN20, Fmax=12 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634-MU: QFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634-MUR: QFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634-SU: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634-SUR: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; - mcuid = 40; - n_interrupts = 28; - n_page_erase = 4; - stk500_devcode = 0x86; - chip_erase_delay = 9000; - pagel = 0xb3; - bs2 = 0xb1; -# avr910_devcode = 0x??; - signature = 0x1e 0x94 0x12; - reset = io; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - flash_instr = 0xb6, 0x01, 0x11; - eeprom_instr = - 0xbd, 0xf2, 0xbd, 0xe1, 0xbb, 0xcf, 0xb4, 0x00, - 0xbe, 0x01, 0xb6, 0x01, 0xbc, 0x00, 0xbb, 0xbf, - 0x99, 0xf9, 0xbb, 0xaf; - hventerstabdelay = 100; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x2e; - spmcr = 0x57; - eecr = 0x3c; - ocdrev = 1; - factory_fcpu = 1000000; - chip_erase = "1010.1100--100x.xxxx--xxxx.xxxx--xxxx.xxxx"; - pgm_enable = "1010.1100--0101.0011--xxxx.xxxx--xxxx.xxxx"; - - memory "eeprom" - size = 256; - page_size = 4; - min_write_delay = 3600; - max_write_delay = 3600; - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - read = "1010.0000--000x.xxxa--aaaa.aaaa--oooo.oooo"; - write = "1100.0000--000x.xxxa--aaaa.aaaa--iiii.iiii"; - loadpage_lo = "1100.0001--0000.0000--0000.00aa--iiii.iiii"; - writepage = "1100.0010--00xx.xxxa--aaaa.aa00--xxxx.xxxx"; - ; - - memory "flash" - paged = yes; - size = 0x4000; - page_size = 32; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - mode = 0x41; - delay = 10; - blocksize = 32; - readsize = 256; - read_lo = "0010.0000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - read_hi = "0010.1000--00aa.aaaa--aaaa.aaaa--oooo.oooo"; - loadpage_lo = "0100.0000--000x.xxxx--xxxx.aaaa--iiii.iiii"; - loadpage_hi = "0100.1000--000x.xxxx--xxxx.aaaa--iiii.iiii"; - writepage = "0100.1100--00aa.aaaa--aaaa.xxxx--xxxx.xxxx"; - ; - - memory "lfuse" - size = 1; - initval = 0x62; - bitmask = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0000--xxxx.xxxx--iiii.iiii"; - ; - - memory "hfuse" - size = 1; - initval = 0xdf; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.1000--xxxx.xxxx--iiii.iiii"; - ; - - memory "efuse" - size = 1; - initval = 0xff; - bitmask = 0x1f; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.0000--0000.1000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--1010.0100--xxxx.xxxx--xxxi.iiii"; - ; - - memory "lock" - size = 1; - initval = 0xff; - bitmask = 0x03; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0101.1000--0000.0000--xxxx.xxxx--oooo.oooo"; - write = "1010.1100--111x.xxxx--xxxx.xxxx--1111.11ii"; - ; - - memory "signature" - size = 3; - read = "0011.0000--000x.xxxx--xxxx.xxaa--oooo.oooo"; - ; - - memory "calibration" - size = 1; - read = "0011.1000--000x.xxxx--0000.0000--oooo.oooo"; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 1024; - offset = 0x100; - ; -; - -#------------------------------------------------------------ -# ATtiny1634R -#------------------------------------------------------------ - -part parent "t1634" # t1634r - desc = "ATtiny1634R"; - id = "t1634r"; - variants = - "ATtiny1634R-MU: QFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634R-MUR: WQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634R-SU: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny1634R-SUR: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 41; -; - -#------------------------------------------------------------ -# Common values for reduced core tinys (4/5/9/10/20/40) -#------------------------------------------------------------ - -part # .reduced_core_tiny - desc = "Common values for reduced core tinys"; - id = ".reduced_core_tiny"; - prog_modes = PM_TPI; - - memory "fuse" - size = 1; - page_size = 16; - initval = 0xff; - bitmask = 0x07; - offset = 0x3f40; - blocksize = 4; - ; - - memory "lockbits" - size = 1; - page_size = 16; - initval = 0xff; - bitmask = 0x03; - offset = 0x3f00; - ; - - memory "signature" - size = 3; - page_size = 16; - offset = 0x3fc0; - ; - - memory "calibration" - size = 1; - page_size = 16; - offset = 0x3f80; - ; - - memory "sram" - size = 32; - offset = 0x40; - ; -; - -#------------------------------------------------------------ -# ATtiny4 -#------------------------------------------------------------ - -part parent ".reduced_core_tiny" # t4 - desc = "ATtiny4"; - id = "t4"; - variants = - "ATtiny4-MAHR: UDFN8, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny4-TS8R: SOT23-6, Fmax=10 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny4-TSHR: SOT23-6, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 0; - n_interrupts = 10; - signature = 0x1e 0x8f 0x0a; - factory_fcpu = 1000000; - - memory "flash" - size = 512; - page_size = 16; - offset = 0x4000; - blocksize = 128; - ; - - memory "io" - size = 64; - ; -; - -#------------------------------------------------------------ -# ATtiny5 -#------------------------------------------------------------ - -part parent "t4" # t5 - desc = "ATtiny5"; - id = "t5"; - variants = - "ATtiny5-MAHR: USON8, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny5-TS8R: SOT23-6, Fmax=10 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny5-TSHR: SOT23-6, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 1; - n_interrupts = 11; - signature = 0x1e 0x8f 0x09; -; - -#------------------------------------------------------------ -# ATtiny9 -#------------------------------------------------------------ - -part parent ".reduced_core_tiny" # t9 - desc = "ATtiny9"; - id = "t9"; - variants = - "ATtiny9-MAHR: DFN8, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny9-TS8R: SOT23-6, Fmax=10 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny9-TSHR: SOT23-6, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 2; - n_interrupts = 10; - signature = 0x1e 0x90 0x08; - factory_fcpu = 1000000; - - memory "flash" - size = 1024; - page_size = 16; - offset = 0x4000; - blocksize = 128; - ; - - memory "io" - size = 64; - ; -; - -#------------------------------------------------------------ -# ATtiny10 -#------------------------------------------------------------ - -part parent "t9" # t10 - desc = "ATtiny10"; - id = "t10"; - variants = - "ATtiny10-MAHR: UDFN8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny10-TS8R: SOT23-6, Fmax=10 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny10-TSHR: SOT23-6, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 3; - n_interrupts = 11; - signature = 0x1e 0x90 0x03; -; - -#------------------------------------------------------------ -# ATtiny20 -#------------------------------------------------------------ - -part parent ".reduced_core_tiny" # t20 - desc = "ATtiny20"; - id = "t20"; - variants = - "ATtiny20-CCU: UFBGA15, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny20-CCUR: UFBGA15, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny20-MMH: VQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny20-MMHR: VQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny20-SSU: SOIC14, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny20-SSUR: SOIC14, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny20-UUR: WLCSP12, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny20-XU: TSSOP14, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny20-XUR: TSSOP14, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 4; - n_interrupts = 17; - signature = 0x1e 0x91 0x0f; - factory_fcpu = 1000000; - - memory "flash" - size = 2048; - page_size = 16; - n_word_writes = 2; - offset = 0x4000; - blocksize = 128; - ; - - memory "fuse" - bitmask = 0x77; - n_word_writes = 2; - ; - - memory "io" - size = 64; - ; - - memory "sram" - size = 128; - ; -; - -#------------------------------------------------------------ -# ATtiny40 -#------------------------------------------------------------ - -part parent ".reduced_core_tiny" # t40 - desc = "ATtiny40"; - id = "t40"; - variants = - "ATtiny40-MMH: VQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny40-MMHR: VQFN20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny40-SU: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny40-SUR: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny40-XU: TSSOP20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny40-XUR: TSSOP20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 5; - n_interrupts = 18; - signature = 0x1e 0x92 0x0e; - factory_fcpu = 1000000; - - memory "flash" - size = 4096; - page_size = 64; - n_word_writes = 4; - offset = 0x4000; - blocksize = 128; - ; - - memory "fuse" - bitmask = 0x77; - n_word_writes = 4; - ; - - memory "io" - size = 64; - ; - - memory "sram" - size = 256; - ; -; - -#------------------------------------------------------------ -# ATtiny102 -#------------------------------------------------------------ - -part parent ".reduced_core_tiny" # t102 - desc = "ATtiny102"; - id = "t102"; - variants = - "ATtiny102-M7R: UDFN8, Fmax=12 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny102-M8R: UDFN8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny102-SSFR: SOIC8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny102-SSNR: SOIC8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny102F-M7R: UDFN8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny102F-M8R: UDFN8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny102F-SSFR: SOIC8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny102F-SSNR: SOIC8, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 6; - n_interrupts = 16; - signature = 0x1e 0x90 0x0c; - factory_fcpu = 1000000; - - memory "flash" - size = 1024; - page_size = 16; - offset = 0x4000; - blocksize = 128; - ; - - memory "fuse" - bitmask = 0x0f; - ; - - memory "prodsig" - size = 16; - page_size = 16; - offset = 0x3fc0; - ; - - memory "sigrow" - alias "prodsig"; - ; - - memory "sernum" - size = 10; - offset = 0x3fc6; # Sub-region of prodsig - ; - - memory "io" - size = 64; - ; -; - -#------------------------------------------------------------ -# ATtiny104 -#------------------------------------------------------------ - -part parent ".reduced_core_tiny" # t104 - desc = "ATtiny104"; - id = "t104"; - variants = - "ATtiny104-SSFR: SOIC14, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny104-SSNR: SOIC14, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny104F-SSFR: SOIC14, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", - "ATtiny104F-SSNR: SOIC14, Fmax=12 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; - mcuid = 7; - n_interrupts = 16; - signature = 0x1e 0x90 0x0b; - factory_fcpu = 1000000; - - memory "flash" - size = 1024; - page_size = 16; - offset = 0x4000; - blocksize = 128; - ; - - memory "fuse" - bitmask = 0x0f; - ; - - memory "prodsig" - size = 16; - page_size = 16; - offset = 0x3fc0; - ; - - memory "sigrow" - alias "prodsig"; - ; - - memory "sernum" - size = 10; - offset = 0x3fc6; # Sub-region of prodsig - ; - - memory "io" - size = 64; - ; -; - -#------------------------------------------------------------ -# ATmega406 -#------------------------------------------------------------ - -part # m406 - desc = "ATmega406"; - id = "m406"; - variants = - "ATmega406: N/A, Fmax=1 MHz, T=[N/A, N/A], Vcc=[3.3 V, 3.3 V]", - "ATmega406-1AAU: LQFP48, Fmax=1 MHz, T=[-30 C, 85 C], Vcc=[4 V, 25 V]"; - prog_modes = PM_SPM | PM_HVPP | PM_JTAG; - mcuid = 125; - n_interrupts = 23; - n_boot_sections = 4; - boot_section_size = 512; - # STK500 parameters (parallel programming IO lines) - pagel = 0xa7; - bs2 = 0xa0; - signature = 0x1e 0x95 0x07; - reset = io; - serial = no; - # STK500v2 HV programming parameters, from XML - pp_controlstack = - 0x0e, 0x1e, 0x0f, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, - 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, - 0x66, 0x76, 0x67, 0x77, 0x6a, 0x7a, 0x6b, 0x7b, - 0xbe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - latchcycles = 6; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepolltimeout = 10; - programfusepolltimeout = 5; - programlockpolltimeout = 5; - idr = 0x31; - spmcr = 0x57; - eecr = 0x3f; - ocdrev = 3; - factory_fcpu = 1000000; - - memory "eeprom" - size = 512; - page_size = 4; - num_pages = 128; - blocksize = 4; - readsize = 4; - ; - - memory "flash" - paged = yes; - size = 0xa000; - page_size = 128; - num_pages = 320; - blocksize = 128; - readsize = 128; - ; - - memory "lfuse" - size = 1; - initval = 0xcd; - ; - - memory "hfuse" - size = 1; - initval = 0xfe; - bitmask = 0x03; - ; - - memory "lockbits" - size = 1; - initval = 0xff; - bitmask = 0x3f; - ; - - memory "signature" - size = 3; - ; - - memory "io" - size = 224; - offset = 0x20; - ; - - memory "sram" - size = 2048; - offset = 0x100; - ; -; - #------------------------------------------------------------ # AVR8X family common values #------------------------------------------------------------ @@ -25650,93 +23192,3 @@ part parent "16eb14" # 16eb32 mcuid = 383; signature = 0x1e 0x94 0x3e; ; - -#------------------------------------------------------------ -# Logic Green parts -#------------------------------------------------------------ - -part parent "m88" # lgt8f88p - desc = "LGT8F88P"; - id = "lgt8f88p"; - mcuid = 227; - signature = 0x1e 0x93 0x0f; - autobaud_sync = 0x1c; - - memory "lfuse" - initval = -1; - ; - - memory "hfuse" - initval = -1; - ; - - memory "efuse" - initval = -1; - bitmask = -1; - ; - - memory "lock" - initval = -1; - bitmask = -1; - ; -; - -#------------------------------------------------------------ -# LGT8F168P -#------------------------------------------------------------ - -part parent "m168" # lgt8f168p - desc = "LGT8F168P"; - id = "lgt8f168p"; - mcuid = 228; - signature = 0x1e 0x94 0x0b; - autobaud_sync = 0x1c; - - memory "lfuse" - initval = -1; - ; - - memory "hfuse" - initval = -1; - ; - - memory "efuse" - initval = -1; - bitmask = -1; - ; - - memory "lock" - initval = -1; - bitmask = -1; - ; -; - -#------------------------------------------------------------ -# LGT8F328P -#------------------------------------------------------------ - -part parent "m328" # lgt8f328p - desc = "LGT8F328P"; - id = "lgt8f328p"; - mcuid = 229; - signature = 0x1e 0x95 0x0f; - autobaud_sync = 0x1c; - - memory "lfuse" - initval = -1; - ; - - memory "hfuse" - initval = -1; - ; - - memory "efuse" - initval = -1; - bitmask = -1; - ; - - memory "lock" - initval = -1; - bitmask = -1; - ; -; From 96e92ba4704a5781adc4e75688dd568afe887bad Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 01:24:13 +0100 Subject: [PATCH 259/422] Extend prodsig and sernum to virtually all classic parts --- src/avrdude.1 | 10 +++++-- src/avrdude.conf.in | 69 +++++++++++++++++++++++++------------------- src/doc/avrdude.texi | 7 ++++- 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index 71524ddc..2f43e8af 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -847,11 +847,17 @@ Low fuse byte .It lock Lock byte .It prodsig -Signature, calibration byte and serial number in a small read-only memory, +Signature, calibration byte(s) and serial number in a small read-only memory, which is only documented to be available for ATmega324PB, ATmega328PB, -ATtiny102 and ATtiny104; programmers may or may not be able to read this memory +ATtiny102 and ATtiny104; +.Nm +generally tries to make this memory available, also for parts where it is +not documented, but not all programmers may be able to read this memory .It sigrow Memory alias for prodsig +.It sernum +The serial number part of prodsig; owing to scarce documentation this may not +actually turn out to be a serial number or be readable by some programmers .It usersig Three extra flash pages for firmware settings; this memory is not erased during a chip erase. Only some classic parts, diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 46531cc8..d7478a49 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -3784,10 +3784,25 @@ part parent ".classic-nocal" # .classic chip_erase = "1010.1100--1000.0000--0000.0000--0000.0000"; pgm_enable = "1010.1100--0101.0011--0000.0000--0000.0000"; + memory "prodsig" + size = 24; + read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; + ; + + memory "sigrow" + alias "prodsig"; + ; + memory "calibration" size = 1; read = "0011.1000--0000.0000--0000.0000--oooo.oooo"; ; + + memory "sernum" + size = 10; + offset = 0xe; # Sub-region of prodsig + read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; + ; ; #------------------------------------------------------------ @@ -3859,6 +3874,10 @@ part parent ".classic" # t11 write = NULL; ; + memory "prodsig" + read = NULL; + ; + memory "signature" read = NULL; ; @@ -3867,6 +3886,10 @@ part parent ".classic" # t11 read = NULL; ; + memory "sernum" + read = NULL; + ; + memory "io" size = 64; offset = 0x0; @@ -6000,6 +6023,10 @@ part parent ".classic" # t28 write = NULL; ; + memory "prodsig" + read = NULL; + ; + memory "signature" read = NULL; ; @@ -6008,6 +6035,10 @@ part parent ".classic" # t28 read = NULL; ; + memory "sernum" + read = NULL; + ; + memory "io" size = 64; ; @@ -10457,21 +10488,6 @@ part parent "m324p" # m324pb bitmask = 0x0f; write = "1010.1100--1010.0100--xxxx.xxxx--1111.iiii"; ; - - memory "prodsig" - size = 24; - read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; - ; - - memory "sigrow" - alias "prodsig"; - ; - - memory "sernum" - size = 10; - offset = 0xe; # Sub-region of prodsig - read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; - ; ; #------------------------------------------------------------ @@ -12581,21 +12597,6 @@ part parent "m328" # m328pb bitmask = 0x0f; write = "1010.1100--1010.0100--xxxx.xxxx--xxxx.iiii"; ; - - memory "prodsig" - size = 24; - read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; - ; - - memory "sigrow" - alias "prodsig"; - ; - - memory "sernum" - size = 10; - offset = 0xe; # Sub-region of prodsig - read = "0 0 1 1 a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a4 a3 a2 a1 o o o o o o o o"; - ; ; #------------------------------------------------------------ @@ -14576,6 +14577,10 @@ part parent ".classic" # m406 bitmask = 0x3f; ; + memory "prodsig" + read = NULL; + ; + memory "signature" read = NULL; ; @@ -14583,6 +14588,10 @@ part parent ".classic" # m406 memory "calibration" read = NULL; ; + + memory "sernum" + read = NULL; + ; ; #------------------------------------------------------------ diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 82c2d66d..3613631e 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -892,9 +892,14 @@ Low fuse byte @item prodsig Signature, calibration byte and serial number in a small read-only memory, which is only documented to be available for ATmega324PB, ATmega328PB, -ATtiny102 and ATtiny104; programmers may or may not be able to read this memory +ATtiny102 and ATtiny104; AVRDUDE generally tries to make this memory +available, also for parts where it is not documented, but not all +programmers may be able to read this memory @item sigrow Memory alias for prodsig +@item sernum +The serial number part of prodsig; owing to scarce documentation this may not +actually turn out to be a serial number or be readable by some programmers @item usersig Three extra flash pages for firmware settings; this memory is not erased during a chip erase. Only some classic parts, From 44104df3e274597ebac153b051bf8fd9250f642d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 15:46:24 +0100 Subject: [PATCH 260/422] Add missing space --- src/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index 937c8ac2..9702267e 100644 --- a/src/term.c +++ b/src/term.c @@ -966,7 +966,7 @@ static int cmd_erase(const PROGRAMMER *pgm, const AVRPART *p, int argc, const ch term_out("%s chip erase; discarded pending writes to flash%s\n", (pgm->prog_modes & PM_SPM)? "asking bootloader to perform": "performing", - avr_locate_bootrow(p)? ", EEPROM and bootrow": avr_locate_eeprom(p)? "and EEPROM": ""); + avr_locate_bootrow(p)? ", EEPROM and bootrow": avr_locate_eeprom(p)? " and EEPROM": ""); // Erase chip and clear cache int rc = pgm->chip_erase_cached(pgm, p); From 31bed52080e36e9e145939b15bf386698ea64b10 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 17:59:40 +0100 Subject: [PATCH 261/422] Consider prog_modes in str_ccmcunames_signature() --- src/fileio.c | 7 +++---- src/libavrdude.h | 6 +++--- src/strutil.c | 51 +++++++++++++++++++++++++++++++++++------------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 3004f1f9..4a637bca 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -352,8 +352,7 @@ static int b2ihex(const AVRPART *p, const AVRMEM *mem, const Segment *segp, Sego if(name) { fprintf(outf, " %s", name); if((str_eq(name, "sigrow") || str_eq(name, "signature")) && !nextaddr) { - char mculist[1024] = {0}; - str_mcunames_signature(buf, mculist, sizeof mculist); + const char *mculist = str_ccmcunames_signature(buf, PM_ALL); if(*mculist) fprintf(outf, " (%s)", mculist); } @@ -580,7 +579,7 @@ static int ihex2b(const char *infile, FILE *inf, const AVRPART *p, const AVRMEM if(!ovsigck && nextaddr == mulmem[MULTI_SIGROW].base && ihex.reclen >= 3) if(!avr_sig_compatible(p->signature, any->buf+nextaddr)) { pmsg_error("signature of %s incompatible with file's (%s)\n", p->desc, - str_ccmcunames_signature(any->buf+nextaddr)); + str_ccmcunames_signature(any->buf+nextaddr, PM_ALL)); imsg_error("use -F to override this check\n"); mmt_free(buffer); goto error; @@ -935,7 +934,7 @@ static int srec2b(const char *infile, FILE * inf, const AVRPART *p, if(!ovsigck && nextaddr == mulmem[MULTI_SIGROW].base && srec.reclen >= 3) if(!avr_sig_compatible(p->signature, any->buf+nextaddr)) { pmsg_error("signature of %s incompatible with file's (%s)\n", p->desc, - str_ccmcunames_signature(any->buf+nextaddr)); + str_ccmcunames_signature(any->buf+nextaddr, PM_ALL)); imsg_error("use -F to override this check\n"); mmt_free(buffer); goto error; diff --git a/src/libavrdude.h b/src/libavrdude.h index baa24b1c..9fa9041a 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -511,7 +511,7 @@ typedef struct avrmem { int initval; /* factory setting of fuses and lock bits */ int bitmask; /* bits used in fuses and lock bits */ int n_word_writes; /* TPI only: number words to write at a time */ - unsigned int offset; /* offset in IO memory (ATxmega) */ + unsigned int offset; /* offset in IO memory (ATxmega, UPDI, some classic memories) */ int min_write_delay; /* microseconds */ int max_write_delay; /* microseconds */ int pwroff_after_write; /* after this memory is written to, @@ -1524,8 +1524,8 @@ char *str_nexttok(char *buf, const char *delim, char **next); const char *str_ccfrq(double f, int n); int str_levenshtein(const char *str1, const char *str2, int swap, int subst, int add, int del); size_t str_weighted_damerau_levenshtein(const char *str1, const char *str2); -int str_mcunames_signature(const unsigned char *sigs, char *p, size_t n); -const char *str_ccmcunames_signature(const unsigned char *sigs); +int str_mcunames_signature(const unsigned char *sigs, int pm, char *p, size_t n); +const char *str_ccmcunames_signature(const unsigned char *sigs, int pm); int led_set(const PROGRAMMER *pgm, int led); int led_clr(const PROGRAMMER *pgm, int led); diff --git a/src/strutil.c b/src/strutil.c index 4d442f91..b281f411 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1330,19 +1330,40 @@ size_t str_weighted_damerau_levenshtein(const char *s1, const char *s2) { // Puts a comma-separated list of matching MCU names into array p with n chars space -int str_mcunames_signature(const unsigned char *sigs, char *p, size_t n) { - int matching = 0; +int str_mcunames_signature(const unsigned char *sigs, int pm, char *p, size_t n) { + int matching = 0, k; + const int N = 100; + const char *matches[N]; - for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++) { - if(0 == memcmp(sigs, uP_table[i].sigs, sizeof uP_table->sigs)) { - if(matching && n > 2) - strcpy(p, ", "), n -= 2, p += 2; - size_t len = strlen(uP_table[i].name); - if(n > len) { - strcpy(p, uP_table[i].name); - n -= len; p += len; + if(!pm || (pm & PM_ALL) == PM_ALL) // Look up uP table when unrestricted by prog modes + for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++) + if(0 == memcmp(sigs, uP_table[i].sigs, sizeof uP_table->sigs) && matching < N) + matches[matching++] = uP_table[i].name; + + for(LNODEID lp = lfirst(part_list); lp; lp = lnext(lp)) { + AVRPART *pp = ldata(lp); + if(0 == memcmp(sigs, pp->signature, 3) && (!pm || (pp->prog_modes & pm))) { + for(k = 0; k < matching; k++) + if(str_eq(matches[k], pp->desc)) + break; + if(k == matching && matching < N) + matches[matching++] = pp->desc; + } + } + + if(n && p) { + *p = 0; + + for(int i = 0; i < matching; i++) { + size_t len = strlen(matches[i]); + if(n > len + 2) { + if(i) { + strcpy(p, ", "); + n -= 2, p += 2; + } + strcpy(p, matches[i]); + n -= len, p += len; } - matching++; } } @@ -1350,9 +1371,11 @@ int str_mcunames_signature(const unsigned char *sigs, char *p, size_t n) { } // Returns a comma-separated list of matching MCU names in closed-circuit space -const char *str_ccmcunames_signature(const unsigned char *sigs) { - char names[1024] = {0}; - (void) str_mcunames_signature(sigs, names, sizeof names); +const char *str_ccmcunames_signature(const unsigned char *sigs, int pm) { + char names[1024]; + // If no match is found, given required prog_modes, relax the match to any prog mode + if(!str_mcunames_signature(sigs, pm, names, sizeof names) && pm && (pm & PM_ALL) != PM_ALL) + (void) str_mcunames_signature(sigs, 0, names, sizeof names); return str_ccprintf("%s", names); } From 811d01e9dbd70187f5d7458626f61bc114d8110e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 18:35:37 +0100 Subject: [PATCH 262/422] Check several signature offsets when trying a -p UPDI part --- src/main.c | 53 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/src/main.c b/src/main.c index 51b0cb46..4555d342 100644 --- a/src/main.c +++ b/src/main.c @@ -1594,7 +1594,7 @@ skipopen: if (uflags & UF_NOWRITE) { pmsg_warning("conflicting -e and -n options specified, NOT erasing chip\n"); } else { - pmsg_info("erasing chip\n"); + pmsg_info("trying to unlock the chip\n"); exitrc = avr_unlock(pgm, p); if(exitrc) goto main_exit; @@ -1619,33 +1619,48 @@ skipopen: sig = avr_locate_signature(p); if (sig == NULL) pmsg_warning("signature memory not defined for device %s\n", p->desc); + else { + const char *mculist = str_ccmcunames_signature(sig->buf, pgm->prog_modes); + if(!*mculist) { + if(p->prog_modes & PM_UPDI) { // UPDI parts have different(!) offsets for signature + int k, n = 0; // Gather list of known different signature offsets + unsigned myoff = sig->offset, offlist[10]; + for(LNODEID ln1 = lfirst(part_list); ln1; ln1 = lnext(ln1)) { + AVRMEM *m = avr_locate_signature(ldata(ln1)); + if(m && m->offset != myoff) { + for(k=0; koffset == offlist[k]) + break; + if(k == n && k < (int) (sizeof offlist/sizeof*offlist)) + offlist[n++] = m->offset; + } + } + // Now go through the list of other(!) sig offsets and try these + for(k=0; koffset = offlist[k]; + if(avr_signature(pgm, p) >= 0) + if(*(mculist = str_ccmcunames_signature(sig->buf, pgm->prog_modes))) + break; + } + sig->offset = myoff; + } + } - if (sig != NULL) { - int ff, zz; - - pmsg_info("device signature = 0x"); - ff = zz = 1; + pmsg_info("device signature ="); + int ff = 1, zz = 1; for (i=0; isize; i++) { - msg_info("%02x", sig->buf[i]); + msg_info(" %02X", sig->buf[i]); if (sig->buf[i] != 0xff) ff = 0; if (sig->buf[i] != 0x00) zz = 0; } + if(*mculist) + msg_info(" (%s)", mculist); - bool signature_matches = - sig->size == 3 && - sig->buf[0] == p->signature[0] && - sig->buf[1] == p->signature[1] && - sig->buf[2] == p->signature[2]; + bool signature_matches = sig->size >= 3 && !memcmp(sig->buf, p->signature, 3); - if (quell_progress < 2) { - AVRPART *part; - if((part = locate_part_by_signature_pm(part_list, sig->buf, sig->size, pgm->prog_modes)) || - (part = locate_part_by_signature(part_list, sig->buf, sig->size))) - msg_info(" (probably %s)", signature_matches? p->id: part->id); - } - if (ff || zz) { + if (ff || zz) { // All three bytes are 0xff or all three bytes are 0x00 if (++attempt < 3) { waittime *= 5; msg_info(" (retrying)\n"); From 43c915aca35b3dc51bf4dac814ba85b3dec6d03e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 19:13:45 +0100 Subject: [PATCH 263/422] Skip parts with all 0xff/0x00 signature --- src/strutil.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/strutil.c b/src/strutil.c index b281f411..fe1234b7 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1337,12 +1337,17 @@ int str_mcunames_signature(const unsigned char *sigs, int pm, char *p, size_t n) if(!pm || (pm & PM_ALL) == PM_ALL) // Look up uP table when unrestricted by prog modes for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++) - if(0 == memcmp(sigs, uP_table[i].sigs, sizeof uP_table->sigs) && matching < N) - matches[matching++] = uP_table[i].name; + if(!is_memset(uP_table[i].sigs, 0xff, 3) && !is_memset(uP_table[i].sigs, 0, 3)) + if(0 == memcmp(sigs, uP_table[i].sigs, sizeof uP_table->sigs) && matching < N) + matches[matching++] = uP_table[i].name; for(LNODEID lp = lfirst(part_list); lp; lp = lnext(lp)) { AVRPART *pp = ldata(lp); - if(0 == memcmp(sigs, pp->signature, 3) && (!pm || (pp->prog_modes & pm))) { + if(!*pp->id || *pp->id == '.') // Skip invalid entries + continue; + if(is_memset(pp->signature, 0xff, 3) || is_memset(pp->signature, 0, 3)) + continue; + if(!memcmp(sigs, pp->signature, 3) && (!pm || (pp->prog_modes & pm))) { for(k = 0; k < matching; k++) if(str_eq(matches[k], pp->desc)) break; From 99bd83c1867b5eb94e353cce637895b11750efce Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 19:27:04 +0100 Subject: [PATCH 264/422] Suppress overzealous compiler warnings --- src/config_gram.y | 2 +- src/fileio.c | 12 ++++++------ src/strutil.c | 5 ++--- src/update.c | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/config_gram.y b/src/config_gram.y index 11e57316..dcfc0d68 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -383,7 +383,7 @@ part_def : if(mem_is_signature(m)) m->type &= ~MEM_IN_SIGROW; } - if(fileio_mem_offset(current_part, m) == -1U) + if(fileio_mem_offset(current_part, m) == ~0U) yywarning("revise fileio_mem_offset(), avrdude.conf entry or memory type assignment"); } diff --git a/src/fileio.c b/src/fileio.c index 4a637bca..b6303760 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -232,22 +232,22 @@ unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) { mem_is_sib(mem)? MBASE(SIGROW) + 0x1000: // Arbitrary 0x1000 offset in signature section for sib mem_is_userrow(mem)? MBASE(USERROW): mem_is_bootrow(mem)? MBASE(BOOTROW): - -1U; + ~0U; - if(location == -1U) + if(location == ~0U) pmsg_error("unable to locate %s's %s in multi-memory address space\n", p->desc, mem->desc); else if(location >= ANY_MEM_SIZE || location + mem->size > ANY_MEM_SIZE) { // Overflow pmsg_error("%s's %s location [0x%06x, 0x%06x] outside flat address space [0, 0x%06x]\n", p->desc, mem->desc, location, location + mem->size-1, ANY_MEM_SIZE-1); - location = -1U; + location = ~0U; } else if(location <= MEND(FLASH) && location + mem->size > MEND(FLASH)+1) { pmsg_error("%s's %s location [0x%06x, 0x%06x] straddles flash section boundary 0x%06x\n", p->desc, mem->desc, location, location + mem->size-1, MEND(FLASH)+1); - location = -1U; + location = ~0U; } else if(location > MEND(FLASH) && location/0x10000 != (location + mem->size-1)/0x10000) { pmsg_error("%s's %s memory location [0x%06x, 0x%06x] straddles memory section boundary 0x%02x0000\n", p->desc, mem->desc, location, location + mem->size-1, 1+location/0x10000); - location = -1U; + location = ~0U; } return location; @@ -465,7 +465,7 @@ static int any2mem(const AVRPART *p, const AVRMEM *mem, const Segment *segp, // Compute location for multi-memory file input unsigned location = maxsize > MEND(FLASH)+1? fileio_mem_offset(p, mem): 0; - if(location == -1U) + if(location == ~0U) return -1; unsigned ret = 0; diff --git a/src/strutil.c b/src/strutil.c index fe1234b7..9fcd158f 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1331,9 +1331,8 @@ size_t str_weighted_damerau_levenshtein(const char *s1, const char *s2) { // Puts a comma-separated list of matching MCU names into array p with n chars space int str_mcunames_signature(const unsigned char *sigs, int pm, char *p, size_t n) { - int matching = 0, k; - const int N = 100; - const char *matches[N]; + const char *matches[100]; + int matching = 0, k, N = sizeof matches/sizeof*matches; if(!pm || (pm & PM_ALL) == PM_ALL) // Look up uP table when unrestricted by prog modes for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++) diff --git a/src/update.c b/src/update.c index 9a5637a7..3b1bcb89 100644 --- a/src/update.c +++ b/src/update.c @@ -721,7 +721,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat continue; } unsigned off = fileio_mem_offset(p, m); - if(off == -1U) { + if(off == ~0U) { pmsg_warning("cannot map %s to flat address space, skipping ...\n", m_name); rwvproblem = 1; continue; From d8836d3819b47078b620d7938a4cf714243024ad Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 19:40:27 +0100 Subject: [PATCH 265/422] Fix jtag3 access to prodsig sub-memories --- src/jtag3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jtag3.c b/src/jtag3.c index 854ccc70..76e68c38 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -2213,7 +2213,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM return -1; } } else if(mem_is_in_sigrow(mem)) { // sigrow submemories but not signature nor sigrow itself - cmd[3] = (p->prog_modes & PM_PDI)? MTYPE_SIGN_JTAG: MTYPE_PRODSIG; + cmd[3] = MTYPE_PRODSIG; AVRMEM *sigrow = avr_locate_sigrow(p); if(sigrow) addr += mem->offset - sigrow->offset; // Adjust offset for parent memory From 0c710432d27e8290c7f1baa89351f260f8fde94d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 23:09:03 +0100 Subject: [PATCH 266/422] Update term command usage --- src/term.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/term.c b/src/term.c index 9702267e..a25d63b1 100644 --- a/src/term.c +++ b/src/term.c @@ -733,7 +733,7 @@ static int cmd_backup(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c "Notes:\n" " - Backup flushes the cache before reading memories\n" " - can be a comma separated list of known memories, all, etc or ALL\n" - " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" + " - ALL also includes sub-memories, eg, boot; all doesn't; etc is same as all\n" " - A leading - or \\ removes that memory from the list so far, eg, all,-bootrow\n" ); return -1; @@ -775,7 +775,7 @@ static int cmd_restore(const PROGRAMMER *pgm, const AVRPART *p, int argc, const " - Restore flushes the cache before writing memories\n" " - After writing memories restore resets the cache\n" " - can be a comma separated list of known memories, all, etc or ALL\n" - " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" + " - ALL also includes sub-memories, eg, boot; all doesn't; etc is same as all\n" " - A leading - or \\ removes that memory from the list so far, eg, all,-bootrow\n" " - Skips read-only memories in a list and, for bootloaders, also fuses and lock\n" " - Writing to single read-only memories only fails if the contents differs\n" @@ -818,7 +818,7 @@ static int cmd_verify(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c "Notes:\n" " - Verify flushes the cache before verifying memories\n" " - can be a comma separated list of known memories, all, etc or ALL\n" - " - ALL includes submemories, eg, boot in flash; all doesn't; etc is same as all\n" + " - ALL also includes sub-memories, eg, boot; all doesn't; etc is same as all\n" " - A leading - or \\ removes that memory from the list so far, eg, all,-bootrow\n" ); return -1; From dbb1ceff1ac0cb2e72323954fc3dff83fd171cc4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 14 Jul 2024 23:12:20 +0100 Subject: [PATCH 267/422] Fix jtag3 access to UPDI sigrow sub-memories --- src/jtag3.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jtag3.c b/src/jtag3.c index 76e68c38..43ae6d5c 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -2135,7 +2135,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM paddr_ptr = &PDATA(pgm)->flash_pageaddr; cache_ptr = PDATA(pgm)->flash_pagecache; } else if (mem_is_eeprom(mem)) { - if ( (pgm->flag & PGM_FL_IS_DW) || (p->prog_modes & PM_PDI) || (p->prog_modes & PM_UPDI) ) { + if ((pgm->flag & PGM_FL_IS_DW) || (p->prog_modes & (PM_PDI | PM_UPDI))) { cmd[3] = MTYPE_EEPROM; } else { cmd[3] = MTYPE_EEPROM_PAGE; @@ -2212,8 +2212,8 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM msg_error("address out of range for signature memory: %lu\n", addr); return -1; } - } else if(mem_is_in_sigrow(mem)) { // sigrow submemories but not signature nor sigrow itself - cmd[3] = MTYPE_PRODSIG; + } else if(mem_is_in_sigrow(mem)) { // sigrow sub-memories but not signature nor sigrow itself + cmd[3] = (p->prog_modes & PM_UPDI)? MTYPE_SIGN_JTAG: MTYPE_PRODSIG; AVRMEM *sigrow = avr_locate_sigrow(p); if(sigrow) addr += mem->offset - sigrow->offset; // Adjust offset for parent memory From e4c67c2c6e43d32839b06ce31a15d6d0a2a938f4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 15 Jul 2024 15:56:36 +0100 Subject: [PATCH 268/422] Skip stump parts and all 0xff/0x00 signatures in locate_part_by_signature() --- src/avrpart.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index 38f38a97..0de5303d 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -1071,12 +1071,16 @@ AVRPART *locate_part_by_avr910_devcode(const LISTID parts, int devcode) { return NULL; } +// Return pointer to first part that has signature sig (unless all 0xff or all 0x00); NULL if no match AVRPART *locate_part_by_signature_pm(const LISTID parts, unsigned char *sig, int sigsize, int prog_modes) { if(parts && sigsize == 3) { for(LNODEID ln=lfirst(parts); ln; ln=lnext(ln)) { AVRPART *p = ldata(ln); - if(memcmp(p->signature, sig, 3) == 0 && p->prog_modes & prog_modes) - return p; + if(!*p->id || *p->id == '.') // Skip stump entries + continue; + if(!is_memset(p->signature, 0xff, 3) && !is_memset(p->signature, 0, 3)) + if(!memcmp(p->signature, sig, 3) && p->prog_modes & prog_modes) + return p; } } return NULL; From f3caabf264b8833f1eb0e9f988d03c188230bd14 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 15 Jul 2024 15:57:53 +0100 Subject: [PATCH 269/422] Make dryrun vector tables more realistic --- src/dryrun.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/dryrun.c b/src/dryrun.c index e5c3bbaf..2e8918bb 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -298,14 +298,22 @@ static int flashlayout(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *fl // Write a vector table to flash addr and return number of bytes written static int putvectortable(const AVRPART *p, const AVRMEM *flm, int addr) { int vecsz = flm->size <= 8192? 2: 4, ret = p->n_interrupts * vecsz; + int app = (ret + vecsz - 2)/2; // Distance to application in words - for(int i = 0; i < ret; i += vecsz) { // First store rjmps - flm->buf[addr + i] = 255-i/2; - flm->buf[addr + i + 1] = 0xcf; // rjmp .-2, rjmp .-6, ... + for(int i = 0; i < ret; i += vecsz) { // First store rjmps to after table + flm->buf[addr + i] = app; + flm->buf[addr + i + 1] = 0xc0 + (app>>8); // rjmp app, rjmp app, ... + app -= vecsz/2; } + for(int i=0; i < vecsz; i++) // Leave one vector gap + flm->buf[addr + ret++] = ' '; + + flm->buf[addr + ret++] = 0xff; // Put endless lopp as application + flm->buf[addr + ret++] = 0xcf; + // Then round up to multiples of 32 while(ret%32) - flm->buf[ret++] = ' '; + flm->buf[addr + ret++] = ' '; return ret; } From ca4534af84a222db106e13058cdf4f0fbdbccd9b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 15 Jul 2024 17:31:55 +0100 Subject: [PATCH 270/422] Remove unnecessary empty lines in avrdude.conf --- src/avrdude.conf.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index d7478a49..8495e72d 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -5127,8 +5127,6 @@ part parent "t44" # t44a "ATtiny44A-SSU: SOIC14, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATtiny44A-SSUR: SOIC14N, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = XVII + IV; # 21; - - ; #------------------------------------------------------------ From 5dc2399694e3fc972648169e98c5ca64f16d65d2 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 15 Jul 2024 17:41:26 +0100 Subject: [PATCH 271/422] Update NEWS --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 24be8646..50f039ee 100644 --- a/NEWS +++ b/NEWS @@ -44,6 +44,8 @@ Changes since version 7.3: - AVRDUDE fails to return -1 on some write errors #1821 - Multi-memory files #1817 - Terminal erase command #1833 + - Bootrow r/w does not work for -c serialupdi #1832 + - Wrong error message when specifying wrong AVR-Ex part #1813 * Pull requests: @@ -103,6 +105,9 @@ Changes since version 7.3: - Add developer options -p*/vcr to explore SW compatibility #1830 - Improve chip erase emulation for dryboot/dryrun #1836 - Use page erase for UPDI programming #1837 + - Add fuses, calibration, sernum and tempsense memories #1829 + - Fix bootrow access for -c serialupdi #1835 + - Improve signature check for UPDI parts #1840 * Internals: From 8f575224b1277947913bdc3f858c96392e1f97a0 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 10:31:41 +0100 Subject: [PATCH 272/422] Add avrdisas-0.07 sources --- src/Callbacks_Assembly.c | 831 +++++++++++++++++++++++++++++++++++++ src/Callbacks_Assembly.h | 173 ++++++++ src/Callbacks_PseudoCode.c | 660 +++++++++++++++++++++++++++++ src/Callbacks_PseudoCode.h | 106 +++++ src/Functions.h | 35 ++ src/Globals.h | 211 ++++++++++ src/IORegisters.c | 114 +++++ src/IORegisters.h | 29 ++ src/JumpCall.c | 180 ++++++++ src/JumpCall.h | 34 ++ src/MNemonics.c | 444 ++++++++++++++++++++ src/MNemonics.h | 30 ++ src/Options.c | 172 ++++++++ src/Options.h | 29 ++ src/Tagfile.c | 453 ++++++++++++++++++++ src/Tagfile.h | 39 ++ src/Tools.c | 37 ++ src/Tools.h | 27 ++ src/avrdisas.c | 587 ++++++++++++++++++++++++++ 19 files changed, 4191 insertions(+) create mode 100644 src/Callbacks_Assembly.c create mode 100644 src/Callbacks_Assembly.h create mode 100644 src/Callbacks_PseudoCode.c create mode 100644 src/Callbacks_PseudoCode.h create mode 100644 src/Functions.h create mode 100644 src/Globals.h create mode 100644 src/IORegisters.c create mode 100644 src/IORegisters.h create mode 100644 src/JumpCall.c create mode 100644 src/JumpCall.h create mode 100644 src/MNemonics.c create mode 100644 src/MNemonics.h create mode 100644 src/Options.c create mode 100644 src/Options.h create mode 100644 src/Tagfile.c create mode 100644 src/Tagfile.h create mode 100644 src/Tools.c create mode 100644 src/Tools.h create mode 100644 src/avrdisas.c diff --git a/src/Callbacks_Assembly.c b/src/Callbacks_Assembly.c new file mode 100644 index 00000000..5c2f15ba --- /dev/null +++ b/src/Callbacks_Assembly.c @@ -0,0 +1,831 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include + +#include "MNemonics.h" +#include "Globals.h" +#include "Callbacks_Assembly.h" +#include "JumpCall.h" +#include "IORegisters.h" +#include "Functions.h" +#include "Tools.h" +#include "Tagfile.h" + +static char *Code_Line; +static char *Comment_Line; +static char *After_Code_Line; +static int *Registers; +static struct Options *Options; + +void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, struct Options *New_Options) { + Code_Line = New_Code_Line; + Comment_Line = New_Comment_Line; + After_Code_Line = New_After_Code_Line; + Registers = New_Registers; + Options = New_Options; +} + +void Operation_Simple(int MNemonic_Int) { + snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); +} + +void Operation_Rd(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); +} + +void Operation_Rd16(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); +} + +void Operation_Rd_Rr(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); +} + +void Operation_Rd16_Rr16(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); +} + +void Operation_Rd16_K(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); + snprintf(Comment_Line, 255, "%d", RK); +} + +void Operation_Rd_K(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(Comment_Line, 255, "%d", RK); +} + +void Operation_RdW_K(int MNemonic_Int) { + if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + } + snprintf(Comment_Line, 255, "%d", RK); +} + +void Operation_RdW_RrW(int MNemonic_Int) { + if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); + } else { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); + } +} + +void Operation_s_k(int MNemonic_Int, int Position) { + int Bits, Offset; + int Target; + + Bits = Rs; + Offset = (2 * Rk); + if (Offset > 128) Offset -= 256; + Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + if (Options->Process_Labels == 0) { + if (Offset>0) { + snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); + } else { + snprintf(Code_Line, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); + } + snprintf(Comment_Line, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); + } else { + snprintf(Code_Line, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); + } +} + +void Operation_r_b(int MNemonic_Int) { + int Register, Bit; + Register = Rr; + Bit = Rb; + snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void Operation_Rd_b(int MNemonic_Int) { + int Register, Bit; + Register = Rd; + Bit = Rb; + snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void Operation_A_b(int MNemonic_Int) { + int Register, Bit; + const char *Register_Name; + Register = RA; + Bit = Rb; + Register_Name = Resolve_IO_Register(Register); + if (Register_Name == NULL) { + snprintf(Code_Line, 255, "%-7s 0x%02x, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + } else { + snprintf(Code_Line, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + } +} + +void Operation_s(int MNemonic_Int) { + int Bit; + Bit = Rs; + snprintf(Code_Line, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { + int Offset; + int Target; + + Offset = (2 * Rk); + if (Offset > 128) Offset -= 256; + Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + if (Options->Process_Labels == 0) { + if (Offset>0) { + snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + } else { + snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + } + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); + } +} + +/************* Now to the callback functions *************/ + +CALLBACK(adc_Callback) { + if (Rd == Rr) { + Operation_Rd(OPCODE_rol); + } else { + Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(add_Callback) { + if (Rd == Rr) { + Operation_Rd(OPCODE_lsl); + } else { + Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(adiw_Callback) { + if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); + } + snprintf(Comment_Line, 255, "%d", RK); +} + +CALLBACK(and_Callback) { + if (Rd == Rr) { + Operation_Rd(OPCODE_tst); + } else { + Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(andi_Callback) { + if (BitCount(RK) < 4) { + Operation_Rd16_K(MNemonic_Int); + } else { + RK = ~RK; + RK &= 0xff; + Operation_Rd16_K(OPCODE_cbr); + } +} + +CALLBACK(asr_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(bclr_Callback) { + Operation_s(MNemonic_Int); +} + +CALLBACK(bld_Callback) { + Operation_Rd_b(MNemonic_Int); +} + +CALLBACK(brbc_Callback) { + Operation_s_k(MNemonic_Int, Position); +} + +CALLBACK(brbs_Callback) { + Operation_s_k(MNemonic_Int, Position); +} + +CALLBACK(brcc_Callback) { + Operation_k(MNemonic_Int, Position, "Carry == 0"); +} + +CALLBACK(brcs_Callback) { + Operation_k(MNemonic_Int, Position, "Carry == 1"); +} + +CALLBACK(break_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(breq_Callback) { + Operation_k(MNemonic_Int, Position, "c1 == c2"); +} + +CALLBACK(brge_Callback) { + Operation_k(MNemonic_Int, Position, "c1 (signed)>= c2"); +} + +CALLBACK(brhc_Callback) { + Operation_k(MNemonic_Int, Position, "HalfCarry == 0"); +} + +CALLBACK(brhs_Callback) { + Operation_k(MNemonic_Int, Position, "HalfCarry == 1"); +} + +CALLBACK(brid_Callback) { + Operation_k(MNemonic_Int, Position, "Global_Interrupts_Disabled()"); +} + +CALLBACK(brie_Callback) { + Operation_k(MNemonic_Int, Position, "Global_Interrupts_Enabled()"); +} + +CALLBACK(brlo_Callback) { + Operation_k(MNemonic_Int, Position, "c1 (unsigned)< c2"); +} + +CALLBACK(brlt_Callback) { + Operation_k(MNemonic_Int, Position, "c1 (signed)< c2"); +} + +CALLBACK(brmi_Callback) { + Operation_k(MNemonic_Int, Position, "< 0"); +} + +CALLBACK(brne_Callback) { + Operation_k(MNemonic_Int, Position, "c1 != c2"); +} + +CALLBACK(brpl_Callback) { + Operation_k(MNemonic_Int, Position, "> 0"); +} + +CALLBACK(brsh_Callback) { + Operation_k(MNemonic_Int, Position, "c1 (unsigned)>= c2"); +} + +CALLBACK(brtc_Callback) { + Operation_k(MNemonic_Int, Position, "T == 0"); +} + +CALLBACK(brts_Callback) { + Operation_k(MNemonic_Int, Position, "T == 1"); +} + +CALLBACK(brvc_Callback) { + Operation_k(MNemonic_Int, Position, "Overflow == 0"); +} + +CALLBACK(brvs_Callback) { + Operation_k(MNemonic_Int, Position, "Overflow == 1"); +} + +CALLBACK(bset_Callback) { + Operation_s(MNemonic_Int); +} + +CALLBACK(bst_Callback) { + Operation_Rd_b(MNemonic_Int); +} + +CALLBACK(call_Callback) { + int Pos; + Pos = FixTargetAddress(2 * Rk); + Register_JumpCall(Position, Pos, MNemonic_Int, 1); + if (!Options->Process_Labels) { + snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); + } else { + char *LabelName; + char *LabelComment = NULL; + LabelName = Get_Label_Name(Pos, &LabelComment); + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); + if (LabelComment != NULL) snprintf(Comment_Line, 255, "%s", LabelComment); + } +} + +CALLBACK(cbi_Callback) { + Operation_A_b(MNemonic_Int); +} + +CALLBACK(clc_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(clh_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(cli_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(cln_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(cls_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(clt_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(clv_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(clz_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(com_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(cp_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(cpc_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(cpi_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(cpse_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(dec_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(eicall_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(eijmp_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(elpm1_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(elpm2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(elpm3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(eor_Callback) { + if (Rd == Rr) { + Operation_Rd(OPCODE_clr); + } else { + Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(fmul_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(fmuls_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(fmulsu_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(icall_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(ijmp_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(in_Callback) { + int Register_Number; + const char *Register_Name; + Register_Number = RA; + Register_Name = Resolve_IO_Register(Register_Number); + if (Register_Name != NULL) { + snprintf(Code_Line, 255, "%-7s r%d, %s", MNemonic[MNemonic_Int], Rd, Register_Name); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, Register_Number); + snprintf(Comment_Line, 255, "%d", RA); + } +} + +CALLBACK(inc_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(jmp_Callback) { + int Pos; + Pos = FixTargetAddress(2 * Rk); + if (!Options->Process_Labels) { + snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); + } else { + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Pos, NULL)); + } + Register_JumpCall(Position, Pos, MNemonic_Int, 0); +} + +CALLBACK(ld1_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, X", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ld2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, X+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ld3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, -X", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldy1_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Y", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldy2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Y+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldy3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, -Y", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldy4_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Y+%d", MNemonic[MNemonic_Int], Rd, Rq); +} + +CALLBACK(ldz1_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldz2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldz3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, -Z", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldz4_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z+%d", MNemonic[MNemonic_Int], Rd, Rq); +} + +CALLBACK(ldi_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(lds_Callback) { + const char *MemAddress; + snprintf(Code_Line, 255, "%-7s r%d, 0x%04x", MNemonic[MNemonic_Int], Rd, Rk); + MemAddress = Tagfile_Resolve_Mem_Address(Rk); + snprintf(Code_Line, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); + if (MemAddress) { + snprintf(Comment_Line, 255, "%s", MemAddress); + } +} + +CALLBACK(lpm1_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(lpm2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(lpm3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(lsr_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(mov_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(movw_Callback) { + Operation_RdW_RrW(MNemonic_Int); +} + +CALLBACK(mul_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(muls_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(mulsu_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(neg_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(nop_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(or_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(ori_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(out_Callback) { + int Register_Number; + const char *Register_Name; + Register_Number = RA; + Register_Name = Resolve_IO_Register(Register_Number); + if (Register_Name != NULL) { + snprintf(Code_Line, 255, "%-7s %s, r%d", MNemonic[MNemonic_Int], Register_Name, Rr); + } else { + snprintf(Code_Line, 255, "%-7s 0x%02x, r%d", MNemonic[MNemonic_Int], Register_Number, Rr); + snprintf(Comment_Line, 255, "%d", RA); + } +} + +CALLBACK(pop_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(push_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(rcall_Callback) { + int Offset; + int Target; + + Offset = 2 * (Rk); + if (Offset > 4096) Offset -= 8192; + Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 1); + if (Options->Process_Labels == 0) { + if (Offset>0) { + snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + } else { + snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + } + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + char *LabelName; + char *LabelComment = NULL; + LabelName = Get_Label_Name(Target, &LabelComment); + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); + if (LabelComment != NULL) snprintf(Comment_Line, 255, "%s", LabelComment); + } +} + +CALLBACK(ret_Callback) { + Operation_Simple(MNemonic_Int); + snprintf(After_Code_Line, 255, "\n"); +} + +CALLBACK(reti_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(rjmp_Callback) { + int Offset; + int Target; + + Offset = 2 * (Rk); + if (Offset > 4096) Offset -= 8192; + Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + + if (Options->Process_Labels == 0) { + if (Offset>0) { + snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + } else { + snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + } + if (Target >= 0) { + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + snprintf(Comment_Line, 255, "-0x%02x - Illegal jump position -- specify flash size!", -Target); + } + } else { + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); + } +} + +CALLBACK(ror_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(sbc_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(sbci_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(sbi_Callback) { + Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbic_Callback) { + Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbis_Callback) { + Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbiw_Callback) { + if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2*Rd+25, 2*Rd+24, RK); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2*Rd+24, RK); + } + snprintf(Comment_Line, 255, "%d", RK); +} + +CALLBACK(sbr_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(sbrc_Callback) { + Operation_r_b(MNemonic_Int); +} + +CALLBACK(sbrs_Callback) { + Operation_r_b(MNemonic_Int); +} + +CALLBACK(sec_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(seh_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sei_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sen_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(ser_Callback) { + Operation_Rd16(MNemonic_Int); +} + +CALLBACK(ses_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(set_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sev_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sez_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sleep_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(spm_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(st1_Callback) { + snprintf(Code_Line, 255, "%-7s X, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(st2_Callback) { + snprintf(Code_Line, 255, "%-7s X+, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(st3_Callback) { + snprintf(Code_Line, 255, "%-7s -X, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(sty1_Callback) { + snprintf(Code_Line, 255, "%-7s Y, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(sty2_Callback) { + snprintf(Code_Line, 255, "%-7s Y+, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(sty3_Callback) { + snprintf(Code_Line, 255, "%-7s -Y, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(sty4_Callback) { + snprintf(Code_Line, 255, "%-7s Y+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); +} + +CALLBACK(stz1_Callback) { + snprintf(Code_Line, 255, "%-7s Z, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(stz2_Callback) { + snprintf(Code_Line, 255, "%-7s Z+, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(stz3_Callback) { + snprintf(Code_Line, 255, "%-7s -Z, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(stz4_Callback) { + snprintf(Code_Line, 255, "%-7s Z+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); +} + +CALLBACK(sts_Callback) { + /* The AVR instruction set 11/2005 defines operation as: "(k) <- Rr", however "(k) <- Rd" seems to be right */ + const char *MemAddress; + MemAddress = Tagfile_Resolve_Mem_Address(Rk); + snprintf(Code_Line, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); + if (MemAddress) { + snprintf(Comment_Line, 255, "%s", MemAddress); + } +} + +CALLBACK(sub_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(subi_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(swap_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(wdr_Callback) { + Operation_Simple(MNemonic_Int); +} + diff --git a/src/Callbacks_Assembly.h b/src/Callbacks_Assembly.h new file mode 100644 index 00000000..3bca9c1d --- /dev/null +++ b/src/Callbacks_Assembly.h @@ -0,0 +1,173 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, struct Options *New_Options); +void Operation_Simple(int MNemonic_Int); +void Operation_Rd(int MNemonic_Int); +void Operation_Rd16(int MNemonic_Int); +void Operation_Rd_Rr(int MNemonic_Int); +void Operation_Rd16_Rr16(int MNemonic_Int); +void Operation_Rd16_K(int MNemonic_Int); +void Operation_Rd_K(int MNemonic_Int); +void Operation_RdW_K(int MNemonic_Int); +void Operation_RdW_RrW(int MNemonic_Int); +void Operation_s_k(int MNemonic_Int, int Position); +void Operation_r_b(int MNemonic_Int); +void Operation_Rd_b(int MNemonic_Int); +void Operation_A_b(int MNemonic_Int); +void Operation_s(int MNemonic_Int); +void Operation_k(int MNemonic_Int, int Position, char *Pseudocode); +void adc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void add_Callback(char *Bitstream, int Position, int MNemonic_Int); +void adiw_Callback(char *Bitstream, int Position, int MNemonic_Int); +void and_Callback(char *Bitstream, int Position, int MNemonic_Int); +void andi_Callback(char *Bitstream, int Position, int MNemonic_Int); +void asr_Callback(char *Bitstream, int Position, int MNemonic_Int); +void bclr_Callback(char *Bitstream, int Position, int MNemonic_Int); +void bld_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brbc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brbs_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brcc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brcs_Callback(char *Bitstream, int Position, int MNemonic_Int); +void break_Callback(char *Bitstream, int Position, int MNemonic_Int); +void breq_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brge_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brhc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brhs_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brid_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brie_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brlo_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brlt_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brmi_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brne_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brpl_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brsh_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brtc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brts_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brvc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void brvs_Callback(char *Bitstream, int Position, int MNemonic_Int); +void bset_Callback(char *Bitstream, int Position, int MNemonic_Int); +void bst_Callback(char *Bitstream, int Position, int MNemonic_Int); +void call_Callback(char *Bitstream, int Position, int MNemonic_Int); +void cbi_Callback(char *Bitstream, int Position, int MNemonic_Int); +void clc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void clh_Callback(char *Bitstream, int Position, int MNemonic_Int); +void cli_Callback(char *Bitstream, int Position, int MNemonic_Int); +void cln_Callback(char *Bitstream, int Position, int MNemonic_Int); +void cls_Callback(char *Bitstream, int Position, int MNemonic_Int); +void clt_Callback(char *Bitstream, int Position, int MNemonic_Int); +void clv_Callback(char *Bitstream, int Position, int MNemonic_Int); +void clz_Callback(char *Bitstream, int Position, int MNemonic_Int); +void com_Callback(char *Bitstream, int Position, int MNemonic_Int); +void cp_Callback(char *Bitstream, int Position, int MNemonic_Int); +void cpc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void cpi_Callback(char *Bitstream, int Position, int MNemonic_Int); +void cpse_Callback(char *Bitstream, int Position, int MNemonic_Int); +void dec_Callback(char *Bitstream, int Position, int MNemonic_Int); +void eicall_Callback(char *Bitstream, int Position, int MNemonic_Int); +void eijmp_Callback(char *Bitstream, int Position, int MNemonic_Int); +void elpm1_Callback(char *Bitstream, int Position, int MNemonic_Int); +void elpm2_Callback(char *Bitstream, int Position, int MNemonic_Int); +void elpm3_Callback(char *Bitstream, int Position, int MNemonic_Int); +void eor_Callback(char *Bitstream, int Position, int MNemonic_Int); +void fmul_Callback(char *Bitstream, int Position, int MNemonic_Int); +void fmuls_Callback(char *Bitstream, int Position, int MNemonic_Int); +void fmulsu_Callback(char *Bitstream, int Position, int MNemonic_Int); +void icall_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ijmp_Callback(char *Bitstream, int Position, int MNemonic_Int); +void in_Callback(char *Bitstream, int Position, int MNemonic_Int); +void inc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void jmp_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ld1_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ld2_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ld3_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldy1_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldy2_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldy3_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldy4_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldz1_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldz2_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldz3_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldz4_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ldi_Callback(char *Bitstream, int Position, int MNemonic_Int); +void lds_Callback(char *Bitstream, int Position, int MNemonic_Int); +void lpm1_Callback(char *Bitstream, int Position, int MNemonic_Int); +void lpm2_Callback(char *Bitstream, int Position, int MNemonic_Int); +void lpm3_Callback(char *Bitstream, int Position, int MNemonic_Int); +void lsr_Callback(char *Bitstream, int Position, int MNemonic_Int); +void mov_Callback(char *Bitstream, int Position, int MNemonic_Int); +void movw_Callback(char *Bitstream, int Position, int MNemonic_Int); +void mul_Callback(char *Bitstream, int Position, int MNemonic_Int); +void muls_Callback(char *Bitstream, int Position, int MNemonic_Int); +void mulsu_Callback(char *Bitstream, int Position, int MNemonic_Int); +void neg_Callback(char *Bitstream, int Position, int MNemonic_Int); +void nop_Callback(char *Bitstream, int Position, int MNemonic_Int); +void or_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ori_Callback(char *Bitstream, int Position, int MNemonic_Int); +void out_Callback(char *Bitstream, int Position, int MNemonic_Int); +void pop_Callback(char *Bitstream, int Position, int MNemonic_Int); +void push_Callback(char *Bitstream, int Position, int MNemonic_Int); +void rcall_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ret_Callback(char *Bitstream, int Position, int MNemonic_Int); +void reti_Callback(char *Bitstream, int Position, int MNemonic_Int); +void rjmp_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ror_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbci_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbi_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbic_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbis_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbiw_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbr_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbrc_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sbrs_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sec_Callback(char *Bitstream, int Position, int MNemonic_Int); +void seh_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sei_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sen_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ser_Callback(char *Bitstream, int Position, int MNemonic_Int); +void ses_Callback(char *Bitstream, int Position, int MNemonic_Int); +void set_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sev_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sez_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sleep_Callback(char *Bitstream, int Position, int MNemonic_Int); +void spm_Callback(char *Bitstream, int Position, int MNemonic_Int); +void st1_Callback(char *Bitstream, int Position, int MNemonic_Int); +void st2_Callback(char *Bitstream, int Position, int MNemonic_Int); +void st3_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sty1_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sty2_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sty3_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sty4_Callback(char *Bitstream, int Position, int MNemonic_Int); +void stz1_Callback(char *Bitstream, int Position, int MNemonic_Int); +void stz2_Callback(char *Bitstream, int Position, int MNemonic_Int); +void stz3_Callback(char *Bitstream, int Position, int MNemonic_Int); +void stz4_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sts_Callback(char *Bitstream, int Position, int MNemonic_Int); +void sub_Callback(char *Bitstream, int Position, int MNemonic_Int); +void subi_Callback(char *Bitstream, int Position, int MNemonic_Int); +void swap_Callback(char *Bitstream, int Position, int MNemonic_Int); +void wdr_Callback(char *Bitstream, int Position, int MNemonic_Int); diff --git a/src/Callbacks_PseudoCode.c b/src/Callbacks_PseudoCode.c new file mode 100644 index 00000000..a81a4c43 --- /dev/null +++ b/src/Callbacks_PseudoCode.c @@ -0,0 +1,660 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include + +#include "MNemonics.h" +#include "Globals.h" +#include "Callbacks_PseudoCode.h" +#include "JumpCall.h" +#include "IORegisters.h" +#include "Functions.h" +#include "Tagfile.h" + +static char *Code_Line; +static char *Comment_Line; +static char *After_Code_Line; +static int *Registers; +static struct Options *Options; + +void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, struct Options *New_Options) { + Code_Line = New_Code_Line; + Comment_Line = New_Comment_Line; + After_Code_Line = New_After_Code_Line; + Registers = New_Registers; + Options = New_Options; +} + +void PC_Operation_Simple(int MNemonic_Int) { + snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); +} + +void PC_Operation_Rd(int MNemonic_Int) { + switch (MNemonic_Int) { + case OPCODE_lsl: + snprintf(Code_Line, 255, "r%d <<= 1;", Rd); + snprintf(Comment_Line, 255, "_BV(0) = 0 (logical shift)"); + break; + case OPCODE_lsr: + snprintf(Code_Line, 255, "r%d >>= 1;", Rd); + snprintf(Comment_Line, 255, "_BV(7) = 0, Carry = _BV(0) (logical shift)"); + break; + case OPCODE_ror: + snprintf(Code_Line, 255, "r%d >>= 1;", Rd); + snprintf(Comment_Line, 255, "_BV(7) = Carry, Carry = _BV(0) (rotate right)"); + break; + case OPCODE_asr: +/* snprintf(Code_Line, 255, "r%d >>= 1;", Rd);*/ +/* snprintf(Comment_Line, 255, "_BV(7) = Sign (Arithmetic Shift)");*/ + snprintf(Code_Line, 255, "r%d /= 2;", Rd); + snprintf(Comment_Line, 255, "arithmetic shift right"); + break; + case OPCODE_swap: + snprintf(Code_Line, 255, "r%d = ((r%d & 0xf0) >> 4) | ((r%d & 0x0f) << 4);", Rd, Rd, Rd); + snprintf(Comment_Line, 255, "swap nibbles"); + break; + case OPCODE_clr: + snprintf(Code_Line, 255, "r%d = 0x00;", Rd); + snprintf(Comment_Line, 255, "0"); + break; + default: + snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); + } +} + +void PC_Operation_Rd16(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); +} + +void PC_Operation_Rd_Rr(int MNemonic_Int) { + switch (MNemonic_Int) { + case OPCODE_add: + if (Rd != Rr) { + snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "No carry"); + } else { + snprintf(Code_Line, 255, "r%d *= 2;", Rd); + } + break; + case OPCODE_adc: + snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "With carry"); + break; + case OPCODE_sub: + snprintf(Code_Line, 255, "r%d -= r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "No carry"); + break; + case OPCODE_sbc: + snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "With carry"); + break; + case OPCODE_mul: + snprintf(Code_Line, 255, "r1:r0 = r%d * r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "Unsigned"); + break; + case OPCODE_mov: + snprintf(Code_Line, 255, "r%d = r%d;", Rd, Rr); + break; + case OPCODE_eor: + snprintf(Code_Line, 255, "r%d ^= r%d;", Rd, Rr); + break; + case OPCODE_and: + if (Rd != Rr) { + snprintf(Code_Line, 255, "r%d &= r%d;", Rd, Rr); + } else { + snprintf(Code_Line, 255, "(r%d == 0) || (r%d < 0);", Rd, Rd); + snprintf(Comment_Line, 255, "test r%d", Rd); + } + break; + case OPCODE_or: + snprintf(Code_Line, 255, "r%d |= r%d;", Rd, Rr); + break; + case OPCODE_cp: + snprintf(Code_Line, 255, "cmp(r%d, r%d);", Rd, Rr); + break; + case OPCODE_cpc: + snprintf(Code_Line, 255, "cmp(r%d, r%d);", Rd, Rr); + snprintf(Comment_Line, 255, "with carry"); + break; + case OPCODE_cpse: + snprintf(Code_Line, 255, "skipif (r%d == r%d)", Rd, Rr); + break; + default: + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); + } +} + +void PC_Operation_Rd16_Rr16(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); +} + +void PC_Operation_Rd16_K(int MNemonic_Int) { + switch (MNemonic_Int) { + case OPCODE_andi: + snprintf(Code_Line, 255, "r%d &= %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x", RK); + break; + case OPCODE_subi: + snprintf(Code_Line, 255, "r%d -= %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x, no carry", RK); + break; + case OPCODE_sbci: + snprintf(Code_Line, 255, "r%d -= %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x, with carry", RK); + break; + case OPCODE_sbr: + case OPCODE_ori: + snprintf(Code_Line, 255, "r%d |= %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x", RK); + break; + default: + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); + snprintf(Comment_Line, 255, "%d", RK); + } +} + +void PC_Operation_Rd_K(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(Comment_Line, 255, "%d", RK); +} + +void PC_Operation_RdW_K(int MNemonic_Int) { + if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd+1, Rd, RK); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + } + snprintf(Comment_Line, 255, "%d", RK); +} + +void PC_Operation_RdW_RrW(int MNemonic_Int) { + if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2*Rd)+1, 2*Rd, (2*Rr)+1, 2*Rr); + } else { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2*Rd, 2*Rr); + } +} + +void PC_Operation_s_k(int MNemonic_Int, int Position) { + int Bits, Offset; + Bits = Rs; + Offset = (2 * Rk); + if (Offset > 128) Offset -= 256; + + int Target = FixTargetAddress(Position + Offset + 2); + Register_JumpCall(Position, Target, MNemonic_Int, 0); + if (Options->Process_Labels == 0) { + if (Offset>0) { + snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); + } else { + snprintf(Code_Line, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); + } + snprintf(Comment_Line, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); + } else { + snprintf(Code_Line, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); + } +} + +void PC_Operation_r_b(int MNemonic_Int) { + int Register, Bit; + Register = Rr; + Bit = Rb; + snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void PC_Operation_Rd_b(int MNemonic_Int) { + int Register, Bit; + Register = Rd; + Bit = Rb; + snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void PC_Operation_A_b(int MNemonic_Int) { + int Register, Bit; + const char *Register_Name; + char Register_Value[5]; + Register = RA; + Bit = Rb; + Register_Name = Resolve_IO_Register(Register); + if (Register_Name == NULL) { + snprintf(Register_Value, sizeof(Register_Value), "0x%02x", Register); + Register_Name = Register_Value; + } + switch (MNemonic_Int) { + case OPCODE_cbi: + snprintf(Code_Line, 255, "IO[%s] &= ~(_BV(%d));", Register_Name, Bit); + break; + case OPCODE_sbi: + snprintf(Code_Line, 255, "IO[%s] |= _BV(%d);", Register_Name, Bit); + break; + case OPCODE_sbis: + snprintf(Code_Line, 255, "skipif (IO[%s] & _BV(%d))", Register_Name, Bit); + break; + case OPCODE_sbic: + snprintf(Code_Line, 255, "skipif (!(IO[%s] & _BV(%d)))",Register_Name, Bit); + break; + default: + snprintf(Code_Line, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); + } + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void PC_Operation_s(int MNemonic_Int) { + int Bit; + Bit = Rs; + snprintf(Code_Line, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { + int Offset; + Offset = (2 * Rk); + if (Offset > 128) Offset -= 256; + + int Target = FixTargetAddress(Position + Offset + 2); + Register_JumpCall(Position, Target, MNemonic_Int, 0); + if (Options->Process_Labels == 0) { + if (Offset > 0) { + snprintf(Code_Line, 255, "if (%s) goto .+%d;", Pseudocode, Offset); + } else { + snprintf(Code_Line, 255, "if (%s) goto .%d", Pseudocode, Offset); + } + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + snprintf(Code_Line, 255, "if (%s) goto %s;", Pseudocode, Get_Label_Name(Target, NULL)); + } +} + +/************* Now to the callback functions *************/ + +CALLBACK(adc_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(add_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(sub_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(sbc_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(mov_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(brcc_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "!Carry"); +} + +CALLBACK(brcs_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Carry"); +} + +CALLBACK(breq_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 == c2"); +} + +CALLBACK(brge_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 (signed)>= c2"); +} + +CALLBACK(brhc_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "!HalfCarry"); +} + +CALLBACK(brhs_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "HalfCarry"); +} + +CALLBACK(brid_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Global_Interrupts_Disabled()"); +} + +CALLBACK(brie_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Global_Interrupts_Enabled()"); +} + +CALLBACK(brlo_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 (unsigned)< c2"); +} + +CALLBACK(brlt_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 (signed)< c2"); +} + +CALLBACK(brmi_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "< 0"); +} + +CALLBACK(brne_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 != c2"); +} + +CALLBACK(brpl_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "> 0"); +} + +CALLBACK(brsh_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 (unsigned)>= c2"); +} + +CALLBACK(brtc_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "T == 0"); +} + +CALLBACK(brts_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "T == 1"); +} + +CALLBACK(brvc_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Overflow == 0"); +} + +CALLBACK(brvs_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Overflow == 1"); +} + +CALLBACK(out_Callback_PC) { + int Register_Number; + const char *Register_Name; + Register_Number = RA; + Register_Name = Resolve_IO_Register(Register_Number); + if (Register_Name) { + snprintf(Code_Line, 255, "IO[%s] = r%d;", Register_Name, Rr); + } else { + snprintf(Code_Line, 255, "IO[0x%02x] = r%d;", Register_Number, Rr); + snprintf(Comment_Line, 255, "%d", RA); + } +} + +CALLBACK(in_Callback_PC) { + int Register_Number; + const char *Register_Name; + Register_Number = RA; + Register_Name = Resolve_IO_Register(Register_Number); + if (Register_Name) { + snprintf(Code_Line, 255, "r%d = IO[%s];", Rd, Register_Name); + } else { + snprintf(Code_Line, 255, "r%d = IO[0x%02x];", Rd, Register_Number); + snprintf(Comment_Line, 255, "%d", RA); + } +} + +CALLBACK(cli_Callback_PC) { + snprintf(Code_Line, 255, "Disable_Interrupts();"); +} + +CALLBACK(sei_Callback_PC) { + snprintf(Code_Line, 255, "Enable_Interrupts();"); +} + +CALLBACK(ret_Callback_PC) { + snprintf(Code_Line, 255, "return;"); + snprintf(After_Code_Line, 255, "\n"); +} + +CALLBACK(reti_Callback_PC) { + snprintf(Code_Line, 255, "ireturn;"); + snprintf(After_Code_Line, 255, "\n"); +} + +CALLBACK(andi_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(subi_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(sbci_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(sbr_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(ori_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(ldi_Callback_PC) { + snprintf(Code_Line, 255, "r%d = %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x", RK); +} + +CALLBACK(lds_Callback_PC) { + const char *MemAddress; + MemAddress = Tagfile_Resolve_Mem_Address(Rk); + if (!MemAddress) { + snprintf(Code_Line, 255, "r%d = Memory[0x%04x];", Rd, Rk); + snprintf(Comment_Line, 255, "%d", Rk); + } else { + snprintf(Code_Line, 255, "r%d = %s;", Rd, MemAddress); + snprintf(Comment_Line, 255, "0x%04x", Rk); + } +} + +CALLBACK(sts_Callback_PC) { + const char *MemAddress; + MemAddress = Tagfile_Resolve_Mem_Address(Rk); + if (!MemAddress) { + snprintf(Code_Line, 255, "Memory[0x%04x] = r%d;", Rk, Rd); + snprintf(Comment_Line, 255, "%d", Rk); + } else { + snprintf(Code_Line, 255, "%s = r%d;", MemAddress, Rd); + snprintf(Comment_Line, 255, "0x%04x", Rk); + } +} + +CALLBACK(call_Callback_PC) { + int Pos; + Pos = FixTargetAddress(2 * Rk); + Register_JumpCall(Position, Pos, MNemonic_Int, 1); + if (Options->Process_Labels == 0) { + snprintf(Code_Line, 255, "0x%02x();", Pos); + } else { + char *LabelName; + char *LabelComment = NULL; + LabelName = Get_Label_Name(Pos, &LabelComment); + snprintf(Code_Line, 255, "%s();", LabelName); + if (LabelComment != NULL) { + snprintf(Comment_Line, 255, "%s", LabelComment); + } + } +} + +CALLBACK(rcall_Callback_PC) { + int Offset; + Offset = 2 * (Rk); + if (Offset > 4096) Offset -= 8192; + + int Target = FixTargetAddress(Position + Offset + 2); + Register_JumpCall(Position, Target, MNemonic_Int, 1); + if (!Options->Process_Labels) { + snprintf(Comment_Line, 255, "0x%02x();", Target); + } else { + char *LabelName; + char *LabelComment = NULL; + LabelName = Get_Label_Name(Target, &LabelComment); + snprintf(Code_Line, 255, "%s();", LabelName); + if (LabelComment != NULL) { + snprintf(Comment_Line, 255, "%s", LabelComment); + } + } +} + +CALLBACK(ror_Callback_PC) { + PC_Operation_Rd(MNemonic_Int); +} + +CALLBACK(lsr_Callback_PC) { + PC_Operation_Rd(MNemonic_Int); +} + +CALLBACK(swap_Callback_PC) { + PC_Operation_Rd(MNemonic_Int); +} + +CALLBACK(eor_Callback_PC) { + if (Rd == Rr) { + PC_Operation_Rd(OPCODE_clr); + } else { + PC_Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(jmp_Callback_PC) { + int Pos; + Pos = FixTargetAddress(2 * Rk); + if (Options->Process_Labels == 0) { + snprintf(Code_Line, 255, "goto 0x%02x;", Pos); + } else { + snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Pos, NULL)); + } + Register_JumpCall(Position, Pos, MNemonic_Int, 0); +} + +CALLBACK(rjmp_Callback_PC) { + int Offset; + Offset = 2 * (Rk); + if (Offset > 4096) Offset -= 8192; + + int Target = FixTargetAddress(Position + Offset + 2); + Register_JumpCall(Position, Target, MNemonic_Int, 0); + + if (Options->Process_Labels == 0) { + if (Offset>0) { + snprintf(Code_Line, 255, "goto .+%d;", Offset); + } else { + snprintf(Code_Line, 255, "goto .%d", Offset); + } + if (Target >= 0) { + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + snprintf(Comment_Line, 255, "-0x%02x - Illegal jump position -- specify flash size!", -(Target)); + } + } else { + snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Position + Offset + 2, NULL)); + } +} + +CALLBACK(cpi_Callback_PC) { + if (RK == 0) { + snprintf(Code_Line, 255, "cmp(r%d, 0);", Rd + 16); + } else { + snprintf(Code_Line, 255, "cmp(r%d, 0x%02x);", Rd + 16, RK); + snprintf(Comment_Line, 255, "%d", RK); + } +} + +CALLBACK(asr_Callback_PC) { + PC_Operation_Rd(MNemonic_Int); +} + +CALLBACK(dec_Callback_PC) { + snprintf(Code_Line, 255, "r%d--;", Rd); +} + +CALLBACK(inc_Callback_PC) { + snprintf(Code_Line, 255, "r%d++;", Rd); +} + +CALLBACK(cp_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(cpc_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(cpse_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(and_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(or_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(mul_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(sbi_Callback_PC) { + PC_Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbic_Callback_PC) { + PC_Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbis_Callback_PC) { + PC_Operation_A_b(MNemonic_Int); +} + +CALLBACK(cbi_Callback_PC) { + PC_Operation_A_b(MNemonic_Int); +} + +CALLBACK(ser_Callback_PC) { + snprintf(Code_Line, 255, "r%d = 0xff;", Rd + 16); + snprintf(Comment_Line, 255, "255"); +} + +CALLBACK(adiw_Callback_PC) { + if (RK != 1) { + snprintf(Code_Line, 255, "[r%d:r%d] += 0x%02x;", 2 * Rd + 25, 2 * Rd + 24, RK); + snprintf(Comment_Line, 255, "%d", RK); + } else { + snprintf(Code_Line, 255, "[r%d:r%d]++;", 2 * Rd + 25, 2 * Rd + 24); + } +} + +CALLBACK(movw_Callback_PC) { + snprintf(Code_Line, 255, "[r%d:r%d] = [r%d:r%d];", (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); +} + +CALLBACK(lpm1_Callback_PC) { + snprintf(Code_Line, 255, "r0 = Flash[r30:r31];"); +} + +CALLBACK(st2_Callback_PC) { + snprintf(Code_Line, 255, "Flash[[r26:r27]++] = r%d;", Rr); +} + diff --git a/src/Callbacks_PseudoCode.h b/src/Callbacks_PseudoCode.h new file mode 100644 index 00000000..13d9f2c6 --- /dev/null +++ b/src/Callbacks_PseudoCode.h @@ -0,0 +1,106 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, struct Options *New_Options); +void PC_Operation_Simple(int MNemonic_Int); +void PC_Operation_Rd(int MNemonic_Int); +void PC_Operation_Rd16(int MNemonic_Int); +void PC_Operation_Rd_Rr(int MNemonic_Int); +void PC_Operation_Rd16_Rr16(int MNemonic_Int); +void PC_Operation_Rd16_K(int MNemonic_Int); +void PC_Operation_Rd_K(int MNemonic_Int); +void PC_Operation_RdW_K(int MNemonic_Int); +void PC_Operation_RdW_RrW(int MNemonic_Int); +void PC_Operation_s_k(int MNemonic_Int, int Position); +void PC_Operation_r_b(int MNemonic_Int); +void PC_Operation_Rd_b(int MNemonic_Int); +void PC_Operation_A_b(int MNemonic_Int); +void PC_Operation_s(int MNemonic_Int); +void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode); +void adc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void add_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sub_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sbc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void mov_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brcc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brcs_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void breq_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brge_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brhc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brhs_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brid_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brie_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brlo_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brlt_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brmi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brne_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brpl_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brsh_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brtc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brts_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brvc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void brvs_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void out_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void in_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void cli_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sei_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void ret_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void reti_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void andi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void subi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sbci_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sbr_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void ori_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void ldi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void lds_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sts_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void call_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void rcall_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void ror_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void lsr_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void swap_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void eor_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void jmp_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void rjmp_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void cpi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void asr_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void dec_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void inc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void cp_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void cpc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void cpse_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void and_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void or_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void mul_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sbi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sbic_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void sbis_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void cbi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void ser_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void adiw_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void movw_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void lpm1_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void st2_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); diff --git a/src/Functions.h b/src/Functions.h new file mode 100644 index 00000000..a7aa1008 --- /dev/null +++ b/src/Functions.h @@ -0,0 +1,35 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#ifdef DOS_BASED_OS + #define snprintf _snprintf +#endif + +#ifdef DESPERATE_SPRINTF_FALLBACK + #warning "Your C library does not support snprintf. Please upgrade! Fallback to sprintf used." + #define snprintf(dest, len, str...) sprintf(dest, str) +#endif + diff --git a/src/Globals.h b/src/Globals.h new file mode 100644 index 00000000..e5d39d48 --- /dev/null +++ b/src/Globals.h @@ -0,0 +1,211 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#define Rd (Registers[(int)'d']) +#define Rr (Registers[(int)'r']) +#define Rk (Registers[(int)'k']) +#define RK (Registers[(int)'K']) +#define Rs (Registers[(int)'s']) +#define RA (Registers[(int)'A']) +#define Rb (Registers[(int)'b']) +#define Rq (Registers[(int)'q']) + +#define CALLBACK(name) void name(char *Bitstream, int Position, int MNemonic_Int) + +#define CODESTYLE_AVR_INSTRUCTION_SET 0 +#define CODESTYLE_AVRGCC 1 + +struct Opcode { + char *Opcode_String; + void (*Callback)(char*, int, int); + int MNemonic; +}; + +struct JumpCall { + int From; + int To; + int Type; + unsigned int LabelNumber; + unsigned char FunctionCall; +}; + +struct Options { + char Show_Addresses; + char Show_Opcodes; + char Show_Comments; + char Show_Cycles; + char Show_PseudoCode; + char Filename[256]; + char MCU[8]; + char Tagfile[256]; + char CodeStyle; + char Process_Labels; + char Pass; + int FlashSize; +}; + +struct IO_Register { + int Address; + char Name[16]; + unsigned char Used; +}; + +#define OPCODE_adc 0 +#define OPCODE_add 1 +#define OPCODE_adiw 2 +#define OPCODE_and 3 +#define OPCODE_andi 4 +#define OPCODE_asr 5 +#define OPCODE_bclr 6 +#define OPCODE_bld 7 +#define OPCODE_brbc 8 +#define OPCODE_brbs 9 +#define OPCODE_brcc 10 +#define OPCODE_brcs 11 +#define OPCODE_break 12 +#define OPCODE_breq 13 +#define OPCODE_brge 14 +#define OPCODE_brhc 15 +#define OPCODE_brhs 16 +#define OPCODE_brid 17 +#define OPCODE_brie 18 +#define OPCODE_brlo 19 +#define OPCODE_brlt 20 +#define OPCODE_brmi 21 +#define OPCODE_brne 22 +#define OPCODE_brpl 23 +#define OPCODE_brsh 24 +#define OPCODE_brtc 25 +#define OPCODE_brts 26 +#define OPCODE_brvc 27 +#define OPCODE_brvs 28 +#define OPCODE_bset 29 +#define OPCODE_bst 30 +#define OPCODE_call 31 +#define OPCODE_cbi 32 +#define OPCODE_cbr 33 +#define OPCODE_clc 34 +#define OPCODE_clh 35 +#define OPCODE_cli 36 +#define OPCODE_cln 37 +#define OPCODE_clr 38 +#define OPCODE_cls 39 +#define OPCODE_clt 40 +#define OPCODE_clv 41 +#define OPCODE_clz 42 +#define OPCODE_com 43 +#define OPCODE_cp 44 +#define OPCODE_cpc 45 +#define OPCODE_cpi 46 +#define OPCODE_cpse 47 +#define OPCODE_dec 48 +#define OPCODE_eicall 49 +#define OPCODE_eijmp 50 +#define OPCODE_elpm_1 51 +#define OPCODE_elpm_2 52 +#define OPCODE_elpm_3 53 +#define OPCODE_eor 54 +#define OPCODE_fmul 55 +#define OPCODE_fmuls 56 +#define OPCODE_fmulsu 57 +#define OPCODE_icall 58 +#define OPCODE_ijmp 59 +#define OPCODE_in 60 +#define OPCODE_inc 61 +#define OPCODE_jmp 62 +#define OPCODE_ld_1 63 +#define OPCODE_ld_2 64 +#define OPCODE_ld_3 65 +#define OPCODE_ld_4 66 +#define OPCODE_ld_5 67 +#define OPCODE_ld_6 68 +#define OPCODE_ldd_1 69 +#define OPCODE_ld_7 70 +#define OPCODE_ld_8 71 +#define OPCODE_ld_9 72 +#define OPCODE_ldd_2 73 +#define OPCODE_ldi 74 +#define OPCODE_lds 75 +#define OPCODE_lpm_1 76 +#define OPCODE_lpm_2 77 +#define OPCODE_lpm_3 78 +#define OPCODE_lsl 79 +#define OPCODE_lsr 80 +#define OPCODE_mov 81 +#define OPCODE_movw 82 +#define OPCODE_mul 83 +#define OPCODE_muls 84 +#define OPCODE_mulsu 85 +#define OPCODE_neg 86 +#define OPCODE_nop 87 +#define OPCODE_or 88 +#define OPCODE_ori 89 +#define OPCODE_out 90 +#define OPCODE_pop 91 +#define OPCODE_push 92 +#define OPCODE_rcall 93 +#define OPCODE_ret 94 +#define OPCODE_reti 95 +#define OPCODE_rjmp 96 +#define OPCODE_rol 97 +#define OPCODE_ror 98 +#define OPCODE_sbc 99 +#define OPCODE_sbci 100 +#define OPCODE_sbi 101 +#define OPCODE_sbic 102 +#define OPCODE_sbis 103 +#define OPCODE_sbiw 104 +#define OPCODE_sbr 105 +#define OPCODE_sbrc 106 +#define OPCODE_sbrs 107 +#define OPCODE_sec 108 +#define OPCODE_seh 109 +#define OPCODE_sei 110 +#define OPCODE_sen 111 +#define OPCODE_ser 112 +#define OPCODE_ses 113 +#define OPCODE_set 114 +#define OPCODE_sev 115 +#define OPCODE_sez 116 +#define OPCODE_sleep 117 +#define OPCODE_spm 118 +#define OPCODE_st_1 119 +#define OPCODE_st_2 120 +#define OPCODE_st_3 121 +#define OPCODE_st_4 122 +#define OPCODE_st_5 123 +#define OPCODE_st_6 124 +#define OPCODE_std_1 125 +#define OPCODE_st_7 126 +#define OPCODE_st_8 127 +#define OPCODE_st_9 128 +#define OPCODE_std_2 129 +#define OPCODE_sts 130 +#define OPCODE_sub 131 +#define OPCODE_subi 132 +#define OPCODE_swap 133 +#define OPCODE_tst 134 +#define OPCODE_wdr 135 diff --git a/src/IORegisters.c b/src/IORegisters.c new file mode 100644 index 00000000..6c2810e6 --- /dev/null +++ b/src/IORegisters.c @@ -0,0 +1,114 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include + +#include "Globals.h" + +extern struct Options Options; + +static struct IO_Register *KnownIORegisters = NULL; +static unsigned int KnownIORegistersCount = 0; + +unsigned int ReadIORegisterFile() { + FILE *f; + f = fopen("/etc/avrdisas.conf", "r"); + if (!f) { + f = fopen("avrdisas.conf", "r"); + } + if (!f) { + fprintf(stderr, "Could not read any configuration file.\n"); + return 0; + } + + + { + char Buffer[256]; + int CurrentMCU = 0; + while (fgets(Buffer, sizeof(Buffer), f)) { + char *Token; + struct IO_Register TempRegister; + + if (!(Token = strtok(Buffer, "\t\n"))) continue; + if (!strcmp(Token, "Register")) { + if (!CurrentMCU) continue; + if (!(Token = strtok(NULL, "\t\n"))) continue; + if (strlen(Token) == 0) continue; + if (Token[1] == 'x') { + TempRegister.Address = strtol(Token + 2, NULL, 16); + } else { + TempRegister.Address = atoi(Token); + } + if (!(Token = strtok(NULL, "\t\n"))) continue; + strncpy(TempRegister.Name, Token, 16); + TempRegister.Used = 0; + + KnownIORegisters = (struct IO_Register*)realloc(KnownIORegisters, sizeof(struct IO_Register) * (KnownIORegistersCount + 1)); + KnownIORegisters[KnownIORegistersCount] = TempRegister; + KnownIORegistersCount++; + } else if (!strcmp(Token, "Unit")) { + if (!(Token = strtok(NULL, "\t\n"))) continue; + CurrentMCU = (!strcmp(Token, Options.MCU)) || (!strcmp(Token, "Global")); + } + } + } + + fclose(f); + return KnownIORegistersCount; +} + +const char* Resolve_IO_Register(int Number) { + int Resolved; + unsigned int i; + + if (!strcmp(Options.MCU, "None")) return NULL; + + Resolved = -1; + for (i = 0; i < KnownIORegistersCount; i++) { + if (KnownIORegisters[i].Address == Number) { + Resolved = i; + break; + } + } + + if (Resolved != -1) { + KnownIORegisters[Resolved].Used = 1; + return KnownIORegisters[Resolved].Name; + } else { + return NULL; + } +} + +void Emit_Used_IO_Registers() { + unsigned int i; + if (Options.Show_PseudoCode) return; + for (i = 0; i < KnownIORegistersCount; i++) { + if (KnownIORegisters[i].Used) printf(".equ %s, 0x%x\n", KnownIORegisters[i].Name, KnownIORegisters[i].Address); + } +} + diff --git a/src/IORegisters.h b/src/IORegisters.h new file mode 100644 index 00000000..cc367f7c --- /dev/null +++ b/src/IORegisters.h @@ -0,0 +1,29 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +unsigned int ReadIORegisterFile(); +const char* Resolve_IO_Register(int Number); +void Emit_Used_IO_Registers(); diff --git a/src/JumpCall.c b/src/JumpCall.c new file mode 100644 index 00000000..b59dd3ca --- /dev/null +++ b/src/JumpCall.c @@ -0,0 +1,180 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include + +#include "Globals.h" +#include "MNemonics.h" +#include "Tagfile.h" +#include "JumpCall.h" + +extern struct Options Options; +static int JumpCall_Count; +static struct JumpCall *JumpCalls; + +void Display_JumpCalls() { + int i; + printf("%d jumps/calls found:\n", JumpCall_Count); + for (i = 0; i < JumpCall_Count; i++) { + printf("%3d: 0x%-4x -> 0x%-4x %s (%d)\n", i, (unsigned int)JumpCalls[i].From, (unsigned int)JumpCalls[i].To, MNemonic[JumpCalls[i].Type], JumpCalls[i].FunctionCall); + } +} + +int FixTargetAddress(int Address) { + if (Options.FlashSize) { + Address %= Options.FlashSize; + if (Address < 0) { + Address += Options.FlashSize; + } + } + return Address; +} + +void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { + if ((Options.Process_Labels == 1) && (Options.Pass == 1)) { + JumpCall_Count++; + JumpCalls = realloc(JumpCalls, sizeof(struct JumpCall) * (JumpCall_Count)); + JumpCalls[JumpCall_Count - 1].From = From; + JumpCalls[JumpCall_Count - 1].To = To; + JumpCalls[JumpCall_Count - 1].Type = Type; + JumpCalls[JumpCall_Count - 1].LabelNumber = 0; + JumpCalls[JumpCall_Count - 1].FunctionCall = FunctionCall; + } +} + +int JC_Comparison(const void *Element1, const void *Element2) { + struct JumpCall *JC1, *JC2; + JC1 = (struct JumpCall*)Element1; + JC2 = (struct JumpCall*)Element2; + if ((JC1->To) > (JC2->To)) return 1; + else if ((JC1->To) == (JC2->To)) return 0; + return -1; +} + +void Sort_JumpCalls() { + qsort(JumpCalls, JumpCall_Count, sizeof(struct JumpCall), JC_Comparison); +} + +void Correct_Label_Types(void) { + int i, j; + int LastIdx = 0; + int LastDest = JumpCalls[0].To; + char CurType = JumpCalls[0].FunctionCall; + + for (i = 1; i < JumpCall_Count; i++) { + if (JumpCalls[i].To != LastDest) { + for (j = LastIdx; j < i; j++) JumpCalls[j].FunctionCall = CurType; + LastIdx = i; + LastDest = JumpCalls[i].To; + CurType = 0; + } + CurType = (CurType || JumpCalls[i].FunctionCall); + } + for (j = LastIdx; j < JumpCall_Count; j++) JumpCalls[j].FunctionCall = CurType; +} + +void Enumerate_Labels(void) { + int i; + int CurrentLabelNumber = 0; + int CurrentFunctionNumber = 0; + int Destination; + + if (JumpCall_Count < 2) return; + + Sort_JumpCalls(); + Correct_Label_Types(); + + Destination = JumpCalls[0].To; + if (JumpCalls[0].FunctionCall) CurrentFunctionNumber++; + else CurrentLabelNumber++; + for (i = 0; i < JumpCall_Count; i++) { + if (Destination != JumpCalls[i].To) { + if (JumpCalls[i].FunctionCall) CurrentFunctionNumber++; + else CurrentLabelNumber++; + Destination = JumpCalls[i].To; + } + if (JumpCalls[i].FunctionCall) JumpCalls[i].LabelNumber = CurrentFunctionNumber; + else JumpCalls[i].LabelNumber = CurrentLabelNumber; + } +} + +char *Get_Label_Name(int Destination, char **LabelComment) { + int i; + static char Buffer[256]; + int TagIndex; + char *TagLabel; + + TagIndex = Tagfile_FindLabelAddress(Destination); + if (TagIndex != -1) { + TagLabel = Tagfile_GetLabel(TagIndex); + snprintf(Buffer, sizeof(Buffer), "%s", TagLabel); + if (LabelComment != NULL) *LabelComment = Tagfile_GetLabelComment(TagIndex); + return Buffer; + } + + for (i = 0; i < JumpCall_Count; i++) { + if ((JumpCalls[i].To) == Destination) { + if (JumpCalls[i].FunctionCall) { + snprintf(Buffer, sizeof(Buffer), "Function%d", JumpCalls[i].LabelNumber); + } else { + snprintf(Buffer, sizeof(Buffer), "Label%d", JumpCalls[i].LabelNumber); + } + return Buffer; + } + } + + snprintf(Buffer, sizeof(Buffer), "UNKNOWN"); + return Buffer; +} + +/* Show all references which refer to "Position" as destination */ +void Print_JumpCalls(int Position) { + int i; + int Match = 0; + + for (i = 0; i < JumpCall_Count; i++) { + if ((JumpCalls[i].To) == Position) { + if (Match == 0) { + printf("\n"); + Match = 1; + } + printf("; Referenced from offset 0x%02x by %s\n", JumpCalls[i].From, MNemonic[JumpCalls[i].Type]); + } + } + if (Match == 1) { + char *LabelName; + char *LabelComment = NULL; + LabelName = Get_Label_Name(Position, &LabelComment); + if (LabelComment == NULL) { + printf("%s:\n", LabelName); + } else { + printf("%s: ; %s\n", LabelName, LabelComment); + } + } +} + diff --git a/src/JumpCall.h b/src/JumpCall.h new file mode 100644 index 00000000..57eef251 --- /dev/null +++ b/src/JumpCall.h @@ -0,0 +1,34 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +void Display_JumpCalls(); +void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall); +int JC_Comparison(const void *Element1, const void *Element2); +void Sort_JumpCalls(); +void Enumerate_Labels(); +char *Get_Label_Name(int Destination, char **LabelComment); +void Print_JumpCalls(int Position); +int FixTargetAddress(int Address); diff --git a/src/MNemonics.c b/src/MNemonics.c new file mode 100644 index 00000000..a96efb19 --- /dev/null +++ b/src/MNemonics.c @@ -0,0 +1,444 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include + +const char* MNemonic[] = { + "adc", + "add", + "adiw", + "and", + "andi", + "asr", + "bclr", + "bld", + "brbc", + "brbs", + "brcc", + "brcs", + "break", + "breq", + "brge", + "brhc", + "brhs", + "brid", + "brie", + "brlo", + "brlt", + "brmi", + "brne", + "brpl", + "brsh", + "brtc", + "brts", + "brvc", + "brvs", + "bset", + "bst", + "call", + "cbi", + "cbr", + "clc", + "clh", + "cli", + "cln", + "clr", + "cls", + "clt", + "clv", + "clz", + "com", + "cp", + "cpc", + "cpi", + "cpse", + "dec", + "eicall", + "eijmp", + "elpm", + "elpm", + "elpm", + "eor", + "fmul", + "fmuls", + "fmulsu", + "icall", + "ijmp", + "in", + "inc", + "jmp", + "ld", + "ld", + "ld", + "ld", + "ld", + "ld", + "ldd", + "ld", + "ld", + "ld", + "ldd", + "ldi", + "lds", + "lpm", + "lpm", + "lpm", + "lsl", + "lsr", + "mov", + "movw", + "mul", + "muls", + "mulsu", + "neg", + "nop", + "or", + "ori", + "out", + "pop", + "push", + "rcall", + "ret", + "reti", + "rjmp", + "rol", + "ror", + "sbc", + "sbci", + "sbi", + "sbic", + "sbis", + "sbiw", + "sbr", + "sbrc", + "sbrs", + "sec", + "seh", + "sei", + "sen", + "ser", + "ses", + "set", + "sev", + "sez", + "sleep", + "spm", + "st", + "st", + "st", + "st", + "st", + "st", + "std", + "st", + "st", + "st", + "std", + "sts", + "sub", + "subi", + "swap", + "tst", + "wdr" +}; + +const char *Cycles[] = { + "1", /* adc */ + "1", /* add */ + "2", /* adiw */ + "1", /* and */ + "1", /* andi */ + "1", /* asr */ + "1", /* bclr */ + "1", /* bld */ + "1/2", /* brbc */ + "1/2", /* brbs */ + "1/2", /* brcc */ + "1/2", /* brcs */ + "N/A", /* break */ + "1/2", /* breq */ + "1/2", /* brge */ + "1/2", /* brhc */ + "1/2", /* brhs */ + "1/2", /* brid */ + "1/2", /* brie */ + "1/2", /* brlo */ + "1/2", /* brlt */ + "1/2", /* brmi */ + "1/2", /* brne */ + "1/2", /* brpl */ + "1/2", /* brsh */ + "1/2", /* brtc */ + "1/2", /* brts */ + "1/2", /* brvc */ + "1/2", /* brvs */ + "1", /* bset */ + "1", /* bst */ + "4", /* call */ + "2", /* cbi */ + "1", /* cbr */ + "1", /* clc */ + "", /* clh */ + "1", /* cli */ + "1", /* cln */ + "1", /* clr */ + "1", /* cls */ + "1", /* clt */ + "1", /* clv */ + "1", /* clz */ + "1", /* com */ + "1", /* cp */ + "1", /* cpc */ + "1", /* cpi */ + "1-3", /* cpse */ + "1", /* dec */ + NULL, + NULL, + NULL, + NULL, + NULL, + "1", /* eor */ + "2", /* fmul */ + "2", /* fmuls */ + "2", /* fmulsu */ + "3", /* icall */ + "2", /* ijmp */ + "1", /* in */ + "1", /* inc */ + "3", /* jmp */ + "2", /* ld */ + "2", /* ld */ + "2", /* ld */ + "2", /* ld */ + "2", /* ld */ + "2", /* ld */ + "2", /* ldd */ + "2", /* ld */ + "2", /* ld */ + "2", /* ld */ + "2", /* ldd */ + "1", /* ldi */ + "2", /* lds */ + "3", /* lpm */ + "3", /* lpm */ + "3", /* lpm */ + "1", /* lsl */ + "1", /* lsr */ + "1", /* mov */ + "1", /* movw */ + "2", /* mul */ + "2", /* muls */ + "2", /* mulsu */ + "1", /* neg */ + "1", /* nop */ + "1", /* or */ + "1", /* ori */ + "1", /* out */ + "2", /* pop */ + "2", /* push */ + "3", /* rcall */ + "4", /* ret */ + "4", /* reti */ + "2", /* rjmp */ + "1", /* rol */ + "1", /* ror */ + "1", /* sbc */ + "1", /* sbci */ + "2", /* sbi */ + "1-3", /* sbic */ + "1-3", /* sbis */ + "2", /* sbiw */ + "1", /* sbr */ + "1-3", /* sbrc */ + "1-3", /* sbrs */ + "1", /* sec */ + "1", /* seh */ + "1", /* sei */ + "1", /* sen */ + "1", /* ser */ + "1", /* ses */ + "1", /* set */ + "1", /* sev */ + "1", /* sez */ + "1", /* sleep */ + "-", /* spm */ + "2", /* st */ + "2", /* st */ + "2", /* st */ + "2", /* st */ + "2", /* st */ + "2", /* st */ + "2", /* std */ + "2", /* st */ + "2", /* st */ + "2", /* st */ + "2", /* std */ + "2", /* sts */ + "1", /* sub */ + "1", /* subi */ + "1", /* swap */ + "1", /* tst */ + "1" /* wdr */ +}; + +/* +adc +add +adiw +and +andi +asr +bclr +bld +brbc +brbs +brcc +brcs +break +breq +brge +brhc +brhs +brid +brie +brlo +brlt +brmi +brne +brpl +brsh +brtc +brts +brvc +brvs +bset +bst +call +cbi +cbr +clc +clh +cli +cln +clr +cls +clt +clv +clz +com +cp +cpc +cpi +cpse +dec +eicall +eijmp +elpm +elpm +elpm +eor +fmul +fmuls +fmulsu +icall +ijmp +in +inc +jmp +ld +ld +ld +ld +ld +ld +ldd +ld +ld +ld +ldd +ldi +lds +lpm +lpm +lpm +lsl +lsr +mov +movw +mul +muls +mulsu +neg +nop +or +ori +out +pop +push +rcall +ret +reti +rjmp +rol +ror +sbc +sbci +sbi +sbic +sbis +sbiw +sbr +sbrc +sbrs +sec +seh +sei +sen +ser +ses +set +sev +sez +sleep +spm +st +st +st +st +st +st +std +st +st +st +std +sts +sub +subi +swap +tst +wdr +*/ diff --git a/src/MNemonics.h b/src/MNemonics.h new file mode 100644 index 00000000..40e37646 --- /dev/null +++ b/src/MNemonics.h @@ -0,0 +1,30 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +extern const char *MNemonic[]; +extern const char *Cycles[]; + + diff --git a/src/Options.c b/src/Options.c new file mode 100644 index 00000000..0b4f1322 --- /dev/null +++ b/src/Options.c @@ -0,0 +1,172 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include + +#include "Globals.h" +#include "IORegisters.h" +#include "Tagfile.h" +#include "Options.h" + +#ifndef AVRDISAS_VERSION +#define AVRDISAS_VERSION "dev" +#endif + +void Options_Default(struct Options *Options) { + Options->Show_Addresses = 0; + Options->Show_Opcodes = 0; + Options->Show_Comments = 1; + Options->Show_Cycles = 0; + Options->Show_PseudoCode = 0; + Options->Filename[0] = 0; + Options->MCU[0] = 0; + Options->Tagfile[0] = 0; + Options->CodeStyle = 1; /* 0 = AVR Instruction Set, 1 = avr-gcc */ + Options->Process_Labels = 1; + Options->Pass = 1; + Options->FlashSize = 0; +} + +int StringStart(const char *String1, const char *String2) { + size_t Length1, Length2; + int MinLen; + + Length1 = strlen(String1); + Length2 = strlen(String2); + if (Length1 < Length2) MinLen = Length1; + else MinLen = Length2; + + return strncmp(String1, String2, MinLen); +} + +void Show_Help(char *ProgramName) { + fprintf(stderr, "%s [Options] [Filename]\n", ProgramName); + fprintf(stderr, "'n' can either be 0 or 1 and means 'off' or 'on':\n"); + fprintf(stderr, " -an Do or don't show addresses\n"); + fprintf(stderr, " -on Do or don't show opcodes\n"); + fprintf(stderr, " -cn Do or don't show comments\n"); + fprintf(stderr, " -qn Do or don't show call cycles\n"); + fprintf(stderr, " -sn Do or don't use avr-gcc codestyle\n"); + fprintf(stderr, " -pn Do or don't include pseodocode\n"); + fprintf(stderr, " -ln Do or don't do jump/call-preprocessing\n"); + fprintf(stderr, " -mMCU Set the MCU for IO-register resolving\n"); + fprintf(stderr, " -tFile Set the tagfile to be used\n"); + fprintf(stderr, " -fSize Set the size of the flash area\n"); + fprintf(stderr, " --help Show this helppage\n"); + fprintf(stderr, " -h Show this helppage\n"); + fprintf(stderr, "\n"); + fprintf(stderr, "Example:\n"); + fprintf(stderr, "%s -a0 -o1 -c0 -m2313 -s1 -l1 -ttags.txt -f8192 Myfile.bin\n", ProgramName); + fprintf(stderr, "\n"); + fprintf(stderr, "Version: " AVRDISAS_VERSION "\n"); +} + +int SetVal(char *Argument, char *Destination, char *Description, char Min, char Max) { + int Value; + Value = atoi(Argument); + if ((Value < Min) || (Value > Max)) { + fprintf(stderr, "Invalid argument for '%s': must be between %d and %d.\n", Description, Min, Max); + return 0; + } + *Destination = Value; + return 1; +} + +int SetValInt(const char *Argument, int *Destination, char *Description, int Min, int Max) { + int Value; + Value = atoi(Argument); + if ((Value < Min) || (Value > Max)) { + fprintf(stderr, "Invalid argument for '%s': must be between %d and %d.\n", Description, Min, Max); + return 0; + } + *Destination = Value; + return 1; +} + +int SetMCU(char *Argument, char *Destination) { + strncpy(Destination, Argument, 7); + if (ReadIORegisterFile() == 0) { + fprintf(stderr, "Invalid argument for MCU! Must be one of the following:\n"); + /* List_Supported_MCUs(); */ + return 0; + } + return 1; +} + +char Options_ParseCmdLine(struct Options *Options, int argc, char **argv) { + int i; + char *Argument; + + for (i = 1; i < argc; i++) { + Argument = argv[i]; + + if (StringStart(Argument, "-a") == 0) { + if (SetVal(Argument + 2, &(Options->Show_Addresses), "show addresses", 0, 1) == 0) return 0; + } else if (StringStart(Argument, "-o") == 0) { + if (SetVal(Argument + 2, &(Options->Show_Opcodes), "show opcodes", 0, 1) == 0) return 0; + } else if (StringStart(Argument, "-c") == 0) { + if (SetVal(Argument + 2, &(Options->Show_Comments), "show comments", 0, 1) == 0) return 0; + } else if (StringStart(Argument, "-q") == 0) { + if (SetVal(Argument + 2, &(Options->Show_Cycles), "show cycles", 0, 1) == 0) return 0; + } else if (StringStart(Argument, "-p") == 0) { + if (SetVal(Argument + 2, &(Options->Show_PseudoCode), "show pseudocode", 0, 1) == 0) return 0; + } else if (StringStart(Argument, "-s") == 0) { + if (SetVal(Argument + 2, &(Options->CodeStyle), "codestyle", 0, 2) == 0) return 0; + } else if (StringStart(Argument, "-l") == 0) { + if (SetVal(Argument + 2, &(Options->Process_Labels), "process labels", 0, 1) == 0) return 0; + } else if (StringStart(Argument, "-m") == 0) { + if (SetMCU(Argument + 2, Options->MCU) == 0) return 0; + } else if (StringStart(Argument, "-t") == 0) { + strncpy(Options->Tagfile, Argument + 2, 256); + } else if (StringStart(Argument, "-f") == 0) { + if (SetValInt(Argument + 2, &(Options->FlashSize), "flash size", 32, 1024 * 1024) == 0) return 0; + } else if (StringStart(Argument, "--help") == 0) { + Show_Help(argv[0]); return 0; + } else if (StringStart(Argument, "-h") == 0) { + Show_Help(argv[0]); return 0; + } else { + if (Options->Filename[0] != 0) { + fprintf(stderr, "Filename '%s' was already supplied!\n", Options->Filename); + return 0; + } + strncpy(Options->Filename, Argument, 255); + } + } + + if (Options->Filename[0] == 0) { + fprintf(stderr, "Error: No filename supplied.\n"); + return 0; + } + + if (Options->Tagfile[0] != 0) { + if (!Read_Tagfile(Options->Tagfile)) return 0; + } + + return 1; +} + diff --git a/src/Options.h b/src/Options.h new file mode 100644 index 00000000..6358e267 --- /dev/null +++ b/src/Options.h @@ -0,0 +1,29 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +void Options_Default(struct Options *Options); +char Options_ParseCmdLine(struct Options *Options, int argc, char **argv); + diff --git a/src/Tagfile.c b/src/Tagfile.c new file mode 100644 index 00000000..8a79a311 --- /dev/null +++ b/src/Tagfile.c @@ -0,0 +1,453 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include +#include + +#include "Tagfile.h" + +struct CodeLabel { + int Address; + char *Text; + char *Comment; +}; + +struct PGMLabel { + int Address; + char Type; + unsigned int Count; + char *Comment; +}; + +struct MemLabel { + int Address; + char Type; + unsigned int Count; + char *Comment; +}; + +static int CodeLabelCount = 0; +static struct CodeLabel *CodeLabels; + +static int PGMLabelCount = 0; +static struct PGMLabel *PGMLabels = NULL; + +static int MemLabelCount = 0; +static struct MemLabel *MemLabels = NULL; + +/* +static void Display_Tagfile() { + int i; + printf("%d code labels:\n", CodeLabelCount); + for (i = 0; i < CodeLabelCount; i++) { + printf("%d: 0x%x = %s\n", i, CodeLabels[i].Address, CodeLabels[i].Text); + } + printf("%d PGM labels:\n", PGMLabelCount); + for (i = 0; i < PGMLabelCount; i++) { + printf("%d: 0x%x = %d * %d\n", i, PGMLabels[i].Address, PGMLabels[i].Count, PGMLabels[i].Type); + } +} +*/ + +static int LineError(const char *Token, const char *Message, int LineNo) { + if ((Token == NULL) || (strlen(Token) == 0)) { + fprintf(stderr, "Error: %s in tagfile, line %d.\n", Message, LineNo); + return 1; + } + return 0; +} + +static int ahtoi(const char *String) { + int Value; + size_t i, l; + if (strlen(String) < 3) return atoi(String); + if ((String[0] != '0') || (String[1] != 'x')) return atoi(String); + String += 2; + Value = 0; + l = strlen(String); + for (i = 0; i < l; i++) { + Value *= 16; + if ((String[i] >= '0') && (String[i] <= '9')) Value += String[i] - '0'; + else if ((String[i] >= 'a') && (String[i] <= 'f')) Value += String[i] - 'a' + 10; + else if ((String[i] >= 'A') && (String[i] <= 'F')) Value += String[i] - 'A' + 10; + else return 0; + } + return Value; +} + +static void Add_LabelTag(int Address, const char *LabelText, const char *LabelComment) { + CodeLabelCount++; + + CodeLabels = (struct CodeLabel*)realloc(CodeLabels, sizeof(struct CodeLabel) * CodeLabelCount); + CodeLabels[CodeLabelCount - 1].Address = Address; + + CodeLabels[CodeLabelCount - 1].Text = (char*)malloc(strlen(LabelText) + 1); + strcpy(CodeLabels[CodeLabelCount - 1].Text, LabelText); + + if (LabelComment != NULL) { + CodeLabels[CodeLabelCount - 1].Comment = (char*)malloc(strlen(LabelComment) + 1); + strcpy(CodeLabels[CodeLabelCount - 1].Comment, LabelComment); + } else { + CodeLabels[CodeLabelCount - 1].Comment = NULL; + } +} + +static void Add_PGM_Tag(int Address, char Type, unsigned int Count, const char *Comment) { + PGMLabelCount++; + + PGMLabels = (struct PGMLabel*)realloc(PGMLabels, sizeof(struct PGMLabel) * PGMLabelCount); + PGMLabels[PGMLabelCount - 1].Address = Address; + PGMLabels[PGMLabelCount - 1].Type = Type; + PGMLabels[PGMLabelCount - 1].Count = Count; + if (Comment != NULL) { + PGMLabels[PGMLabelCount - 1].Comment = (char*)malloc(strlen(Comment) + 1); + strcpy(PGMLabels[PGMLabelCount - 1].Comment, Comment); + } else { + PGMLabels[PGMLabelCount - 1].Comment = NULL; + } +} + +static void Add_Mem_Tag(int Address, char Type, unsigned int Count, const char *Comment) { + MemLabelCount++; + + MemLabels = (struct MemLabel*)realloc(MemLabels, sizeof(struct MemLabel) * MemLabelCount); + MemLabels[MemLabelCount - 1].Address = Address; + MemLabels[MemLabelCount - 1].Type = Type; + MemLabels[MemLabelCount - 1].Count = Count; + if (Comment != NULL) { + MemLabels[MemLabelCount - 1].Comment = (char*)malloc(strlen(Comment) + 1); + strcpy(MemLabels[MemLabelCount - 1].Comment, Comment); + } else { + MemLabels[MemLabelCount - 1].Comment = NULL; + } +} + +static void Tagfile_Readline(char *Line, int LineNo) { + char *Token; + int Address; + char Type, Subtype; + int Count; + + if (Line[0] == '#') return; + if (strlen(Line) <= 1) return; + + Token = strtok(Line, "\t\n"); + if (LineError(Token, "nonempty line", LineNo)) return; + + /* Token now holds an address, determine if hex or dec */ + Address = ahtoi(Token); + + Token = strtok(NULL, "\t\n"); + if (LineError(Token, "no second argument", LineNo)) return; + if (strlen(Token) != 1) { + LineError(NULL, "second argument too long", LineNo); + return; + } + + Type = Token[0]; + Token = strtok(NULL, "\t\n"); + if (LineError(Token, "no third argument", LineNo)) return; + + if (Type == 'L') { + char *LabelName = Token; + Token = strtok(NULL, "\t\n"); + Add_LabelTag(Address, LabelName, Token); + return; + } + + if (LineError(Token, "no fourth argument", LineNo)) return; + Subtype = Token[0]; + + /* Either B(yte), W(ord), A(utoterminated string) or S(tring) */ + switch (Subtype) { + case 'B': Subtype = TYPE_BYTE; break; + case 'W': Subtype = TYPE_WORD; break; + case 'A': Subtype = TYPE_ASTRING; break; + case 'S': Subtype = TYPE_STRING; break; + default : Subtype = 0; + } + if (!Subtype) { + LineError(NULL, "invalid type (expected one of L, B, W, A or S)", LineNo); + return; + } + if ((Type == 'M') && ((Subtype != TYPE_BYTE) && (Subtype != TYPE_WORD))) { + LineError(NULL, "memory labels can only be of type B or W", LineNo); + return; + } + + Token = strtok(NULL, "\t\n"); + Count = ahtoi(Token); + if (Count < 1) { + LineError(NULL, "invalid count given", LineNo); + return; + } + + Token = strtok(NULL, "\t\n"); + if (Type == 'P') { + Add_PGM_Tag(Address, Subtype, Count, Token); + } else if (Type == 'M') { + Add_Mem_Tag(Address, Subtype, Count, Token); + } else { + fprintf(stderr, "Invalid tag type '%c'.\n", Type); + } +} + +static int CodeLabelSort(const void *A, const void *B) { + const struct CodeLabel *X, *Y; + X = (const struct CodeLabel*)A; + Y = (const struct CodeLabel*)B; + if (X->Address == Y->Address) return 0; + if (X->Address < Y->Address) return -1; + return 1; +} + +static int PGMLabelSort(const void *A, const void *B) { + const struct PGMLabel *X, *Y; + X = (const struct PGMLabel*)A; + Y = (const struct PGMLabel*)B; + if (X->Address == Y->Address) return 0; + if (X->Address < Y->Address) return -1; + return 1; +} + +static int MemLabelSort(const void *A, const void *B) { + const struct MemLabel *X, *Y; + X = (const struct MemLabel*)A; + Y = (const struct MemLabel*)B; + if (X->Address == Y->Address) return 0; + if (X->Address < Y->Address) return -1; + return 1; +} + +static void Tagfile_SortLabels() { + qsort(CodeLabels, CodeLabelCount, sizeof(struct CodeLabel), CodeLabelSort); + qsort(PGMLabels, PGMLabelCount, sizeof(struct PGMLabel), PGMLabelSort); + qsort(MemLabels, MemLabelCount, sizeof(struct MemLabel), MemLabelSort); +} + +int Read_Tagfile(const char *Filename) { + FILE *f; + f = fopen(Filename, "r"); + if (!f) { + fprintf(stderr, "Error opening tagfile '%s': %s\n", Filename, strerror(errno)); + return 0; + } + + { + char Buffer[256]; + int LineNo = 1; + while (fgets(Buffer, sizeof(Buffer), f) != NULL) { + Tagfile_Readline(Buffer, LineNo++); + } + } + + fclose(f); + + Tagfile_SortLabels(); + return 1; +} + +int Tagfile_FindLabelAddress(int Address) { + struct CodeLabel Goal; + struct CodeLabel *Result; + Goal.Address = Address; + Result = bsearch(&Goal, CodeLabels, CodeLabelCount, sizeof(struct CodeLabel), CodeLabelSort); + if (Result == NULL) return -1; + return Result - CodeLabels; +} + +char *Tagfile_GetLabel(int TagIndex) { + return CodeLabels[TagIndex].Text; +} + +char *Tagfile_GetLabelComment(int TagIndex) { + return CodeLabels[TagIndex].Comment; +} + +int Tagfile_FindPGMAddress(int Address) { + struct PGMLabel Goal; + struct PGMLabel *Result; + Goal.Address = Address; + Result = bsearch(&Goal, PGMLabels, PGMLabelCount, sizeof(struct PGMLabel), PGMLabelSort); + if (Result == NULL) return -1; + return Result - PGMLabels; +} + +const char* Tagfile_Resolve_Mem_Address(int Address) { + static char Buffer[64]; + int i; + for (i = 0; i < MemLabelCount; i++) { + int Start, End, Size; + Size = 0; + if (MemLabels[i].Address > Address) return NULL; + + Start = MemLabels[i].Address; + switch (MemLabels[i].Type) { + case TYPE_BYTE: Size = 1; break; + case TYPE_WORD: Size = 2; break; + } + End = MemLabels[i].Address + MemLabels[i].Count * Size - 1; + + if ((Address >= Start) && (Address <= End)) { + if (MemLabels[i].Count == 1) { + /* Single variable */ + if (Size == 1) { + strncpy(Buffer, MemLabels[i].Comment, sizeof(Buffer)); + } else { + if ((Address - Start) == 0) { + snprintf(Buffer, sizeof(Buffer), "_lo8(%s)", MemLabels[i].Comment); + } else { + snprintf(Buffer, sizeof(Buffer), "_hi8(%s)", MemLabels[i].Comment); + } + } + } else { + /* Array */ + if (Size == 1) { + snprintf(Buffer, sizeof(Buffer), "%s[%d]", MemLabels[i].Comment, (Address - Start) / 1); + } else { + int HiLo = (Address - Start) % 2; + if (HiLo == 0) { + snprintf(Buffer, sizeof(Buffer), "_lo8(%s[%d])", MemLabels[i].Comment, (Address - Start) / 2); + } else { + snprintf(Buffer, sizeof(Buffer), "_hi8(%s[%d])", MemLabels[i].Comment, (Address - Start) / 2); + } + } + } + return Buffer; + } + } + return NULL; +} + +static int Tagfile_Process_Byte(char *Bitstream, int Position, int ArgumentNo, const char *Label) { + printf(".byte 0x%02x\n", ((unsigned char*)Bitstream)[Position]); + return 1; +} + +static int Tagfile_Process_Word(char *Bitstream, int Position, int ArgumentNo, const char *Label) { + printf(".word 0x%02x%02x\n", ((unsigned char*)Bitstream)[Position + 1], ((unsigned char*)Bitstream)[Position]); + return 2; +} + +static int Tagfile_Process_String(char *Bitstream, int Position, int ArgumentNo, const char *Label) { + int i; + unsigned char c; + unsigned int InString = 0; + + printf("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); + i = 0; + while ((c = ((unsigned char*)Bitstream)[Position + i])) { + if ((c >= 32) && (c <= 127)) { + if (!InString) printf(".ascii \""); + printf("%c", c); + InString = 1; + } else { + if (InString) printf("\"\n"); + printf(".byte 0x%02x\n", c); + InString = 0; + } + i++; + } + if (InString) printf("\\0\"\n"); + else printf(".byte 0x00\n"); + + printf("\n"); + return i + 1; +} + +static void Sanitize_String(char *String) { + size_t i; + size_t l = strlen(String); + for (i = 0; i < l; i++) { + if (!(((String[i] >= 'a') && (String[i] <= 'z')) || + (((String[i] >= 'A') && (String[i] <= 'Z'))) || + (((String[i] >= '0') && (String[i] <= '9'))))) { + String[i] = '_'; + } + } +} + +int Tagfile_Process_Data(char *Bitstream, int Position) { + int i; + int BytesAdvanced; + int Index; + int (*ProcessingFunction)(char*, int, int, const char*) = NULL; + char Buffer[32]; + Index = Tagfile_FindPGMAddress(Position); + if (Index == -1) return 0; + + switch (PGMLabels[Index].Type) { + case TYPE_BYTE: ProcessingFunction = Tagfile_Process_Byte; break; + case TYPE_WORD: ProcessingFunction = Tagfile_Process_Word; break; + case TYPE_ASTRING: ProcessingFunction = Tagfile_Process_String; break; + case TYPE_STRING: ProcessingFunction = Tagfile_Process_String; break; + } + + printf("; Inline PGM data: %d ", PGMLabels[Index].Count); + switch (PGMLabels[Index].Type) { + case TYPE_BYTE: printf("byte"); break; + case TYPE_WORD: printf("word"); break; + case TYPE_ASTRING: printf("autoaligned string"); break; + case TYPE_STRING: printf("string"); break; + } + if (PGMLabels[Index].Count != 1) printf("s"); + printf(" starting at 0x%x", Position); + + if (PGMLabels[Index].Comment != NULL) { + printf(" (%s)", PGMLabels[Index].Comment); + } + printf("\n"); + + if ((PGMLabels[Index].Type == TYPE_ASTRING) || (PGMLabels[Index].Type == TYPE_STRING)) { + if (PGMLabels[Index].Comment != NULL) { + snprintf(Buffer, sizeof(Buffer), "%x_%s", Position, PGMLabels[Index].Comment); + Sanitize_String(Buffer); + } else { + snprintf(Buffer, sizeof(Buffer), "%x", Position); + } + } + + BytesAdvanced = 0; + for (i = 0; i < PGMLabels[Index].Count; i++) { + BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, i, Buffer); + } + + if (PGMLabels[Index].Type == TYPE_ASTRING) { + /* Autoaligned string */ + if ((BytesAdvanced % 2) != 0) { + /* Not yet aligned correctly */ + if (Bitstream[Position + BytesAdvanced] != 0x00) fprintf(stderr, "Warning in autoalignment: expected zero but got 0x%0x padding. Ignored.\n", ((unsigned char*)Bitstream)[Position + BytesAdvanced]); + printf(".byte 0x%02x ; String Autoalignment\n", ((unsigned char*)Bitstream)[Position + BytesAdvanced]); + BytesAdvanced++; + } + } + + printf("\n"); + return BytesAdvanced; +} + diff --git a/src/Tagfile.h b/src/Tagfile.h new file mode 100644 index 00000000..d41c53b5 --- /dev/null +++ b/src/Tagfile.h @@ -0,0 +1,39 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#define TYPE_BYTE 1 +#define TYPE_WORD 2 +#define TYPE_ASTRING 3 +#define TYPE_STRING 4 + +int Read_Tagfile(const char *Filename); +int Tagfile_FindLabelAddress(int Address); +char *Tagfile_GetLabel(int TagIndex); +char *Tagfile_GetLabelComment(int TagIndex); +int Tagfile_FindPGMAddress(int Address); +const char* Tagfile_Resolve_Mem_Address(int Address); +int Tagfile_Process_Data(char *Bitstream, int Position); + diff --git a/src/Tools.c b/src/Tools.c new file mode 100644 index 00000000..f39a35cc --- /dev/null +++ b/src/Tools.c @@ -0,0 +1,37 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include "Tools.h" + +unsigned char BitCount(unsigned char Number) { + unsigned char Result = 0; + int i; + for (i = 0; i < 8; i++) { + if (Number & 0x01) Result++; + Number >>= 1; + } + return Result; +} diff --git a/src/Tools.h b/src/Tools.h new file mode 100644 index 00000000..2bfcd164 --- /dev/null +++ b/src/Tools.h @@ -0,0 +1,27 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +unsigned char BitCount(unsigned char Number); diff --git a/src/avrdisas.c b/src/avrdisas.c new file mode 100644 index 00000000..c4e3519f --- /dev/null +++ b/src/avrdisas.c @@ -0,0 +1,587 @@ +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "Globals.h" +#include "Callbacks_Assembly.h" +#include "Callbacks_PseudoCode.h" +#include "Options.h" +#include "JumpCall.h" +#include "IORegisters.h" +#include "MNemonics.h" +#include "Tagfile.h" + +#define READ_BUFFER 131072 /* 128 kB */ + +static int Number_Opcodes = 0; +static struct Opcode Opcodes[256]; +static int Registers[256]; + +struct Options Options; +static char Code_Line[256]; +static char Comment_Line[256]; +static char After_Code_Line[256]; + +void Display_Registers() { + int i; + printf("Register dump:\n"); + for (i = 0; i < 256; i++) { + if (Registers[i] != 0) { + printf("Registers[%3d] '%c': %d = 0x%x\n", i, i, Registers[i], Registers[i]); + } + } + printf("End of register dump.\n"); +} + +int Compare_Opcode(char *Bitstream, char *Bitmask) { + size_t i; + char Bit; + + for (i = 0; i < strlen(Bitmask); i++) { + if ((Bitmask[i] != 'x') && (Bitmask[i] != '1') && (Bitmask[i] != '0')) { + fprintf(stderr, "Invalid Bitmask!\n"); + return 0; + } + + if (Bitmask[i] == 'x') continue; /* Ignore character */ + /* Retrieve the i-th Bit of Bitstream */ + Bit = (Bitstream[i / 8] >> (7 - (i % 8))) & 1; +/* printf("Bit %d is %d [should be %c]\n",i,Bit,Bitmask[i]); */ + if ((Bitmask[i] == '1') && (Bit == 1)) continue; + if ((Bitmask[i] == '0') && (Bit == 0)) continue; + return 0; /* No match */ + } + return 1; /* Match */ +} + +void Register_Opcode(void (*Callback)(char*, int, int), const char *New_Opcode_String, int New_MNemonic) { + Number_Opcodes++; + Opcodes[Number_Opcodes-1].Opcode_String = malloc(strlen(New_Opcode_String) + 1); + strcpy(Opcodes[Number_Opcodes-1].Opcode_String, New_Opcode_String); + Opcodes[Number_Opcodes-1].MNemonic = New_MNemonic; + Opcodes[Number_Opcodes-1].Callback = Callback; +} + +void Supersede_Opcode(void (*Callback)(char*, int, int), int New_MNemonic) { + int i; + for (i = 0; i < Number_Opcodes; i++) { + if (Opcodes[i].MNemonic == New_MNemonic) { + /* Supersede callback */ + Opcodes[i].Callback = Callback; + return; + } + } + fprintf(stderr, "Error: No callback to supersede opcode %d found (%s).\n", New_MNemonic, MNemonic[New_MNemonic]); +} + +int Get_Bitmask_Length(char *Bitmask) { + int Length = 0; + size_t i; + for (i = 0; i < strlen(Bitmask); i++) { + if (Bitmask[i] != ' ') Length++; + } + return Length; +} + +void Clear_Registers() { + int i; + for (i = 0; i < 256; i++) Registers[i] = 0; +} + +char Get_From_Bitmask(char *Bitmask, int Byte, int Bit) { + size_t i; + int Cnt = 0; + int GetBit; + GetBit = (Byte * 8) + Bit; + for (i = 0; i < strlen(Bitmask); i++) { + if (Bitmask[i] != ' ') { + if (Cnt == GetBit) return Bitmask[i]; + Cnt++; + } + } + return '?'; +} + +void Display_Binary(char *Bitstream, int Count) { + int i, j; + for (i = 0; i < Count; i++) { + for (j = 7; j >= 0; j--) { + if ((Bitstream[i] & (1 << j)) != 0) printf("1"); + else printf("0"); + if (j == 4) printf(" "); + } + printf(" "); + if ((((i + 1) % 2) == 0) && (i != 0)) printf(" "); + } + printf("\n"); +} + + +int Match_Opcode(char *Bitmask, char *Bitstream) { + int i; + int Length; + int Byte_Mask, Bit_Mask; + int Byte_Stream, Bit_Stream; + char Mask_Val, Stream_Val; + + Clear_Registers(); + Length = Get_Bitmask_Length(Bitmask); + + for (i = 0; i < Length; i++) { + Byte_Mask = i / 8; + Bit_Mask = i % 8; + + Byte_Stream = i / 8; + Byte_Stream ^= 1; /* Invert last bit */ + Bit_Stream = 7 - (i % 8); + + Mask_Val = Get_From_Bitmask(Bitmask, Byte_Mask, Bit_Mask); + Stream_Val = (Bitstream[Byte_Stream] >> Bit_Stream) & 0x01; + +/* printf("Extracting Bit %2d: Maske = (%d, %d) [%c], Stream = (%d, %d) [%d] ",i,Byte_Mask,Bit_Mask,Mask_Val,Byte_Stream,Bit_Stream,Stream_Val); */ + if ((Mask_Val == '0') || (Mask_Val == '1')) { + /* This Bit is a identification Bit */ + if (Mask_Val == '0') { + if (Stream_Val == 1) { +/* printf("\nMatch failed.\n");*/ + return 0; + } + } else { + if (Stream_Val == 0) { +/* printf("\nMatch failed.\n");*/ + return 0; + } + } + } else { + /* This Bit is a register Bit, set in appropriate place */ + Registers[(int)Mask_Val] <<= 1; + Registers[(int)Mask_Val] |= Stream_Val; +/* printf("-> %d Stored [%x]",Stream_Val,Registers[(int)Mask_Val]); */ + } +/* printf("\n"); */ + } + return 1; +} + +int Get_Next_Opcode(char *Bitstream) { + int i; + for (i = 0; i < Number_Opcodes; i++) { + if (Match_Opcode(Opcodes[i].Opcode_String, Bitstream) == 1) { + return i; + } + } + return -1; +} + +void Disassemble(char *Filename) { + FILE *f; + char Bitstream[READ_BUFFER]; + int Read; + int Pos; + int Opcode; + int i; + +#ifndef DOS_BASED_OS + f = fopen(Filename, "r"); +#else + f = fopen(Filename, "rb"); +#endif + if (!f) { + fprintf(stderr, "Error opening file '%s' for disassembly: %s\n", Filename, strerror(errno)); + return; + } + + if (Options.Show_PseudoCode == 1) { + printf("#include \n"); + printf("\n"); + printf("/* Disassembly of %s (pseudocode) */\n", Filename); + printf("\n"); + printf("int r0, r1, r2, r3, r4, r5, r6, r7, r8, r9;\n"); + printf("int r10, r11, r12, r13, r14, r15, r16, r17, r18, r19;\n"); + printf("int r20, r21, r22, r23, r24, r25, r26, r27, r28, r29;\n"); + printf("int r30, r31, r32;\n"); + printf("\n"); + printf("int main(int argc, char **argv) {\n"); + } else { + if (Options.CodeStyle == CODESTYLE_AVRGCC) { + printf("; Disassembly of %s (avr-gcc style)\n", Filename); + } else { + printf("; Disassembly of %s (AVR instruction set style)\n", Filename); + } + printf("\n"); + } + + Read = fread(Bitstream, 1, READ_BUFFER, f); + Options.Pass = 1; + Pos = 0; + + if ((Options.Process_Labels == 1) || ((!Options.Show_PseudoCode) && (Options.CodeStyle == CODESTYLE_AVRGCC))) { + /* Preprocess to gather jump labels or to gain knowledge about registers which are being used */ + while (Pos < Read) { + Opcode = Get_Next_Opcode(Bitstream + Pos); + if (Opcode == -1) { + Pos += 2; + } else { + Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); + Pos += Get_Bitmask_Length(Opcodes[Opcode].Opcode_String) / 8; + } + } + Enumerate_Labels(); + Options.Pass = 2; + Pos = 0; + } + + if (Options.CodeStyle == CODESTYLE_AVRGCC) { + Emit_Used_IO_Registers(); + printf(".text\n"); + printf("main:\n"); + } + + while (Pos < Read) { + int Added; + + /* Check if this is actually code or maybe only data from tagfile */ + Added = Tagfile_Process_Data(Bitstream, Pos); + if (Added != 0) { + /* Data was added */ + Pos += Added; + continue; + } + + Opcode = Get_Next_Opcode(Bitstream + Pos); + if (Opcode != -1) { + Code_Line[0] = 0; + Comment_Line[0] = 0; + After_Code_Line[0] = 0; + Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); + + if (Options.Process_Labels) { + Print_JumpCalls(Pos); + } + + if (Options.Show_Addresses) printf("%4x: ", Pos); + if (Options.Show_Cycles) { + const char *Cycle = Cycles[Opcodes[Opcode].MNemonic]; + if (!Cycle) printf(" "); + else printf("[%-3s] ", Cycle); + } + + if (Options.Show_Opcodes) { + /* Now display the Opcode */ + for (i = 0; i < (Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8; i++) { + printf("%02x ", (unsigned char)(Bitstream[Pos+i])); + } + printf(" "); + /* Missing spaces */ + for (i = 0; i < 5 - ((Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8); i++) { + printf(" "); + } + } + + if (Code_Line[0] == 0) { + /* No code was generated? */ + printf("; - Not implemented opcode: %d -\n", Opcodes[Opcode].MNemonic); + } else { + if ((Comment_Line[0] == 0) || (!Options.Show_Comments)) { + /* No comment */ + printf("%s\n", Code_Line); + } else { + /* Comment available */ + if (!Options.Show_PseudoCode) { + printf("%-23s ; %s\n", Code_Line, Comment_Line); + } else { + printf("%-35s ; %s\n", Code_Line, Comment_Line); + } + } + } + printf("%s", After_Code_Line); + + Pos += Get_Bitmask_Length(Opcodes[Opcode].Opcode_String) / 8; + } else { + printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x (%d). Disassembler skipped two bytes.\n", ((unsigned char*)Bitstream)[Pos + 1], ((unsigned char *)Bitstream)[Pos], Pos, Pos); + Pos += 2; + } + } + fclose(f); + + if (Options.Show_PseudoCode) { + printf("}\n"); + printf("\n"); + } +} + +void Display_Opcodes() { + unsigned int i; + printf("%d opcodes registered:\n", Number_Opcodes); + for (i = 0; i < Number_Opcodes; i++) { + /* This invokes UB as a function pointer is converted to void* - beware */ + printf("%3d: '%-80s' -> %p\n", i, Opcodes[i].Opcode_String, (void*)Opcodes[i].Callback); + } +} + +int Get_Specifity(char *Opcode) { + size_t i; + int Specifity = 0; + for (i = 0; i < strlen(Opcode); i++) { + if ((Opcode[i] == '0') || (Opcode[i] == '1')) Specifity++; + } + return Specifity; +} + +int Comparison(const void *Element1, const void *Element2) { + struct Opcode *OC1, *OC2; + int SP1, SP2; + OC1 = (struct Opcode*)Element1; + OC2 = (struct Opcode*)Element2; + SP1 = Get_Specifity(OC1->Opcode_String); + SP2 = Get_Specifity(OC2->Opcode_String); + if (SP1 < SP2) return 1; + else if (SP2 == SP1) return 0; + return -1; +} + +int main(int argc, char **argv) { + Options_Default(&Options); + if (!Options_ParseCmdLine(&Options, argc, argv)) return 1; + + Activate_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &Options); + Activate_PC_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &Options); + Register_Opcode(adc_Callback, "0001 11rd dddd rrrr", OPCODE_adc); + Register_Opcode(add_Callback, "0000 11rd dddd rrrr", OPCODE_add); + Register_Opcode(adiw_Callback, "1001 0110 KKdd KKKK", OPCODE_adiw); + Register_Opcode(and_Callback, "0010 00rd dddd rrrr", OPCODE_and); + Register_Opcode(andi_Callback, "0111 KKKK dddd KKKK", OPCODE_andi); + Register_Opcode(asr_Callback, "1001 010d dddd 0101", OPCODE_asr); + Register_Opcode(bclr_Callback, "1001 0100 1sss 1000", OPCODE_bclr); + Register_Opcode(bld_Callback, "1111 100d dddd 0bbb", OPCODE_bld); + Register_Opcode(brbc_Callback, "1111 01kk kkkk ksss", OPCODE_brbc); + Register_Opcode(brbs_Callback, "1111 00kk kkkk ksss", OPCODE_brbs); + Register_Opcode(brcc_Callback, "1111 01kk kkkk k000", OPCODE_brcc); + Register_Opcode(brcs_Callback, "1111 00kk kkkk k000", OPCODE_brcs); + Register_Opcode(break_Callback, "1001 0101 1001 1000", OPCODE_break); + Register_Opcode(breq_Callback, "1111 00kk kkkk k001", OPCODE_breq); + Register_Opcode(brge_Callback, "1111 01kk kkkk k100", OPCODE_brge); + Register_Opcode(brhc_Callback, "1111 01kk kkkk k101", OPCODE_brhc); + Register_Opcode(brhs_Callback, "1111 00kk kkkk k101", OPCODE_brhs); + Register_Opcode(brid_Callback, "1111 01kk kkkk k111", OPCODE_brid); + Register_Opcode(brie_Callback, "1111 00kk kkkk k111", OPCODE_brie); + Register_Opcode(brlo_Callback, "1111 00kk kkkk k000", OPCODE_brlo); + Register_Opcode(brlt_Callback, "1111 00kk kkkk k100", OPCODE_brlt); + Register_Opcode(brmi_Callback, "1111 00kk kkkk k010", OPCODE_brmi); + Register_Opcode(brne_Callback, "1111 01kk kkkk k001", OPCODE_brne); + Register_Opcode(brpl_Callback, "1111 01kk kkkk k010", OPCODE_brpl); + Register_Opcode(brsh_Callback, "1111 01kk kkkk k000", OPCODE_brsh); + Register_Opcode(brtc_Callback, "1111 01kk kkkk k110", OPCODE_brtc); + Register_Opcode(brts_Callback, "1111 00kk kkkk k110", OPCODE_brts); + Register_Opcode(brvc_Callback, "1111 01kk kkkk k011", OPCODE_brvc); + Register_Opcode(brvs_Callback, "1111 00kk kkkk k011", OPCODE_brvs); + Register_Opcode(bset_Callback, "1001 0100 0sss 1000", OPCODE_bset); + Register_Opcode(bst_Callback, "1111 101d dddd 0bbb", OPCODE_bst); + Register_Opcode(call_Callback, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call); + Register_Opcode(cbi_Callback, "1001 1000 AAAA Abbb", OPCODE_cbi); + Register_Opcode(clc_Callback, "1001 0100 1000 1000", OPCODE_clc); + Register_Opcode(clh_Callback, "1001 0100 1101 1000", OPCODE_clh); + Register_Opcode(cli_Callback, "1001 0100 1111 1000", OPCODE_cli); + Register_Opcode(cln_Callback, "1001 0100 1010 1000", OPCODE_cln); +/* Register_Opcode(clr_Callback, "0010 01dd dddd dddd", OPCODE_clr); */ /* Implied by eor */ + Register_Opcode(cls_Callback, "1001 0100 1100 1000", OPCODE_cls); + Register_Opcode(clt_Callback, "1001 0100 1110 1000", OPCODE_clt); + Register_Opcode(clv_Callback, "1001 0100 1011 1000", OPCODE_clv); + Register_Opcode(clz_Callback, "1001 0100 1001 1000", OPCODE_clz); + Register_Opcode(com_Callback, "1001 010d dddd 0000", OPCODE_com); + Register_Opcode(cp_Callback, "0001 01rd dddd rrrr", OPCODE_cp); + Register_Opcode(cpc_Callback, "0000 01rd dddd rrrr", OPCODE_cpc); + Register_Opcode(cpi_Callback, "0011 KKKK dddd KKKK", OPCODE_cpi); + Register_Opcode(cpse_Callback, "0001 00rd dddd rrrr", OPCODE_cpse); + Register_Opcode(dec_Callback, "1001 010d dddd 1010", OPCODE_dec); + Register_Opcode(eicall_Callback, "1001 0101 0001 1001", OPCODE_eicall); + Register_Opcode(eijmp_Callback, "1001 0100 0001 1001", OPCODE_eijmp); + Register_Opcode(elpm1_Callback, "1001 0101 1101 1000", OPCODE_elpm_1); + Register_Opcode(elpm2_Callback, "1001 000d dddd 0110", OPCODE_elpm_2); + Register_Opcode(elpm3_Callback, "1001 000d dddd 0111", OPCODE_elpm_3); + Register_Opcode(eor_Callback, "0010 01rd dddd rrrr", OPCODE_eor); + Register_Opcode(fmul_Callback, "0000 0011 0ddd 1rrr", OPCODE_fmul); + Register_Opcode(fmuls_Callback, "0000 0011 1ddd 0rrr", OPCODE_fmuls); + Register_Opcode(fmulsu_Callback, "0000 0011 1ddd 1rrr", OPCODE_fmulsu); + Register_Opcode(icall_Callback, "1001 0101 0000 1001", OPCODE_icall); + Register_Opcode(ijmp_Callback, "1001 0100 0000 1001", OPCODE_ijmp); + Register_Opcode(in_Callback, "1011 0AAd dddd AAAA", OPCODE_in); + Register_Opcode(inc_Callback, "1001 010d dddd 0011", OPCODE_inc); + Register_Opcode(jmp_Callback, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp); + Register_Opcode(ld1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); + Register_Opcode(ld2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); + Register_Opcode(ld3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); + Register_Opcode(ldy1_Callback, "1000 000d dddd 1000", OPCODE_ld_4); + Register_Opcode(ldy2_Callback, "1001 000d dddd 1001", OPCODE_ld_5); + Register_Opcode(ldy3_Callback, "1001 000d dddd 1010", OPCODE_ld_6); + Register_Opcode(ldy4_Callback, "10q0 qq0d dddd 1qqq", OPCODE_ldd_1); + Register_Opcode(ldz1_Callback, "1000 000d dddd 0000", OPCODE_ld_7); + Register_Opcode(ldz2_Callback, "1001 000d dddd 0001", OPCODE_ld_8); + Register_Opcode(ldz3_Callback, "1001 000d dddd 0010", OPCODE_ld_9); + Register_Opcode(ldz4_Callback, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2); + Register_Opcode(ldi_Callback, "1110 KKKK dddd KKKK", OPCODE_ldi); + Register_Opcode(lds_Callback, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds); + Register_Opcode(lpm1_Callback, "1001 0101 1100 1000", OPCODE_lpm_1); + Register_Opcode(lpm2_Callback, "1001 000d dddd 0100", OPCODE_lpm_2); + Register_Opcode(lpm3_Callback, "1001 000d dddd 0101", OPCODE_lpm_3); +/* Register_Opcode(lsl_Callback, "0000 11dd dddd dddd", OPCODE_lsl); */ /* Implied by add */ + Register_Opcode(lsr_Callback, "1001 010d dddd 0110", OPCODE_lsr); + Register_Opcode(mov_Callback, "0010 11rd dddd rrrr", OPCODE_mov); + Register_Opcode(movw_Callback, "0000 0001 dddd rrrr", OPCODE_movw); + Register_Opcode(mul_Callback, "1001 11rd dddd rrrr", OPCODE_mul); + Register_Opcode(muls_Callback, "0000 0010 dddd rrrr", OPCODE_muls); + Register_Opcode(mulsu_Callback, "0000 0011 0ddd 0rrr", OPCODE_mulsu); + Register_Opcode(neg_Callback, "1001 010d dddd 0001", OPCODE_neg); + Register_Opcode(nop_Callback, "0000 0000 0000 0000", OPCODE_nop); + Register_Opcode(or_Callback, "0010 10rd dddd rrrr", OPCODE_or); + Register_Opcode(ori_Callback, "0110 KKKK dddd KKKK", OPCODE_ori); + Register_Opcode(out_Callback, "1011 1AAr rrrr AAAA", OPCODE_out); + Register_Opcode(pop_Callback, "1001 000d dddd 1111", OPCODE_pop); + Register_Opcode(push_Callback, "1001 001d dddd 1111", OPCODE_push); + Register_Opcode(rcall_Callback, "1101 kkkk kkkk kkkk", OPCODE_rcall); + Register_Opcode(ret_Callback, "1001 0101 0000 1000", OPCODE_ret); + Register_Opcode(reti_Callback, "1001 0101 0001 1000", OPCODE_reti); + Register_Opcode(rjmp_Callback, "1100 kkkk kkkk kkkk", OPCODE_rjmp); +/* Register_Opcode(rol_Callback, "0001 11dd dddd dddd", OPCODE_rol); */ /* Implied by adc */ + Register_Opcode(ror_Callback, "1001 010d dddd 0111", OPCODE_ror); + Register_Opcode(sbc_Callback, "0000 10rd dddd rrrr", OPCODE_sbc); + Register_Opcode(sbci_Callback, "0100 KKKK dddd KKKK", OPCODE_sbci); + Register_Opcode(sbi_Callback, "1001 1010 AAAA Abbb", OPCODE_sbi); + Register_Opcode(sbic_Callback, "1001 1001 AAAA Abbb", OPCODE_sbic); + Register_Opcode(sbis_Callback, "1001 1011 AAAA Abbb", OPCODE_sbis); + Register_Opcode(sbiw_Callback, "1001 0111 KKdd KKKK", OPCODE_sbiw); + Register_Opcode(sbr_Callback, "0110 KKKK dddd KKKK", OPCODE_sbr); + Register_Opcode(sbrc_Callback, "1111 110r rrrr 0bbb", OPCODE_sbrc); + Register_Opcode(sbrs_Callback, "1111 111r rrrr 0bbb", OPCODE_sbrs); + Register_Opcode(sec_Callback, "1001 0100 0000 1000", OPCODE_sec); + Register_Opcode(seh_Callback, "1001 0100 0101 1000", OPCODE_seh); + Register_Opcode(sei_Callback, "1001 0100 0111 1000", OPCODE_sei); + Register_Opcode(sen_Callback, "1001 0100 0010 1000", OPCODE_sen); + Register_Opcode(ser_Callback, "1110 1111 dddd 1111", OPCODE_ser); + Register_Opcode(ses_Callback, "1001 0100 0100 1000", OPCODE_ses); + Register_Opcode(set_Callback, "1001 0100 0110 1000", OPCODE_set); + Register_Opcode(sev_Callback, "1001 0100 0011 1000", OPCODE_sev); + Register_Opcode(sez_Callback, "1001 0100 0001 1000", OPCODE_sez); + Register_Opcode(sleep_Callback, "1001 0101 1000 1000", OPCODE_sleep); + Register_Opcode(spm_Callback, "1001 0101 1110 1000", OPCODE_spm); + Register_Opcode(st1_Callback, "1001 001r rrrr 1100", OPCODE_st_1); + Register_Opcode(st2_Callback, "1001 001r rrrr 1101", OPCODE_st_2); + Register_Opcode(st3_Callback, "1001 001r rrrr 1110", OPCODE_st_3); + Register_Opcode(sty1_Callback, "1000 001r rrrr 1000", OPCODE_st_4); + Register_Opcode(sty2_Callback, "1001 001r rrrr 1001", OPCODE_st_5); + Register_Opcode(sty3_Callback, "1001 001r rrrr 1010", OPCODE_st_6); + Register_Opcode(sty4_Callback, "10q0 qq1r rrrr 1qqq", OPCODE_std_1); + Register_Opcode(stz1_Callback, "1000 001r rrrr 0000", OPCODE_st_7); + Register_Opcode(stz2_Callback, "1001 001r rrrr 0001", OPCODE_st_8); + Register_Opcode(stz3_Callback, "1001 001r rrrr 0010", OPCODE_st_9); + Register_Opcode(stz4_Callback, "10q0 qq1r rrrr 0qqq", OPCODE_std_2); + Register_Opcode(sts_Callback, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts); + Register_Opcode(sub_Callback, "0001 10rd dddd rrrr", OPCODE_sub); + Register_Opcode(subi_Callback, "0101 KKKK dddd KKKK", OPCODE_subi); + Register_Opcode(swap_Callback, "1001 010d dddd 0010", OPCODE_swap); +/* Register_Opcode(tst_Callback, "0010 00dd dddd dddd", OPCODE_tst); */ /* Implied by and */ + Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); + + if (Options.Show_PseudoCode) { + Supersede_Opcode(adc_Callback_PC, OPCODE_adc); + Supersede_Opcode(add_Callback_PC, OPCODE_add); + Supersede_Opcode(sub_Callback_PC, OPCODE_sub); + Supersede_Opcode(sbc_Callback_PC, OPCODE_sbc); + Supersede_Opcode(mov_Callback_PC, OPCODE_mov); + Supersede_Opcode(brcc_Callback_PC, OPCODE_brcc); + Supersede_Opcode(brcs_Callback_PC, OPCODE_brcs); + Supersede_Opcode(breq_Callback_PC, OPCODE_breq); + Supersede_Opcode(brge_Callback_PC, OPCODE_brge); + Supersede_Opcode(brhc_Callback_PC, OPCODE_brhc); + Supersede_Opcode(brhs_Callback_PC, OPCODE_brhs); + Supersede_Opcode(brid_Callback_PC, OPCODE_brid); + Supersede_Opcode(brie_Callback_PC, OPCODE_brie); + Supersede_Opcode(brlo_Callback_PC, OPCODE_brlo); + Supersede_Opcode(brlt_Callback_PC, OPCODE_brlt); + Supersede_Opcode(brmi_Callback_PC, OPCODE_brmi); + Supersede_Opcode(brne_Callback_PC, OPCODE_brne); + Supersede_Opcode(brpl_Callback_PC, OPCODE_brpl); + Supersede_Opcode(brsh_Callback_PC, OPCODE_brsh); + Supersede_Opcode(brtc_Callback_PC, OPCODE_brtc); + Supersede_Opcode(brts_Callback_PC, OPCODE_brts); + Supersede_Opcode(brvc_Callback_PC, OPCODE_brvc); + Supersede_Opcode(brvs_Callback_PC, OPCODE_brvs); + Supersede_Opcode(out_Callback_PC, OPCODE_out); + Supersede_Opcode(in_Callback_PC, OPCODE_in); + Supersede_Opcode(cli_Callback_PC, OPCODE_cli); + Supersede_Opcode(sei_Callback_PC, OPCODE_sei); + Supersede_Opcode(ret_Callback_PC, OPCODE_ret); + Supersede_Opcode(reti_Callback_PC, OPCODE_reti); + Supersede_Opcode(andi_Callback_PC, OPCODE_andi); + Supersede_Opcode(subi_Callback_PC, OPCODE_subi); + Supersede_Opcode(sbci_Callback_PC, OPCODE_sbci); + Supersede_Opcode(sbr_Callback_PC, OPCODE_sbr); + Supersede_Opcode(ori_Callback_PC, OPCODE_ori); + Supersede_Opcode(ldi_Callback_PC, OPCODE_ldi); + Supersede_Opcode(lds_Callback_PC, OPCODE_lds); + Supersede_Opcode(sts_Callback_PC, OPCODE_sts); + Supersede_Opcode(call_Callback_PC, OPCODE_call); + Supersede_Opcode(rcall_Callback_PC, OPCODE_rcall); + Supersede_Opcode(ror_Callback_PC, OPCODE_ror); + Supersede_Opcode(lsr_Callback_PC, OPCODE_lsr); + Supersede_Opcode(eor_Callback_PC, OPCODE_eor); + Supersede_Opcode(swap_Callback_PC, OPCODE_swap); + Supersede_Opcode(jmp_Callback_PC, OPCODE_jmp); + Supersede_Opcode(rjmp_Callback_PC, OPCODE_rjmp); + Supersede_Opcode(cpi_Callback_PC, OPCODE_cpi); + Supersede_Opcode(asr_Callback_PC, OPCODE_asr); + Supersede_Opcode(inc_Callback_PC, OPCODE_inc); + Supersede_Opcode(dec_Callback_PC, OPCODE_dec); + Supersede_Opcode(cp_Callback_PC, OPCODE_cp); + Supersede_Opcode(cpc_Callback_PC, OPCODE_cpc); + Supersede_Opcode(cpse_Callback_PC, OPCODE_cpse); + Supersede_Opcode(and_Callback_PC, OPCODE_and); + Supersede_Opcode(or_Callback_PC, OPCODE_or); + Supersede_Opcode(mul_Callback_PC, OPCODE_mul); + Supersede_Opcode(sbi_Callback_PC, OPCODE_sbi); + Supersede_Opcode(sbis_Callback_PC, OPCODE_sbis); + Supersede_Opcode(sbic_Callback_PC, OPCODE_sbic); + Supersede_Opcode(cbi_Callback_PC, OPCODE_cbi); + Supersede_Opcode(ser_Callback_PC, OPCODE_ser); + Supersede_Opcode(movw_Callback_PC, OPCODE_movw); + Supersede_Opcode(adiw_Callback_PC, OPCODE_adiw); + Supersede_Opcode(lpm1_Callback_PC, OPCODE_lpm_1); + Supersede_Opcode(st2_Callback_PC, OPCODE_st_2); + } + + qsort(Opcodes, Number_Opcodes, sizeof(struct Opcode), Comparison); + + Disassemble(Options.Filename); + return 0; +} + From a21f84bb64198096f7d141ca90d64c65c9c73919 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 11:09:58 +0100 Subject: [PATCH 273/422] Rename and reformat disasm files --- src/Callbacks_Assembly.c | 831 ----------------- src/Callbacks_PseudoCode.c | 660 -------------- src/Globals.h | 211 ----- src/IORegisters.c | 114 --- src/JumpCall.c | 180 ---- src/MNemonics.c | 444 --------- src/Options.c | 172 ---- src/Tagfile.c | 453 ---------- src/avrdisas.c | 587 ------------ src/disasm.c | 625 +++++++++++++ src/disasm_callbacks_assembly.c | 850 ++++++++++++++++++ ...Assembly.h => disasm_callbacks_assembly.h} | 20 +- src/disasm_callbacks_pseudocode.c | 687 ++++++++++++++ ...doCode.h => disasm_callbacks_pseudocode.h} | 20 +- src/{Functions.h => disasm_functions.h} | 24 +- src/disasm_globals.h | 212 +++++ src/disasm_ioregisters.c | 126 +++ src/{IORegisters.h => disasm_ioregisters.h} | 19 +- src/disasm_jumpcall.c | 196 ++++ src/{JumpCall.h => disasm_jumpcall.h} | 17 +- src/disasm_mnemonics.c | 445 +++++++++ src/{MNemonics.h => disasm_mnemonics.h} | 19 +- src/disasm_options.c | 188 ++++ src/{Options.h => disasm_options.h} | 18 +- src/disasm_tagfile.c | 523 +++++++++++ src/{Tagfile.h => disasm_tagfile.h} | 28 +- src/{Tools.c => disasm_tools.c} | 35 +- src/{Tools.h => disasm_tools.h} | 17 +- 28 files changed, 3965 insertions(+), 3756 deletions(-) delete mode 100644 src/Callbacks_Assembly.c delete mode 100644 src/Callbacks_PseudoCode.c delete mode 100644 src/Globals.h delete mode 100644 src/IORegisters.c delete mode 100644 src/JumpCall.c delete mode 100644 src/MNemonics.c delete mode 100644 src/Options.c delete mode 100644 src/Tagfile.c delete mode 100644 src/avrdisas.c create mode 100644 src/disasm.c create mode 100644 src/disasm_callbacks_assembly.c rename src/{Callbacks_Assembly.h => disasm_callbacks_assembly.h} (97%) create mode 100644 src/disasm_callbacks_pseudocode.c rename src/{Callbacks_PseudoCode.h => disasm_callbacks_pseudocode.h} (95%) rename src/{Functions.h => disasm_functions.h} (66%) create mode 100644 src/disasm_globals.h create mode 100644 src/disasm_ioregisters.c rename src/{IORegisters.h => disasm_ioregisters.h} (74%) create mode 100644 src/disasm_jumpcall.c rename src/{JumpCall.h => disasm_jumpcall.h} (82%) create mode 100644 src/disasm_mnemonics.c rename src/{MNemonics.h => disasm_mnemonics.h} (77%) create mode 100644 src/disasm_options.c rename src/{Options.h => disasm_options.h} (79%) create mode 100644 src/disasm_tagfile.c rename src/{Tagfile.h => disasm_tagfile.h} (72%) rename src/{Tools.c => disasm_tools.c} (66%) rename src/{Tools.h => disasm_tools.h} (77%) diff --git a/src/Callbacks_Assembly.c b/src/Callbacks_Assembly.c deleted file mode 100644 index 5c2f15ba..00000000 --- a/src/Callbacks_Assembly.c +++ /dev/null @@ -1,831 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include - -#include "MNemonics.h" -#include "Globals.h" -#include "Callbacks_Assembly.h" -#include "JumpCall.h" -#include "IORegisters.h" -#include "Functions.h" -#include "Tools.h" -#include "Tagfile.h" - -static char *Code_Line; -static char *Comment_Line; -static char *After_Code_Line; -static int *Registers; -static struct Options *Options; - -void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, struct Options *New_Options) { - Code_Line = New_Code_Line; - Comment_Line = New_Comment_Line; - After_Code_Line = New_After_Code_Line; - Registers = New_Registers; - Options = New_Options; -} - -void Operation_Simple(int MNemonic_Int) { - snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); -} - -void Operation_Rd(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); -} - -void Operation_Rd16(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); -} - -void Operation_Rd_Rr(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); -} - -void Operation_Rd16_Rr16(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); -} - -void Operation_Rd16_K(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); - snprintf(Comment_Line, 255, "%d", RK); -} - -void Operation_Rd_K(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); - snprintf(Comment_Line, 255, "%d", RK); -} - -void Operation_RdW_K(int MNemonic_Int) { - if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); - } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); - } - snprintf(Comment_Line, 255, "%d", RK); -} - -void Operation_RdW_RrW(int MNemonic_Int) { - if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); - } else { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); - } -} - -void Operation_s_k(int MNemonic_Int, int Position) { - int Bits, Offset; - int Target; - - Bits = Rs; - Offset = (2 * Rk); - if (Offset > 128) Offset -= 256; - Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, MNemonic_Int, 0); - if (Options->Process_Labels == 0) { - if (Offset>0) { - snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); - } else { - snprintf(Code_Line, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); - } - snprintf(Comment_Line, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); - } else { - snprintf(Code_Line, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); - } -} - -void Operation_r_b(int MNemonic_Int) { - int Register, Bit; - Register = Rr; - Bit = Rb; - snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void Operation_Rd_b(int MNemonic_Int) { - int Register, Bit; - Register = Rd; - Bit = Rb; - snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void Operation_A_b(int MNemonic_Int) { - int Register, Bit; - const char *Register_Name; - Register = RA; - Bit = Rb; - Register_Name = Resolve_IO_Register(Register); - if (Register_Name == NULL) { - snprintf(Code_Line, 255, "%-7s 0x%02x, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); - } else { - snprintf(Code_Line, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); - } -} - -void Operation_s(int MNemonic_Int) { - int Bit; - Bit = Rs; - snprintf(Code_Line, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { - int Offset; - int Target; - - Offset = (2 * Rk); - if (Offset > 128) Offset -= 256; - Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, MNemonic_Int, 0); - if (Options->Process_Labels == 0) { - if (Offset>0) { - snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); - } else { - snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); - } - snprintf(Comment_Line, 255, "0x%02x", Target); - } else { - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); - } -} - -/************* Now to the callback functions *************/ - -CALLBACK(adc_Callback) { - if (Rd == Rr) { - Operation_Rd(OPCODE_rol); - } else { - Operation_Rd_Rr(MNemonic_Int); - } -} - -CALLBACK(add_Callback) { - if (Rd == Rr) { - Operation_Rd(OPCODE_lsl); - } else { - Operation_Rd_Rr(MNemonic_Int); - } -} - -CALLBACK(adiw_Callback) { - if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); - } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); - } - snprintf(Comment_Line, 255, "%d", RK); -} - -CALLBACK(and_Callback) { - if (Rd == Rr) { - Operation_Rd(OPCODE_tst); - } else { - Operation_Rd_Rr(MNemonic_Int); - } -} - -CALLBACK(andi_Callback) { - if (BitCount(RK) < 4) { - Operation_Rd16_K(MNemonic_Int); - } else { - RK = ~RK; - RK &= 0xff; - Operation_Rd16_K(OPCODE_cbr); - } -} - -CALLBACK(asr_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(bclr_Callback) { - Operation_s(MNemonic_Int); -} - -CALLBACK(bld_Callback) { - Operation_Rd_b(MNemonic_Int); -} - -CALLBACK(brbc_Callback) { - Operation_s_k(MNemonic_Int, Position); -} - -CALLBACK(brbs_Callback) { - Operation_s_k(MNemonic_Int, Position); -} - -CALLBACK(brcc_Callback) { - Operation_k(MNemonic_Int, Position, "Carry == 0"); -} - -CALLBACK(brcs_Callback) { - Operation_k(MNemonic_Int, Position, "Carry == 1"); -} - -CALLBACK(break_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(breq_Callback) { - Operation_k(MNemonic_Int, Position, "c1 == c2"); -} - -CALLBACK(brge_Callback) { - Operation_k(MNemonic_Int, Position, "c1 (signed)>= c2"); -} - -CALLBACK(brhc_Callback) { - Operation_k(MNemonic_Int, Position, "HalfCarry == 0"); -} - -CALLBACK(brhs_Callback) { - Operation_k(MNemonic_Int, Position, "HalfCarry == 1"); -} - -CALLBACK(brid_Callback) { - Operation_k(MNemonic_Int, Position, "Global_Interrupts_Disabled()"); -} - -CALLBACK(brie_Callback) { - Operation_k(MNemonic_Int, Position, "Global_Interrupts_Enabled()"); -} - -CALLBACK(brlo_Callback) { - Operation_k(MNemonic_Int, Position, "c1 (unsigned)< c2"); -} - -CALLBACK(brlt_Callback) { - Operation_k(MNemonic_Int, Position, "c1 (signed)< c2"); -} - -CALLBACK(brmi_Callback) { - Operation_k(MNemonic_Int, Position, "< 0"); -} - -CALLBACK(brne_Callback) { - Operation_k(MNemonic_Int, Position, "c1 != c2"); -} - -CALLBACK(brpl_Callback) { - Operation_k(MNemonic_Int, Position, "> 0"); -} - -CALLBACK(brsh_Callback) { - Operation_k(MNemonic_Int, Position, "c1 (unsigned)>= c2"); -} - -CALLBACK(brtc_Callback) { - Operation_k(MNemonic_Int, Position, "T == 0"); -} - -CALLBACK(brts_Callback) { - Operation_k(MNemonic_Int, Position, "T == 1"); -} - -CALLBACK(brvc_Callback) { - Operation_k(MNemonic_Int, Position, "Overflow == 0"); -} - -CALLBACK(brvs_Callback) { - Operation_k(MNemonic_Int, Position, "Overflow == 1"); -} - -CALLBACK(bset_Callback) { - Operation_s(MNemonic_Int); -} - -CALLBACK(bst_Callback) { - Operation_Rd_b(MNemonic_Int); -} - -CALLBACK(call_Callback) { - int Pos; - Pos = FixTargetAddress(2 * Rk); - Register_JumpCall(Position, Pos, MNemonic_Int, 1); - if (!Options->Process_Labels) { - snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); - } else { - char *LabelName; - char *LabelComment = NULL; - LabelName = Get_Label_Name(Pos, &LabelComment); - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); - if (LabelComment != NULL) snprintf(Comment_Line, 255, "%s", LabelComment); - } -} - -CALLBACK(cbi_Callback) { - Operation_A_b(MNemonic_Int); -} - -CALLBACK(clc_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(clh_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(cli_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(cln_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(cls_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(clt_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(clv_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(clz_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(com_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(cp_Callback) { - Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(cpc_Callback) { - Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(cpi_Callback) { - Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(cpse_Callback) { - Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(dec_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(eicall_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(eijmp_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(elpm1_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(elpm2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(elpm3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(eor_Callback) { - if (Rd == Rr) { - Operation_Rd(OPCODE_clr); - } else { - Operation_Rd_Rr(MNemonic_Int); - } -} - -CALLBACK(fmul_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); -} - -CALLBACK(fmuls_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); -} - -CALLBACK(fmulsu_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); -} - -CALLBACK(icall_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(ijmp_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(in_Callback) { - int Register_Number; - const char *Register_Name; - Register_Number = RA; - Register_Name = Resolve_IO_Register(Register_Number); - if (Register_Name != NULL) { - snprintf(Code_Line, 255, "%-7s r%d, %s", MNemonic[MNemonic_Int], Rd, Register_Name); - } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, Register_Number); - snprintf(Comment_Line, 255, "%d", RA); - } -} - -CALLBACK(inc_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(jmp_Callback) { - int Pos; - Pos = FixTargetAddress(2 * Rk); - if (!Options->Process_Labels) { - snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); - } else { - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Pos, NULL)); - } - Register_JumpCall(Position, Pos, MNemonic_Int, 0); -} - -CALLBACK(ld1_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, X", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ld2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, X+", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ld3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, -X", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ldy1_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Y", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ldy2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Y+", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ldy3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, -Y", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ldy4_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Y+%d", MNemonic[MNemonic_Int], Rd, Rq); -} - -CALLBACK(ldz1_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ldz2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ldz3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, -Z", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(ldz4_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z+%d", MNemonic[MNemonic_Int], Rd, Rq); -} - -CALLBACK(ldi_Callback) { - Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(lds_Callback) { - const char *MemAddress; - snprintf(Code_Line, 255, "%-7s r%d, 0x%04x", MNemonic[MNemonic_Int], Rd, Rk); - MemAddress = Tagfile_Resolve_Mem_Address(Rk); - snprintf(Code_Line, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); - if (MemAddress) { - snprintf(Comment_Line, 255, "%s", MemAddress); - } -} - -CALLBACK(lpm1_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(lpm2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(lpm3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); -} - -CALLBACK(lsr_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(mov_Callback) { - Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(movw_Callback) { - Operation_RdW_RrW(MNemonic_Int); -} - -CALLBACK(mul_Callback) { - Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(muls_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); -} - -CALLBACK(mulsu_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); -} - -CALLBACK(neg_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(nop_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(or_Callback) { - Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(ori_Callback) { - Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(out_Callback) { - int Register_Number; - const char *Register_Name; - Register_Number = RA; - Register_Name = Resolve_IO_Register(Register_Number); - if (Register_Name != NULL) { - snprintf(Code_Line, 255, "%-7s %s, r%d", MNemonic[MNemonic_Int], Register_Name, Rr); - } else { - snprintf(Code_Line, 255, "%-7s 0x%02x, r%d", MNemonic[MNemonic_Int], Register_Number, Rr); - snprintf(Comment_Line, 255, "%d", RA); - } -} - -CALLBACK(pop_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(push_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(rcall_Callback) { - int Offset; - int Target; - - Offset = 2 * (Rk); - if (Offset > 4096) Offset -= 8192; - Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, MNemonic_Int, 1); - if (Options->Process_Labels == 0) { - if (Offset>0) { - snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); - } else { - snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); - } - snprintf(Comment_Line, 255, "0x%02x", Target); - } else { - char *LabelName; - char *LabelComment = NULL; - LabelName = Get_Label_Name(Target, &LabelComment); - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); - if (LabelComment != NULL) snprintf(Comment_Line, 255, "%s", LabelComment); - } -} - -CALLBACK(ret_Callback) { - Operation_Simple(MNemonic_Int); - snprintf(After_Code_Line, 255, "\n"); -} - -CALLBACK(reti_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(rjmp_Callback) { - int Offset; - int Target; - - Offset = 2 * (Rk); - if (Offset > 4096) Offset -= 8192; - Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, MNemonic_Int, 0); - - if (Options->Process_Labels == 0) { - if (Offset>0) { - snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); - } else { - snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); - } - if (Target >= 0) { - snprintf(Comment_Line, 255, "0x%02x", Target); - } else { - snprintf(Comment_Line, 255, "-0x%02x - Illegal jump position -- specify flash size!", -Target); - } - } else { - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); - } -} - -CALLBACK(ror_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(sbc_Callback) { - Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(sbci_Callback) { - Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(sbi_Callback) { - Operation_A_b(MNemonic_Int); -} - -CALLBACK(sbic_Callback) { - Operation_A_b(MNemonic_Int); -} - -CALLBACK(sbis_Callback) { - Operation_A_b(MNemonic_Int); -} - -CALLBACK(sbiw_Callback) { - if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2*Rd+25, 2*Rd+24, RK); - } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2*Rd+24, RK); - } - snprintf(Comment_Line, 255, "%d", RK); -} - -CALLBACK(sbr_Callback) { - Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(sbrc_Callback) { - Operation_r_b(MNemonic_Int); -} - -CALLBACK(sbrs_Callback) { - Operation_r_b(MNemonic_Int); -} - -CALLBACK(sec_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(seh_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(sei_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(sen_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(ser_Callback) { - Operation_Rd16(MNemonic_Int); -} - -CALLBACK(ses_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(set_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(sev_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(sez_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(sleep_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(spm_Callback) { - Operation_Simple(MNemonic_Int); -} - -CALLBACK(st1_Callback) { - snprintf(Code_Line, 255, "%-7s X, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(st2_Callback) { - snprintf(Code_Line, 255, "%-7s X+, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(st3_Callback) { - snprintf(Code_Line, 255, "%-7s -X, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(sty1_Callback) { - snprintf(Code_Line, 255, "%-7s Y, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(sty2_Callback) { - snprintf(Code_Line, 255, "%-7s Y+, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(sty3_Callback) { - snprintf(Code_Line, 255, "%-7s -Y, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(sty4_Callback) { - snprintf(Code_Line, 255, "%-7s Y+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); -} - -CALLBACK(stz1_Callback) { - snprintf(Code_Line, 255, "%-7s Z, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(stz2_Callback) { - snprintf(Code_Line, 255, "%-7s Z+, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(stz3_Callback) { - snprintf(Code_Line, 255, "%-7s -Z, r%d", MNemonic[MNemonic_Int], Rr); -} - -CALLBACK(stz4_Callback) { - snprintf(Code_Line, 255, "%-7s Z+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); -} - -CALLBACK(sts_Callback) { - /* The AVR instruction set 11/2005 defines operation as: "(k) <- Rr", however "(k) <- Rd" seems to be right */ - const char *MemAddress; - MemAddress = Tagfile_Resolve_Mem_Address(Rk); - snprintf(Code_Line, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); - if (MemAddress) { - snprintf(Comment_Line, 255, "%s", MemAddress); - } -} - -CALLBACK(sub_Callback) { - Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(subi_Callback) { - Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(swap_Callback) { - Operation_Rd(MNemonic_Int); -} - -CALLBACK(wdr_Callback) { - Operation_Simple(MNemonic_Int); -} - diff --git a/src/Callbacks_PseudoCode.c b/src/Callbacks_PseudoCode.c deleted file mode 100644 index a81a4c43..00000000 --- a/src/Callbacks_PseudoCode.c +++ /dev/null @@ -1,660 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include - -#include "MNemonics.h" -#include "Globals.h" -#include "Callbacks_PseudoCode.h" -#include "JumpCall.h" -#include "IORegisters.h" -#include "Functions.h" -#include "Tagfile.h" - -static char *Code_Line; -static char *Comment_Line; -static char *After_Code_Line; -static int *Registers; -static struct Options *Options; - -void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, struct Options *New_Options) { - Code_Line = New_Code_Line; - Comment_Line = New_Comment_Line; - After_Code_Line = New_After_Code_Line; - Registers = New_Registers; - Options = New_Options; -} - -void PC_Operation_Simple(int MNemonic_Int) { - snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); -} - -void PC_Operation_Rd(int MNemonic_Int) { - switch (MNemonic_Int) { - case OPCODE_lsl: - snprintf(Code_Line, 255, "r%d <<= 1;", Rd); - snprintf(Comment_Line, 255, "_BV(0) = 0 (logical shift)"); - break; - case OPCODE_lsr: - snprintf(Code_Line, 255, "r%d >>= 1;", Rd); - snprintf(Comment_Line, 255, "_BV(7) = 0, Carry = _BV(0) (logical shift)"); - break; - case OPCODE_ror: - snprintf(Code_Line, 255, "r%d >>= 1;", Rd); - snprintf(Comment_Line, 255, "_BV(7) = Carry, Carry = _BV(0) (rotate right)"); - break; - case OPCODE_asr: -/* snprintf(Code_Line, 255, "r%d >>= 1;", Rd);*/ -/* snprintf(Comment_Line, 255, "_BV(7) = Sign (Arithmetic Shift)");*/ - snprintf(Code_Line, 255, "r%d /= 2;", Rd); - snprintf(Comment_Line, 255, "arithmetic shift right"); - break; - case OPCODE_swap: - snprintf(Code_Line, 255, "r%d = ((r%d & 0xf0) >> 4) | ((r%d & 0x0f) << 4);", Rd, Rd, Rd); - snprintf(Comment_Line, 255, "swap nibbles"); - break; - case OPCODE_clr: - snprintf(Code_Line, 255, "r%d = 0x00;", Rd); - snprintf(Comment_Line, 255, "0"); - break; - default: - snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); - } -} - -void PC_Operation_Rd16(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); -} - -void PC_Operation_Rd_Rr(int MNemonic_Int) { - switch (MNemonic_Int) { - case OPCODE_add: - if (Rd != Rr) { - snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "No carry"); - } else { - snprintf(Code_Line, 255, "r%d *= 2;", Rd); - } - break; - case OPCODE_adc: - snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "With carry"); - break; - case OPCODE_sub: - snprintf(Code_Line, 255, "r%d -= r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "No carry"); - break; - case OPCODE_sbc: - snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "With carry"); - break; - case OPCODE_mul: - snprintf(Code_Line, 255, "r1:r0 = r%d * r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "Unsigned"); - break; - case OPCODE_mov: - snprintf(Code_Line, 255, "r%d = r%d;", Rd, Rr); - break; - case OPCODE_eor: - snprintf(Code_Line, 255, "r%d ^= r%d;", Rd, Rr); - break; - case OPCODE_and: - if (Rd != Rr) { - snprintf(Code_Line, 255, "r%d &= r%d;", Rd, Rr); - } else { - snprintf(Code_Line, 255, "(r%d == 0) || (r%d < 0);", Rd, Rd); - snprintf(Comment_Line, 255, "test r%d", Rd); - } - break; - case OPCODE_or: - snprintf(Code_Line, 255, "r%d |= r%d;", Rd, Rr); - break; - case OPCODE_cp: - snprintf(Code_Line, 255, "cmp(r%d, r%d);", Rd, Rr); - break; - case OPCODE_cpc: - snprintf(Code_Line, 255, "cmp(r%d, r%d);", Rd, Rr); - snprintf(Comment_Line, 255, "with carry"); - break; - case OPCODE_cpse: - snprintf(Code_Line, 255, "skipif (r%d == r%d)", Rd, Rr); - break; - default: - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); - } -} - -void PC_Operation_Rd16_Rr16(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); -} - -void PC_Operation_Rd16_K(int MNemonic_Int) { - switch (MNemonic_Int) { - case OPCODE_andi: - snprintf(Code_Line, 255, "r%d &= %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x", RK); - break; - case OPCODE_subi: - snprintf(Code_Line, 255, "r%d -= %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x, no carry", RK); - break; - case OPCODE_sbci: - snprintf(Code_Line, 255, "r%d -= %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x, with carry", RK); - break; - case OPCODE_sbr: - case OPCODE_ori: - snprintf(Code_Line, 255, "r%d |= %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x", RK); - break; - default: - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); - snprintf(Comment_Line, 255, "%d", RK); - } -} - -void PC_Operation_Rd_K(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); - snprintf(Comment_Line, 255, "%d", RK); -} - -void PC_Operation_RdW_K(int MNemonic_Int) { - if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd+1, Rd, RK); - } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); - } - snprintf(Comment_Line, 255, "%d", RK); -} - -void PC_Operation_RdW_RrW(int MNemonic_Int) { - if (Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2*Rd)+1, 2*Rd, (2*Rr)+1, 2*Rr); - } else { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2*Rd, 2*Rr); - } -} - -void PC_Operation_s_k(int MNemonic_Int, int Position) { - int Bits, Offset; - Bits = Rs; - Offset = (2 * Rk); - if (Offset > 128) Offset -= 256; - - int Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); - if (Options->Process_Labels == 0) { - if (Offset>0) { - snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); - } else { - snprintf(Code_Line, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); - } - snprintf(Comment_Line, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); - } else { - snprintf(Code_Line, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); - } -} - -void PC_Operation_r_b(int MNemonic_Int) { - int Register, Bit; - Register = Rr; - Bit = Rb; - snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void PC_Operation_Rd_b(int MNemonic_Int) { - int Register, Bit; - Register = Rd; - Bit = Rb; - snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void PC_Operation_A_b(int MNemonic_Int) { - int Register, Bit; - const char *Register_Name; - char Register_Value[5]; - Register = RA; - Bit = Rb; - Register_Name = Resolve_IO_Register(Register); - if (Register_Name == NULL) { - snprintf(Register_Value, sizeof(Register_Value), "0x%02x", Register); - Register_Name = Register_Value; - } - switch (MNemonic_Int) { - case OPCODE_cbi: - snprintf(Code_Line, 255, "IO[%s] &= ~(_BV(%d));", Register_Name, Bit); - break; - case OPCODE_sbi: - snprintf(Code_Line, 255, "IO[%s] |= _BV(%d);", Register_Name, Bit); - break; - case OPCODE_sbis: - snprintf(Code_Line, 255, "skipif (IO[%s] & _BV(%d))", Register_Name, Bit); - break; - case OPCODE_sbic: - snprintf(Code_Line, 255, "skipif (!(IO[%s] & _BV(%d)))",Register_Name, Bit); - break; - default: - snprintf(Code_Line, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); - } - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void PC_Operation_s(int MNemonic_Int) { - int Bit; - Bit = Rs; - snprintf(Code_Line, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { - int Offset; - Offset = (2 * Rk); - if (Offset > 128) Offset -= 256; - - int Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); - if (Options->Process_Labels == 0) { - if (Offset > 0) { - snprintf(Code_Line, 255, "if (%s) goto .+%d;", Pseudocode, Offset); - } else { - snprintf(Code_Line, 255, "if (%s) goto .%d", Pseudocode, Offset); - } - snprintf(Comment_Line, 255, "0x%02x", Target); - } else { - snprintf(Code_Line, 255, "if (%s) goto %s;", Pseudocode, Get_Label_Name(Target, NULL)); - } -} - -/************* Now to the callback functions *************/ - -CALLBACK(adc_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(add_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(sub_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(sbc_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(mov_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(brcc_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "!Carry"); -} - -CALLBACK(brcs_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Carry"); -} - -CALLBACK(breq_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 == c2"); -} - -CALLBACK(brge_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 (signed)>= c2"); -} - -CALLBACK(brhc_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "!HalfCarry"); -} - -CALLBACK(brhs_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "HalfCarry"); -} - -CALLBACK(brid_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Global_Interrupts_Disabled()"); -} - -CALLBACK(brie_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Global_Interrupts_Enabled()"); -} - -CALLBACK(brlo_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 (unsigned)< c2"); -} - -CALLBACK(brlt_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 (signed)< c2"); -} - -CALLBACK(brmi_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "< 0"); -} - -CALLBACK(brne_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 != c2"); -} - -CALLBACK(brpl_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "> 0"); -} - -CALLBACK(brsh_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 (unsigned)>= c2"); -} - -CALLBACK(brtc_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "T == 0"); -} - -CALLBACK(brts_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "T == 1"); -} - -CALLBACK(brvc_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Overflow == 0"); -} - -CALLBACK(brvs_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Overflow == 1"); -} - -CALLBACK(out_Callback_PC) { - int Register_Number; - const char *Register_Name; - Register_Number = RA; - Register_Name = Resolve_IO_Register(Register_Number); - if (Register_Name) { - snprintf(Code_Line, 255, "IO[%s] = r%d;", Register_Name, Rr); - } else { - snprintf(Code_Line, 255, "IO[0x%02x] = r%d;", Register_Number, Rr); - snprintf(Comment_Line, 255, "%d", RA); - } -} - -CALLBACK(in_Callback_PC) { - int Register_Number; - const char *Register_Name; - Register_Number = RA; - Register_Name = Resolve_IO_Register(Register_Number); - if (Register_Name) { - snprintf(Code_Line, 255, "r%d = IO[%s];", Rd, Register_Name); - } else { - snprintf(Code_Line, 255, "r%d = IO[0x%02x];", Rd, Register_Number); - snprintf(Comment_Line, 255, "%d", RA); - } -} - -CALLBACK(cli_Callback_PC) { - snprintf(Code_Line, 255, "Disable_Interrupts();"); -} - -CALLBACK(sei_Callback_PC) { - snprintf(Code_Line, 255, "Enable_Interrupts();"); -} - -CALLBACK(ret_Callback_PC) { - snprintf(Code_Line, 255, "return;"); - snprintf(After_Code_Line, 255, "\n"); -} - -CALLBACK(reti_Callback_PC) { - snprintf(Code_Line, 255, "ireturn;"); - snprintf(After_Code_Line, 255, "\n"); -} - -CALLBACK(andi_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(subi_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(sbci_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(sbr_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(ori_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); -} - -CALLBACK(ldi_Callback_PC) { - snprintf(Code_Line, 255, "r%d = %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x", RK); -} - -CALLBACK(lds_Callback_PC) { - const char *MemAddress; - MemAddress = Tagfile_Resolve_Mem_Address(Rk); - if (!MemAddress) { - snprintf(Code_Line, 255, "r%d = Memory[0x%04x];", Rd, Rk); - snprintf(Comment_Line, 255, "%d", Rk); - } else { - snprintf(Code_Line, 255, "r%d = %s;", Rd, MemAddress); - snprintf(Comment_Line, 255, "0x%04x", Rk); - } -} - -CALLBACK(sts_Callback_PC) { - const char *MemAddress; - MemAddress = Tagfile_Resolve_Mem_Address(Rk); - if (!MemAddress) { - snprintf(Code_Line, 255, "Memory[0x%04x] = r%d;", Rk, Rd); - snprintf(Comment_Line, 255, "%d", Rk); - } else { - snprintf(Code_Line, 255, "%s = r%d;", MemAddress, Rd); - snprintf(Comment_Line, 255, "0x%04x", Rk); - } -} - -CALLBACK(call_Callback_PC) { - int Pos; - Pos = FixTargetAddress(2 * Rk); - Register_JumpCall(Position, Pos, MNemonic_Int, 1); - if (Options->Process_Labels == 0) { - snprintf(Code_Line, 255, "0x%02x();", Pos); - } else { - char *LabelName; - char *LabelComment = NULL; - LabelName = Get_Label_Name(Pos, &LabelComment); - snprintf(Code_Line, 255, "%s();", LabelName); - if (LabelComment != NULL) { - snprintf(Comment_Line, 255, "%s", LabelComment); - } - } -} - -CALLBACK(rcall_Callback_PC) { - int Offset; - Offset = 2 * (Rk); - if (Offset > 4096) Offset -= 8192; - - int Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 1); - if (!Options->Process_Labels) { - snprintf(Comment_Line, 255, "0x%02x();", Target); - } else { - char *LabelName; - char *LabelComment = NULL; - LabelName = Get_Label_Name(Target, &LabelComment); - snprintf(Code_Line, 255, "%s();", LabelName); - if (LabelComment != NULL) { - snprintf(Comment_Line, 255, "%s", LabelComment); - } - } -} - -CALLBACK(ror_Callback_PC) { - PC_Operation_Rd(MNemonic_Int); -} - -CALLBACK(lsr_Callback_PC) { - PC_Operation_Rd(MNemonic_Int); -} - -CALLBACK(swap_Callback_PC) { - PC_Operation_Rd(MNemonic_Int); -} - -CALLBACK(eor_Callback_PC) { - if (Rd == Rr) { - PC_Operation_Rd(OPCODE_clr); - } else { - PC_Operation_Rd_Rr(MNemonic_Int); - } -} - -CALLBACK(jmp_Callback_PC) { - int Pos; - Pos = FixTargetAddress(2 * Rk); - if (Options->Process_Labels == 0) { - snprintf(Code_Line, 255, "goto 0x%02x;", Pos); - } else { - snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Pos, NULL)); - } - Register_JumpCall(Position, Pos, MNemonic_Int, 0); -} - -CALLBACK(rjmp_Callback_PC) { - int Offset; - Offset = 2 * (Rk); - if (Offset > 4096) Offset -= 8192; - - int Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); - - if (Options->Process_Labels == 0) { - if (Offset>0) { - snprintf(Code_Line, 255, "goto .+%d;", Offset); - } else { - snprintf(Code_Line, 255, "goto .%d", Offset); - } - if (Target >= 0) { - snprintf(Comment_Line, 255, "0x%02x", Target); - } else { - snprintf(Comment_Line, 255, "-0x%02x - Illegal jump position -- specify flash size!", -(Target)); - } - } else { - snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Position + Offset + 2, NULL)); - } -} - -CALLBACK(cpi_Callback_PC) { - if (RK == 0) { - snprintf(Code_Line, 255, "cmp(r%d, 0);", Rd + 16); - } else { - snprintf(Code_Line, 255, "cmp(r%d, 0x%02x);", Rd + 16, RK); - snprintf(Comment_Line, 255, "%d", RK); - } -} - -CALLBACK(asr_Callback_PC) { - PC_Operation_Rd(MNemonic_Int); -} - -CALLBACK(dec_Callback_PC) { - snprintf(Code_Line, 255, "r%d--;", Rd); -} - -CALLBACK(inc_Callback_PC) { - snprintf(Code_Line, 255, "r%d++;", Rd); -} - -CALLBACK(cp_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(cpc_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(cpse_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(and_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(or_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(mul_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); -} - -CALLBACK(sbi_Callback_PC) { - PC_Operation_A_b(MNemonic_Int); -} - -CALLBACK(sbic_Callback_PC) { - PC_Operation_A_b(MNemonic_Int); -} - -CALLBACK(sbis_Callback_PC) { - PC_Operation_A_b(MNemonic_Int); -} - -CALLBACK(cbi_Callback_PC) { - PC_Operation_A_b(MNemonic_Int); -} - -CALLBACK(ser_Callback_PC) { - snprintf(Code_Line, 255, "r%d = 0xff;", Rd + 16); - snprintf(Comment_Line, 255, "255"); -} - -CALLBACK(adiw_Callback_PC) { - if (RK != 1) { - snprintf(Code_Line, 255, "[r%d:r%d] += 0x%02x;", 2 * Rd + 25, 2 * Rd + 24, RK); - snprintf(Comment_Line, 255, "%d", RK); - } else { - snprintf(Code_Line, 255, "[r%d:r%d]++;", 2 * Rd + 25, 2 * Rd + 24); - } -} - -CALLBACK(movw_Callback_PC) { - snprintf(Code_Line, 255, "[r%d:r%d] = [r%d:r%d];", (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); -} - -CALLBACK(lpm1_Callback_PC) { - snprintf(Code_Line, 255, "r0 = Flash[r30:r31];"); -} - -CALLBACK(st2_Callback_PC) { - snprintf(Code_Line, 255, "Flash[[r26:r27]++] = r%d;", Rr); -} - diff --git a/src/Globals.h b/src/Globals.h deleted file mode 100644 index e5d39d48..00000000 --- a/src/Globals.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#define Rd (Registers[(int)'d']) -#define Rr (Registers[(int)'r']) -#define Rk (Registers[(int)'k']) -#define RK (Registers[(int)'K']) -#define Rs (Registers[(int)'s']) -#define RA (Registers[(int)'A']) -#define Rb (Registers[(int)'b']) -#define Rq (Registers[(int)'q']) - -#define CALLBACK(name) void name(char *Bitstream, int Position, int MNemonic_Int) - -#define CODESTYLE_AVR_INSTRUCTION_SET 0 -#define CODESTYLE_AVRGCC 1 - -struct Opcode { - char *Opcode_String; - void (*Callback)(char*, int, int); - int MNemonic; -}; - -struct JumpCall { - int From; - int To; - int Type; - unsigned int LabelNumber; - unsigned char FunctionCall; -}; - -struct Options { - char Show_Addresses; - char Show_Opcodes; - char Show_Comments; - char Show_Cycles; - char Show_PseudoCode; - char Filename[256]; - char MCU[8]; - char Tagfile[256]; - char CodeStyle; - char Process_Labels; - char Pass; - int FlashSize; -}; - -struct IO_Register { - int Address; - char Name[16]; - unsigned char Used; -}; - -#define OPCODE_adc 0 -#define OPCODE_add 1 -#define OPCODE_adiw 2 -#define OPCODE_and 3 -#define OPCODE_andi 4 -#define OPCODE_asr 5 -#define OPCODE_bclr 6 -#define OPCODE_bld 7 -#define OPCODE_brbc 8 -#define OPCODE_brbs 9 -#define OPCODE_brcc 10 -#define OPCODE_brcs 11 -#define OPCODE_break 12 -#define OPCODE_breq 13 -#define OPCODE_brge 14 -#define OPCODE_brhc 15 -#define OPCODE_brhs 16 -#define OPCODE_brid 17 -#define OPCODE_brie 18 -#define OPCODE_brlo 19 -#define OPCODE_brlt 20 -#define OPCODE_brmi 21 -#define OPCODE_brne 22 -#define OPCODE_brpl 23 -#define OPCODE_brsh 24 -#define OPCODE_brtc 25 -#define OPCODE_brts 26 -#define OPCODE_brvc 27 -#define OPCODE_brvs 28 -#define OPCODE_bset 29 -#define OPCODE_bst 30 -#define OPCODE_call 31 -#define OPCODE_cbi 32 -#define OPCODE_cbr 33 -#define OPCODE_clc 34 -#define OPCODE_clh 35 -#define OPCODE_cli 36 -#define OPCODE_cln 37 -#define OPCODE_clr 38 -#define OPCODE_cls 39 -#define OPCODE_clt 40 -#define OPCODE_clv 41 -#define OPCODE_clz 42 -#define OPCODE_com 43 -#define OPCODE_cp 44 -#define OPCODE_cpc 45 -#define OPCODE_cpi 46 -#define OPCODE_cpse 47 -#define OPCODE_dec 48 -#define OPCODE_eicall 49 -#define OPCODE_eijmp 50 -#define OPCODE_elpm_1 51 -#define OPCODE_elpm_2 52 -#define OPCODE_elpm_3 53 -#define OPCODE_eor 54 -#define OPCODE_fmul 55 -#define OPCODE_fmuls 56 -#define OPCODE_fmulsu 57 -#define OPCODE_icall 58 -#define OPCODE_ijmp 59 -#define OPCODE_in 60 -#define OPCODE_inc 61 -#define OPCODE_jmp 62 -#define OPCODE_ld_1 63 -#define OPCODE_ld_2 64 -#define OPCODE_ld_3 65 -#define OPCODE_ld_4 66 -#define OPCODE_ld_5 67 -#define OPCODE_ld_6 68 -#define OPCODE_ldd_1 69 -#define OPCODE_ld_7 70 -#define OPCODE_ld_8 71 -#define OPCODE_ld_9 72 -#define OPCODE_ldd_2 73 -#define OPCODE_ldi 74 -#define OPCODE_lds 75 -#define OPCODE_lpm_1 76 -#define OPCODE_lpm_2 77 -#define OPCODE_lpm_3 78 -#define OPCODE_lsl 79 -#define OPCODE_lsr 80 -#define OPCODE_mov 81 -#define OPCODE_movw 82 -#define OPCODE_mul 83 -#define OPCODE_muls 84 -#define OPCODE_mulsu 85 -#define OPCODE_neg 86 -#define OPCODE_nop 87 -#define OPCODE_or 88 -#define OPCODE_ori 89 -#define OPCODE_out 90 -#define OPCODE_pop 91 -#define OPCODE_push 92 -#define OPCODE_rcall 93 -#define OPCODE_ret 94 -#define OPCODE_reti 95 -#define OPCODE_rjmp 96 -#define OPCODE_rol 97 -#define OPCODE_ror 98 -#define OPCODE_sbc 99 -#define OPCODE_sbci 100 -#define OPCODE_sbi 101 -#define OPCODE_sbic 102 -#define OPCODE_sbis 103 -#define OPCODE_sbiw 104 -#define OPCODE_sbr 105 -#define OPCODE_sbrc 106 -#define OPCODE_sbrs 107 -#define OPCODE_sec 108 -#define OPCODE_seh 109 -#define OPCODE_sei 110 -#define OPCODE_sen 111 -#define OPCODE_ser 112 -#define OPCODE_ses 113 -#define OPCODE_set 114 -#define OPCODE_sev 115 -#define OPCODE_sez 116 -#define OPCODE_sleep 117 -#define OPCODE_spm 118 -#define OPCODE_st_1 119 -#define OPCODE_st_2 120 -#define OPCODE_st_3 121 -#define OPCODE_st_4 122 -#define OPCODE_st_5 123 -#define OPCODE_st_6 124 -#define OPCODE_std_1 125 -#define OPCODE_st_7 126 -#define OPCODE_st_8 127 -#define OPCODE_st_9 128 -#define OPCODE_std_2 129 -#define OPCODE_sts 130 -#define OPCODE_sub 131 -#define OPCODE_subi 132 -#define OPCODE_swap 133 -#define OPCODE_tst 134 -#define OPCODE_wdr 135 diff --git a/src/IORegisters.c b/src/IORegisters.c deleted file mode 100644 index 6c2810e6..00000000 --- a/src/IORegisters.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include -#include - -#include "Globals.h" - -extern struct Options Options; - -static struct IO_Register *KnownIORegisters = NULL; -static unsigned int KnownIORegistersCount = 0; - -unsigned int ReadIORegisterFile() { - FILE *f; - f = fopen("/etc/avrdisas.conf", "r"); - if (!f) { - f = fopen("avrdisas.conf", "r"); - } - if (!f) { - fprintf(stderr, "Could not read any configuration file.\n"); - return 0; - } - - - { - char Buffer[256]; - int CurrentMCU = 0; - while (fgets(Buffer, sizeof(Buffer), f)) { - char *Token; - struct IO_Register TempRegister; - - if (!(Token = strtok(Buffer, "\t\n"))) continue; - if (!strcmp(Token, "Register")) { - if (!CurrentMCU) continue; - if (!(Token = strtok(NULL, "\t\n"))) continue; - if (strlen(Token) == 0) continue; - if (Token[1] == 'x') { - TempRegister.Address = strtol(Token + 2, NULL, 16); - } else { - TempRegister.Address = atoi(Token); - } - if (!(Token = strtok(NULL, "\t\n"))) continue; - strncpy(TempRegister.Name, Token, 16); - TempRegister.Used = 0; - - KnownIORegisters = (struct IO_Register*)realloc(KnownIORegisters, sizeof(struct IO_Register) * (KnownIORegistersCount + 1)); - KnownIORegisters[KnownIORegistersCount] = TempRegister; - KnownIORegistersCount++; - } else if (!strcmp(Token, "Unit")) { - if (!(Token = strtok(NULL, "\t\n"))) continue; - CurrentMCU = (!strcmp(Token, Options.MCU)) || (!strcmp(Token, "Global")); - } - } - } - - fclose(f); - return KnownIORegistersCount; -} - -const char* Resolve_IO_Register(int Number) { - int Resolved; - unsigned int i; - - if (!strcmp(Options.MCU, "None")) return NULL; - - Resolved = -1; - for (i = 0; i < KnownIORegistersCount; i++) { - if (KnownIORegisters[i].Address == Number) { - Resolved = i; - break; - } - } - - if (Resolved != -1) { - KnownIORegisters[Resolved].Used = 1; - return KnownIORegisters[Resolved].Name; - } else { - return NULL; - } -} - -void Emit_Used_IO_Registers() { - unsigned int i; - if (Options.Show_PseudoCode) return; - for (i = 0; i < KnownIORegistersCount; i++) { - if (KnownIORegisters[i].Used) printf(".equ %s, 0x%x\n", KnownIORegisters[i].Name, KnownIORegisters[i].Address); - } -} - diff --git a/src/JumpCall.c b/src/JumpCall.c deleted file mode 100644 index b59dd3ca..00000000 --- a/src/JumpCall.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include -#include - -#include "Globals.h" -#include "MNemonics.h" -#include "Tagfile.h" -#include "JumpCall.h" - -extern struct Options Options; -static int JumpCall_Count; -static struct JumpCall *JumpCalls; - -void Display_JumpCalls() { - int i; - printf("%d jumps/calls found:\n", JumpCall_Count); - for (i = 0; i < JumpCall_Count; i++) { - printf("%3d: 0x%-4x -> 0x%-4x %s (%d)\n", i, (unsigned int)JumpCalls[i].From, (unsigned int)JumpCalls[i].To, MNemonic[JumpCalls[i].Type], JumpCalls[i].FunctionCall); - } -} - -int FixTargetAddress(int Address) { - if (Options.FlashSize) { - Address %= Options.FlashSize; - if (Address < 0) { - Address += Options.FlashSize; - } - } - return Address; -} - -void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { - if ((Options.Process_Labels == 1) && (Options.Pass == 1)) { - JumpCall_Count++; - JumpCalls = realloc(JumpCalls, sizeof(struct JumpCall) * (JumpCall_Count)); - JumpCalls[JumpCall_Count - 1].From = From; - JumpCalls[JumpCall_Count - 1].To = To; - JumpCalls[JumpCall_Count - 1].Type = Type; - JumpCalls[JumpCall_Count - 1].LabelNumber = 0; - JumpCalls[JumpCall_Count - 1].FunctionCall = FunctionCall; - } -} - -int JC_Comparison(const void *Element1, const void *Element2) { - struct JumpCall *JC1, *JC2; - JC1 = (struct JumpCall*)Element1; - JC2 = (struct JumpCall*)Element2; - if ((JC1->To) > (JC2->To)) return 1; - else if ((JC1->To) == (JC2->To)) return 0; - return -1; -} - -void Sort_JumpCalls() { - qsort(JumpCalls, JumpCall_Count, sizeof(struct JumpCall), JC_Comparison); -} - -void Correct_Label_Types(void) { - int i, j; - int LastIdx = 0; - int LastDest = JumpCalls[0].To; - char CurType = JumpCalls[0].FunctionCall; - - for (i = 1; i < JumpCall_Count; i++) { - if (JumpCalls[i].To != LastDest) { - for (j = LastIdx; j < i; j++) JumpCalls[j].FunctionCall = CurType; - LastIdx = i; - LastDest = JumpCalls[i].To; - CurType = 0; - } - CurType = (CurType || JumpCalls[i].FunctionCall); - } - for (j = LastIdx; j < JumpCall_Count; j++) JumpCalls[j].FunctionCall = CurType; -} - -void Enumerate_Labels(void) { - int i; - int CurrentLabelNumber = 0; - int CurrentFunctionNumber = 0; - int Destination; - - if (JumpCall_Count < 2) return; - - Sort_JumpCalls(); - Correct_Label_Types(); - - Destination = JumpCalls[0].To; - if (JumpCalls[0].FunctionCall) CurrentFunctionNumber++; - else CurrentLabelNumber++; - for (i = 0; i < JumpCall_Count; i++) { - if (Destination != JumpCalls[i].To) { - if (JumpCalls[i].FunctionCall) CurrentFunctionNumber++; - else CurrentLabelNumber++; - Destination = JumpCalls[i].To; - } - if (JumpCalls[i].FunctionCall) JumpCalls[i].LabelNumber = CurrentFunctionNumber; - else JumpCalls[i].LabelNumber = CurrentLabelNumber; - } -} - -char *Get_Label_Name(int Destination, char **LabelComment) { - int i; - static char Buffer[256]; - int TagIndex; - char *TagLabel; - - TagIndex = Tagfile_FindLabelAddress(Destination); - if (TagIndex != -1) { - TagLabel = Tagfile_GetLabel(TagIndex); - snprintf(Buffer, sizeof(Buffer), "%s", TagLabel); - if (LabelComment != NULL) *LabelComment = Tagfile_GetLabelComment(TagIndex); - return Buffer; - } - - for (i = 0; i < JumpCall_Count; i++) { - if ((JumpCalls[i].To) == Destination) { - if (JumpCalls[i].FunctionCall) { - snprintf(Buffer, sizeof(Buffer), "Function%d", JumpCalls[i].LabelNumber); - } else { - snprintf(Buffer, sizeof(Buffer), "Label%d", JumpCalls[i].LabelNumber); - } - return Buffer; - } - } - - snprintf(Buffer, sizeof(Buffer), "UNKNOWN"); - return Buffer; -} - -/* Show all references which refer to "Position" as destination */ -void Print_JumpCalls(int Position) { - int i; - int Match = 0; - - for (i = 0; i < JumpCall_Count; i++) { - if ((JumpCalls[i].To) == Position) { - if (Match == 0) { - printf("\n"); - Match = 1; - } - printf("; Referenced from offset 0x%02x by %s\n", JumpCalls[i].From, MNemonic[JumpCalls[i].Type]); - } - } - if (Match == 1) { - char *LabelName; - char *LabelComment = NULL; - LabelName = Get_Label_Name(Position, &LabelComment); - if (LabelComment == NULL) { - printf("%s:\n", LabelName); - } else { - printf("%s: ; %s\n", LabelName, LabelComment); - } - } -} - diff --git a/src/MNemonics.c b/src/MNemonics.c deleted file mode 100644 index a96efb19..00000000 --- a/src/MNemonics.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include - -const char* MNemonic[] = { - "adc", - "add", - "adiw", - "and", - "andi", - "asr", - "bclr", - "bld", - "brbc", - "brbs", - "brcc", - "brcs", - "break", - "breq", - "brge", - "brhc", - "brhs", - "brid", - "brie", - "brlo", - "brlt", - "brmi", - "brne", - "brpl", - "brsh", - "brtc", - "brts", - "brvc", - "brvs", - "bset", - "bst", - "call", - "cbi", - "cbr", - "clc", - "clh", - "cli", - "cln", - "clr", - "cls", - "clt", - "clv", - "clz", - "com", - "cp", - "cpc", - "cpi", - "cpse", - "dec", - "eicall", - "eijmp", - "elpm", - "elpm", - "elpm", - "eor", - "fmul", - "fmuls", - "fmulsu", - "icall", - "ijmp", - "in", - "inc", - "jmp", - "ld", - "ld", - "ld", - "ld", - "ld", - "ld", - "ldd", - "ld", - "ld", - "ld", - "ldd", - "ldi", - "lds", - "lpm", - "lpm", - "lpm", - "lsl", - "lsr", - "mov", - "movw", - "mul", - "muls", - "mulsu", - "neg", - "nop", - "or", - "ori", - "out", - "pop", - "push", - "rcall", - "ret", - "reti", - "rjmp", - "rol", - "ror", - "sbc", - "sbci", - "sbi", - "sbic", - "sbis", - "sbiw", - "sbr", - "sbrc", - "sbrs", - "sec", - "seh", - "sei", - "sen", - "ser", - "ses", - "set", - "sev", - "sez", - "sleep", - "spm", - "st", - "st", - "st", - "st", - "st", - "st", - "std", - "st", - "st", - "st", - "std", - "sts", - "sub", - "subi", - "swap", - "tst", - "wdr" -}; - -const char *Cycles[] = { - "1", /* adc */ - "1", /* add */ - "2", /* adiw */ - "1", /* and */ - "1", /* andi */ - "1", /* asr */ - "1", /* bclr */ - "1", /* bld */ - "1/2", /* brbc */ - "1/2", /* brbs */ - "1/2", /* brcc */ - "1/2", /* brcs */ - "N/A", /* break */ - "1/2", /* breq */ - "1/2", /* brge */ - "1/2", /* brhc */ - "1/2", /* brhs */ - "1/2", /* brid */ - "1/2", /* brie */ - "1/2", /* brlo */ - "1/2", /* brlt */ - "1/2", /* brmi */ - "1/2", /* brne */ - "1/2", /* brpl */ - "1/2", /* brsh */ - "1/2", /* brtc */ - "1/2", /* brts */ - "1/2", /* brvc */ - "1/2", /* brvs */ - "1", /* bset */ - "1", /* bst */ - "4", /* call */ - "2", /* cbi */ - "1", /* cbr */ - "1", /* clc */ - "", /* clh */ - "1", /* cli */ - "1", /* cln */ - "1", /* clr */ - "1", /* cls */ - "1", /* clt */ - "1", /* clv */ - "1", /* clz */ - "1", /* com */ - "1", /* cp */ - "1", /* cpc */ - "1", /* cpi */ - "1-3", /* cpse */ - "1", /* dec */ - NULL, - NULL, - NULL, - NULL, - NULL, - "1", /* eor */ - "2", /* fmul */ - "2", /* fmuls */ - "2", /* fmulsu */ - "3", /* icall */ - "2", /* ijmp */ - "1", /* in */ - "1", /* inc */ - "3", /* jmp */ - "2", /* ld */ - "2", /* ld */ - "2", /* ld */ - "2", /* ld */ - "2", /* ld */ - "2", /* ld */ - "2", /* ldd */ - "2", /* ld */ - "2", /* ld */ - "2", /* ld */ - "2", /* ldd */ - "1", /* ldi */ - "2", /* lds */ - "3", /* lpm */ - "3", /* lpm */ - "3", /* lpm */ - "1", /* lsl */ - "1", /* lsr */ - "1", /* mov */ - "1", /* movw */ - "2", /* mul */ - "2", /* muls */ - "2", /* mulsu */ - "1", /* neg */ - "1", /* nop */ - "1", /* or */ - "1", /* ori */ - "1", /* out */ - "2", /* pop */ - "2", /* push */ - "3", /* rcall */ - "4", /* ret */ - "4", /* reti */ - "2", /* rjmp */ - "1", /* rol */ - "1", /* ror */ - "1", /* sbc */ - "1", /* sbci */ - "2", /* sbi */ - "1-3", /* sbic */ - "1-3", /* sbis */ - "2", /* sbiw */ - "1", /* sbr */ - "1-3", /* sbrc */ - "1-3", /* sbrs */ - "1", /* sec */ - "1", /* seh */ - "1", /* sei */ - "1", /* sen */ - "1", /* ser */ - "1", /* ses */ - "1", /* set */ - "1", /* sev */ - "1", /* sez */ - "1", /* sleep */ - "-", /* spm */ - "2", /* st */ - "2", /* st */ - "2", /* st */ - "2", /* st */ - "2", /* st */ - "2", /* st */ - "2", /* std */ - "2", /* st */ - "2", /* st */ - "2", /* st */ - "2", /* std */ - "2", /* sts */ - "1", /* sub */ - "1", /* subi */ - "1", /* swap */ - "1", /* tst */ - "1" /* wdr */ -}; - -/* -adc -add -adiw -and -andi -asr -bclr -bld -brbc -brbs -brcc -brcs -break -breq -brge -brhc -brhs -brid -brie -brlo -brlt -brmi -brne -brpl -brsh -brtc -brts -brvc -brvs -bset -bst -call -cbi -cbr -clc -clh -cli -cln -clr -cls -clt -clv -clz -com -cp -cpc -cpi -cpse -dec -eicall -eijmp -elpm -elpm -elpm -eor -fmul -fmuls -fmulsu -icall -ijmp -in -inc -jmp -ld -ld -ld -ld -ld -ld -ldd -ld -ld -ld -ldd -ldi -lds -lpm -lpm -lpm -lsl -lsr -mov -movw -mul -muls -mulsu -neg -nop -or -ori -out -pop -push -rcall -ret -reti -rjmp -rol -ror -sbc -sbci -sbi -sbic -sbis -sbiw -sbr -sbrc -sbrs -sec -seh -sei -sen -ser -ses -set -sev -sez -sleep -spm -st -st -st -st -st -st -std -st -st -st -std -sts -sub -subi -swap -tst -wdr -*/ diff --git a/src/Options.c b/src/Options.c deleted file mode 100644 index 0b4f1322..00000000 --- a/src/Options.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include -#include - -#include "Globals.h" -#include "IORegisters.h" -#include "Tagfile.h" -#include "Options.h" - -#ifndef AVRDISAS_VERSION -#define AVRDISAS_VERSION "dev" -#endif - -void Options_Default(struct Options *Options) { - Options->Show_Addresses = 0; - Options->Show_Opcodes = 0; - Options->Show_Comments = 1; - Options->Show_Cycles = 0; - Options->Show_PseudoCode = 0; - Options->Filename[0] = 0; - Options->MCU[0] = 0; - Options->Tagfile[0] = 0; - Options->CodeStyle = 1; /* 0 = AVR Instruction Set, 1 = avr-gcc */ - Options->Process_Labels = 1; - Options->Pass = 1; - Options->FlashSize = 0; -} - -int StringStart(const char *String1, const char *String2) { - size_t Length1, Length2; - int MinLen; - - Length1 = strlen(String1); - Length2 = strlen(String2); - if (Length1 < Length2) MinLen = Length1; - else MinLen = Length2; - - return strncmp(String1, String2, MinLen); -} - -void Show_Help(char *ProgramName) { - fprintf(stderr, "%s [Options] [Filename]\n", ProgramName); - fprintf(stderr, "'n' can either be 0 or 1 and means 'off' or 'on':\n"); - fprintf(stderr, " -an Do or don't show addresses\n"); - fprintf(stderr, " -on Do or don't show opcodes\n"); - fprintf(stderr, " -cn Do or don't show comments\n"); - fprintf(stderr, " -qn Do or don't show call cycles\n"); - fprintf(stderr, " -sn Do or don't use avr-gcc codestyle\n"); - fprintf(stderr, " -pn Do or don't include pseodocode\n"); - fprintf(stderr, " -ln Do or don't do jump/call-preprocessing\n"); - fprintf(stderr, " -mMCU Set the MCU for IO-register resolving\n"); - fprintf(stderr, " -tFile Set the tagfile to be used\n"); - fprintf(stderr, " -fSize Set the size of the flash area\n"); - fprintf(stderr, " --help Show this helppage\n"); - fprintf(stderr, " -h Show this helppage\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Example:\n"); - fprintf(stderr, "%s -a0 -o1 -c0 -m2313 -s1 -l1 -ttags.txt -f8192 Myfile.bin\n", ProgramName); - fprintf(stderr, "\n"); - fprintf(stderr, "Version: " AVRDISAS_VERSION "\n"); -} - -int SetVal(char *Argument, char *Destination, char *Description, char Min, char Max) { - int Value; - Value = atoi(Argument); - if ((Value < Min) || (Value > Max)) { - fprintf(stderr, "Invalid argument for '%s': must be between %d and %d.\n", Description, Min, Max); - return 0; - } - *Destination = Value; - return 1; -} - -int SetValInt(const char *Argument, int *Destination, char *Description, int Min, int Max) { - int Value; - Value = atoi(Argument); - if ((Value < Min) || (Value > Max)) { - fprintf(stderr, "Invalid argument for '%s': must be between %d and %d.\n", Description, Min, Max); - return 0; - } - *Destination = Value; - return 1; -} - -int SetMCU(char *Argument, char *Destination) { - strncpy(Destination, Argument, 7); - if (ReadIORegisterFile() == 0) { - fprintf(stderr, "Invalid argument for MCU! Must be one of the following:\n"); - /* List_Supported_MCUs(); */ - return 0; - } - return 1; -} - -char Options_ParseCmdLine(struct Options *Options, int argc, char **argv) { - int i; - char *Argument; - - for (i = 1; i < argc; i++) { - Argument = argv[i]; - - if (StringStart(Argument, "-a") == 0) { - if (SetVal(Argument + 2, &(Options->Show_Addresses), "show addresses", 0, 1) == 0) return 0; - } else if (StringStart(Argument, "-o") == 0) { - if (SetVal(Argument + 2, &(Options->Show_Opcodes), "show opcodes", 0, 1) == 0) return 0; - } else if (StringStart(Argument, "-c") == 0) { - if (SetVal(Argument + 2, &(Options->Show_Comments), "show comments", 0, 1) == 0) return 0; - } else if (StringStart(Argument, "-q") == 0) { - if (SetVal(Argument + 2, &(Options->Show_Cycles), "show cycles", 0, 1) == 0) return 0; - } else if (StringStart(Argument, "-p") == 0) { - if (SetVal(Argument + 2, &(Options->Show_PseudoCode), "show pseudocode", 0, 1) == 0) return 0; - } else if (StringStart(Argument, "-s") == 0) { - if (SetVal(Argument + 2, &(Options->CodeStyle), "codestyle", 0, 2) == 0) return 0; - } else if (StringStart(Argument, "-l") == 0) { - if (SetVal(Argument + 2, &(Options->Process_Labels), "process labels", 0, 1) == 0) return 0; - } else if (StringStart(Argument, "-m") == 0) { - if (SetMCU(Argument + 2, Options->MCU) == 0) return 0; - } else if (StringStart(Argument, "-t") == 0) { - strncpy(Options->Tagfile, Argument + 2, 256); - } else if (StringStart(Argument, "-f") == 0) { - if (SetValInt(Argument + 2, &(Options->FlashSize), "flash size", 32, 1024 * 1024) == 0) return 0; - } else if (StringStart(Argument, "--help") == 0) { - Show_Help(argv[0]); return 0; - } else if (StringStart(Argument, "-h") == 0) { - Show_Help(argv[0]); return 0; - } else { - if (Options->Filename[0] != 0) { - fprintf(stderr, "Filename '%s' was already supplied!\n", Options->Filename); - return 0; - } - strncpy(Options->Filename, Argument, 255); - } - } - - if (Options->Filename[0] == 0) { - fprintf(stderr, "Error: No filename supplied.\n"); - return 0; - } - - if (Options->Tagfile[0] != 0) { - if (!Read_Tagfile(Options->Tagfile)) return 0; - } - - return 1; -} - diff --git a/src/Tagfile.c b/src/Tagfile.c deleted file mode 100644 index 8a79a311..00000000 --- a/src/Tagfile.c +++ /dev/null @@ -1,453 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include -#include -#include - -#include "Tagfile.h" - -struct CodeLabel { - int Address; - char *Text; - char *Comment; -}; - -struct PGMLabel { - int Address; - char Type; - unsigned int Count; - char *Comment; -}; - -struct MemLabel { - int Address; - char Type; - unsigned int Count; - char *Comment; -}; - -static int CodeLabelCount = 0; -static struct CodeLabel *CodeLabels; - -static int PGMLabelCount = 0; -static struct PGMLabel *PGMLabels = NULL; - -static int MemLabelCount = 0; -static struct MemLabel *MemLabels = NULL; - -/* -static void Display_Tagfile() { - int i; - printf("%d code labels:\n", CodeLabelCount); - for (i = 0; i < CodeLabelCount; i++) { - printf("%d: 0x%x = %s\n", i, CodeLabels[i].Address, CodeLabels[i].Text); - } - printf("%d PGM labels:\n", PGMLabelCount); - for (i = 0; i < PGMLabelCount; i++) { - printf("%d: 0x%x = %d * %d\n", i, PGMLabels[i].Address, PGMLabels[i].Count, PGMLabels[i].Type); - } -} -*/ - -static int LineError(const char *Token, const char *Message, int LineNo) { - if ((Token == NULL) || (strlen(Token) == 0)) { - fprintf(stderr, "Error: %s in tagfile, line %d.\n", Message, LineNo); - return 1; - } - return 0; -} - -static int ahtoi(const char *String) { - int Value; - size_t i, l; - if (strlen(String) < 3) return atoi(String); - if ((String[0] != '0') || (String[1] != 'x')) return atoi(String); - String += 2; - Value = 0; - l = strlen(String); - for (i = 0; i < l; i++) { - Value *= 16; - if ((String[i] >= '0') && (String[i] <= '9')) Value += String[i] - '0'; - else if ((String[i] >= 'a') && (String[i] <= 'f')) Value += String[i] - 'a' + 10; - else if ((String[i] >= 'A') && (String[i] <= 'F')) Value += String[i] - 'A' + 10; - else return 0; - } - return Value; -} - -static void Add_LabelTag(int Address, const char *LabelText, const char *LabelComment) { - CodeLabelCount++; - - CodeLabels = (struct CodeLabel*)realloc(CodeLabels, sizeof(struct CodeLabel) * CodeLabelCount); - CodeLabels[CodeLabelCount - 1].Address = Address; - - CodeLabels[CodeLabelCount - 1].Text = (char*)malloc(strlen(LabelText) + 1); - strcpy(CodeLabels[CodeLabelCount - 1].Text, LabelText); - - if (LabelComment != NULL) { - CodeLabels[CodeLabelCount - 1].Comment = (char*)malloc(strlen(LabelComment) + 1); - strcpy(CodeLabels[CodeLabelCount - 1].Comment, LabelComment); - } else { - CodeLabels[CodeLabelCount - 1].Comment = NULL; - } -} - -static void Add_PGM_Tag(int Address, char Type, unsigned int Count, const char *Comment) { - PGMLabelCount++; - - PGMLabels = (struct PGMLabel*)realloc(PGMLabels, sizeof(struct PGMLabel) * PGMLabelCount); - PGMLabels[PGMLabelCount - 1].Address = Address; - PGMLabels[PGMLabelCount - 1].Type = Type; - PGMLabels[PGMLabelCount - 1].Count = Count; - if (Comment != NULL) { - PGMLabels[PGMLabelCount - 1].Comment = (char*)malloc(strlen(Comment) + 1); - strcpy(PGMLabels[PGMLabelCount - 1].Comment, Comment); - } else { - PGMLabels[PGMLabelCount - 1].Comment = NULL; - } -} - -static void Add_Mem_Tag(int Address, char Type, unsigned int Count, const char *Comment) { - MemLabelCount++; - - MemLabels = (struct MemLabel*)realloc(MemLabels, sizeof(struct MemLabel) * MemLabelCount); - MemLabels[MemLabelCount - 1].Address = Address; - MemLabels[MemLabelCount - 1].Type = Type; - MemLabels[MemLabelCount - 1].Count = Count; - if (Comment != NULL) { - MemLabels[MemLabelCount - 1].Comment = (char*)malloc(strlen(Comment) + 1); - strcpy(MemLabels[MemLabelCount - 1].Comment, Comment); - } else { - MemLabels[MemLabelCount - 1].Comment = NULL; - } -} - -static void Tagfile_Readline(char *Line, int LineNo) { - char *Token; - int Address; - char Type, Subtype; - int Count; - - if (Line[0] == '#') return; - if (strlen(Line) <= 1) return; - - Token = strtok(Line, "\t\n"); - if (LineError(Token, "nonempty line", LineNo)) return; - - /* Token now holds an address, determine if hex or dec */ - Address = ahtoi(Token); - - Token = strtok(NULL, "\t\n"); - if (LineError(Token, "no second argument", LineNo)) return; - if (strlen(Token) != 1) { - LineError(NULL, "second argument too long", LineNo); - return; - } - - Type = Token[0]; - Token = strtok(NULL, "\t\n"); - if (LineError(Token, "no third argument", LineNo)) return; - - if (Type == 'L') { - char *LabelName = Token; - Token = strtok(NULL, "\t\n"); - Add_LabelTag(Address, LabelName, Token); - return; - } - - if (LineError(Token, "no fourth argument", LineNo)) return; - Subtype = Token[0]; - - /* Either B(yte), W(ord), A(utoterminated string) or S(tring) */ - switch (Subtype) { - case 'B': Subtype = TYPE_BYTE; break; - case 'W': Subtype = TYPE_WORD; break; - case 'A': Subtype = TYPE_ASTRING; break; - case 'S': Subtype = TYPE_STRING; break; - default : Subtype = 0; - } - if (!Subtype) { - LineError(NULL, "invalid type (expected one of L, B, W, A or S)", LineNo); - return; - } - if ((Type == 'M') && ((Subtype != TYPE_BYTE) && (Subtype != TYPE_WORD))) { - LineError(NULL, "memory labels can only be of type B or W", LineNo); - return; - } - - Token = strtok(NULL, "\t\n"); - Count = ahtoi(Token); - if (Count < 1) { - LineError(NULL, "invalid count given", LineNo); - return; - } - - Token = strtok(NULL, "\t\n"); - if (Type == 'P') { - Add_PGM_Tag(Address, Subtype, Count, Token); - } else if (Type == 'M') { - Add_Mem_Tag(Address, Subtype, Count, Token); - } else { - fprintf(stderr, "Invalid tag type '%c'.\n", Type); - } -} - -static int CodeLabelSort(const void *A, const void *B) { - const struct CodeLabel *X, *Y; - X = (const struct CodeLabel*)A; - Y = (const struct CodeLabel*)B; - if (X->Address == Y->Address) return 0; - if (X->Address < Y->Address) return -1; - return 1; -} - -static int PGMLabelSort(const void *A, const void *B) { - const struct PGMLabel *X, *Y; - X = (const struct PGMLabel*)A; - Y = (const struct PGMLabel*)B; - if (X->Address == Y->Address) return 0; - if (X->Address < Y->Address) return -1; - return 1; -} - -static int MemLabelSort(const void *A, const void *B) { - const struct MemLabel *X, *Y; - X = (const struct MemLabel*)A; - Y = (const struct MemLabel*)B; - if (X->Address == Y->Address) return 0; - if (X->Address < Y->Address) return -1; - return 1; -} - -static void Tagfile_SortLabels() { - qsort(CodeLabels, CodeLabelCount, sizeof(struct CodeLabel), CodeLabelSort); - qsort(PGMLabels, PGMLabelCount, sizeof(struct PGMLabel), PGMLabelSort); - qsort(MemLabels, MemLabelCount, sizeof(struct MemLabel), MemLabelSort); -} - -int Read_Tagfile(const char *Filename) { - FILE *f; - f = fopen(Filename, "r"); - if (!f) { - fprintf(stderr, "Error opening tagfile '%s': %s\n", Filename, strerror(errno)); - return 0; - } - - { - char Buffer[256]; - int LineNo = 1; - while (fgets(Buffer, sizeof(Buffer), f) != NULL) { - Tagfile_Readline(Buffer, LineNo++); - } - } - - fclose(f); - - Tagfile_SortLabels(); - return 1; -} - -int Tagfile_FindLabelAddress(int Address) { - struct CodeLabel Goal; - struct CodeLabel *Result; - Goal.Address = Address; - Result = bsearch(&Goal, CodeLabels, CodeLabelCount, sizeof(struct CodeLabel), CodeLabelSort); - if (Result == NULL) return -1; - return Result - CodeLabels; -} - -char *Tagfile_GetLabel(int TagIndex) { - return CodeLabels[TagIndex].Text; -} - -char *Tagfile_GetLabelComment(int TagIndex) { - return CodeLabels[TagIndex].Comment; -} - -int Tagfile_FindPGMAddress(int Address) { - struct PGMLabel Goal; - struct PGMLabel *Result; - Goal.Address = Address; - Result = bsearch(&Goal, PGMLabels, PGMLabelCount, sizeof(struct PGMLabel), PGMLabelSort); - if (Result == NULL) return -1; - return Result - PGMLabels; -} - -const char* Tagfile_Resolve_Mem_Address(int Address) { - static char Buffer[64]; - int i; - for (i = 0; i < MemLabelCount; i++) { - int Start, End, Size; - Size = 0; - if (MemLabels[i].Address > Address) return NULL; - - Start = MemLabels[i].Address; - switch (MemLabels[i].Type) { - case TYPE_BYTE: Size = 1; break; - case TYPE_WORD: Size = 2; break; - } - End = MemLabels[i].Address + MemLabels[i].Count * Size - 1; - - if ((Address >= Start) && (Address <= End)) { - if (MemLabels[i].Count == 1) { - /* Single variable */ - if (Size == 1) { - strncpy(Buffer, MemLabels[i].Comment, sizeof(Buffer)); - } else { - if ((Address - Start) == 0) { - snprintf(Buffer, sizeof(Buffer), "_lo8(%s)", MemLabels[i].Comment); - } else { - snprintf(Buffer, sizeof(Buffer), "_hi8(%s)", MemLabels[i].Comment); - } - } - } else { - /* Array */ - if (Size == 1) { - snprintf(Buffer, sizeof(Buffer), "%s[%d]", MemLabels[i].Comment, (Address - Start) / 1); - } else { - int HiLo = (Address - Start) % 2; - if (HiLo == 0) { - snprintf(Buffer, sizeof(Buffer), "_lo8(%s[%d])", MemLabels[i].Comment, (Address - Start) / 2); - } else { - snprintf(Buffer, sizeof(Buffer), "_hi8(%s[%d])", MemLabels[i].Comment, (Address - Start) / 2); - } - } - } - return Buffer; - } - } - return NULL; -} - -static int Tagfile_Process_Byte(char *Bitstream, int Position, int ArgumentNo, const char *Label) { - printf(".byte 0x%02x\n", ((unsigned char*)Bitstream)[Position]); - return 1; -} - -static int Tagfile_Process_Word(char *Bitstream, int Position, int ArgumentNo, const char *Label) { - printf(".word 0x%02x%02x\n", ((unsigned char*)Bitstream)[Position + 1], ((unsigned char*)Bitstream)[Position]); - return 2; -} - -static int Tagfile_Process_String(char *Bitstream, int Position, int ArgumentNo, const char *Label) { - int i; - unsigned char c; - unsigned int InString = 0; - - printf("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); - i = 0; - while ((c = ((unsigned char*)Bitstream)[Position + i])) { - if ((c >= 32) && (c <= 127)) { - if (!InString) printf(".ascii \""); - printf("%c", c); - InString = 1; - } else { - if (InString) printf("\"\n"); - printf(".byte 0x%02x\n", c); - InString = 0; - } - i++; - } - if (InString) printf("\\0\"\n"); - else printf(".byte 0x00\n"); - - printf("\n"); - return i + 1; -} - -static void Sanitize_String(char *String) { - size_t i; - size_t l = strlen(String); - for (i = 0; i < l; i++) { - if (!(((String[i] >= 'a') && (String[i] <= 'z')) || - (((String[i] >= 'A') && (String[i] <= 'Z'))) || - (((String[i] >= '0') && (String[i] <= '9'))))) { - String[i] = '_'; - } - } -} - -int Tagfile_Process_Data(char *Bitstream, int Position) { - int i; - int BytesAdvanced; - int Index; - int (*ProcessingFunction)(char*, int, int, const char*) = NULL; - char Buffer[32]; - Index = Tagfile_FindPGMAddress(Position); - if (Index == -1) return 0; - - switch (PGMLabels[Index].Type) { - case TYPE_BYTE: ProcessingFunction = Tagfile_Process_Byte; break; - case TYPE_WORD: ProcessingFunction = Tagfile_Process_Word; break; - case TYPE_ASTRING: ProcessingFunction = Tagfile_Process_String; break; - case TYPE_STRING: ProcessingFunction = Tagfile_Process_String; break; - } - - printf("; Inline PGM data: %d ", PGMLabels[Index].Count); - switch (PGMLabels[Index].Type) { - case TYPE_BYTE: printf("byte"); break; - case TYPE_WORD: printf("word"); break; - case TYPE_ASTRING: printf("autoaligned string"); break; - case TYPE_STRING: printf("string"); break; - } - if (PGMLabels[Index].Count != 1) printf("s"); - printf(" starting at 0x%x", Position); - - if (PGMLabels[Index].Comment != NULL) { - printf(" (%s)", PGMLabels[Index].Comment); - } - printf("\n"); - - if ((PGMLabels[Index].Type == TYPE_ASTRING) || (PGMLabels[Index].Type == TYPE_STRING)) { - if (PGMLabels[Index].Comment != NULL) { - snprintf(Buffer, sizeof(Buffer), "%x_%s", Position, PGMLabels[Index].Comment); - Sanitize_String(Buffer); - } else { - snprintf(Buffer, sizeof(Buffer), "%x", Position); - } - } - - BytesAdvanced = 0; - for (i = 0; i < PGMLabels[Index].Count; i++) { - BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, i, Buffer); - } - - if (PGMLabels[Index].Type == TYPE_ASTRING) { - /* Autoaligned string */ - if ((BytesAdvanced % 2) != 0) { - /* Not yet aligned correctly */ - if (Bitstream[Position + BytesAdvanced] != 0x00) fprintf(stderr, "Warning in autoalignment: expected zero but got 0x%0x padding. Ignored.\n", ((unsigned char*)Bitstream)[Position + BytesAdvanced]); - printf(".byte 0x%02x ; String Autoalignment\n", ((unsigned char*)Bitstream)[Position + BytesAdvanced]); - BytesAdvanced++; - } - } - - printf("\n"); - return BytesAdvanced; -} - diff --git a/src/avrdisas.c b/src/avrdisas.c deleted file mode 100644 index c4e3519f..00000000 --- a/src/avrdisas.c +++ /dev/null @@ -1,587 +0,0 @@ -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "Globals.h" -#include "Callbacks_Assembly.h" -#include "Callbacks_PseudoCode.h" -#include "Options.h" -#include "JumpCall.h" -#include "IORegisters.h" -#include "MNemonics.h" -#include "Tagfile.h" - -#define READ_BUFFER 131072 /* 128 kB */ - -static int Number_Opcodes = 0; -static struct Opcode Opcodes[256]; -static int Registers[256]; - -struct Options Options; -static char Code_Line[256]; -static char Comment_Line[256]; -static char After_Code_Line[256]; - -void Display_Registers() { - int i; - printf("Register dump:\n"); - for (i = 0; i < 256; i++) { - if (Registers[i] != 0) { - printf("Registers[%3d] '%c': %d = 0x%x\n", i, i, Registers[i], Registers[i]); - } - } - printf("End of register dump.\n"); -} - -int Compare_Opcode(char *Bitstream, char *Bitmask) { - size_t i; - char Bit; - - for (i = 0; i < strlen(Bitmask); i++) { - if ((Bitmask[i] != 'x') && (Bitmask[i] != '1') && (Bitmask[i] != '0')) { - fprintf(stderr, "Invalid Bitmask!\n"); - return 0; - } - - if (Bitmask[i] == 'x') continue; /* Ignore character */ - /* Retrieve the i-th Bit of Bitstream */ - Bit = (Bitstream[i / 8] >> (7 - (i % 8))) & 1; -/* printf("Bit %d is %d [should be %c]\n",i,Bit,Bitmask[i]); */ - if ((Bitmask[i] == '1') && (Bit == 1)) continue; - if ((Bitmask[i] == '0') && (Bit == 0)) continue; - return 0; /* No match */ - } - return 1; /* Match */ -} - -void Register_Opcode(void (*Callback)(char*, int, int), const char *New_Opcode_String, int New_MNemonic) { - Number_Opcodes++; - Opcodes[Number_Opcodes-1].Opcode_String = malloc(strlen(New_Opcode_String) + 1); - strcpy(Opcodes[Number_Opcodes-1].Opcode_String, New_Opcode_String); - Opcodes[Number_Opcodes-1].MNemonic = New_MNemonic; - Opcodes[Number_Opcodes-1].Callback = Callback; -} - -void Supersede_Opcode(void (*Callback)(char*, int, int), int New_MNemonic) { - int i; - for (i = 0; i < Number_Opcodes; i++) { - if (Opcodes[i].MNemonic == New_MNemonic) { - /* Supersede callback */ - Opcodes[i].Callback = Callback; - return; - } - } - fprintf(stderr, "Error: No callback to supersede opcode %d found (%s).\n", New_MNemonic, MNemonic[New_MNemonic]); -} - -int Get_Bitmask_Length(char *Bitmask) { - int Length = 0; - size_t i; - for (i = 0; i < strlen(Bitmask); i++) { - if (Bitmask[i] != ' ') Length++; - } - return Length; -} - -void Clear_Registers() { - int i; - for (i = 0; i < 256; i++) Registers[i] = 0; -} - -char Get_From_Bitmask(char *Bitmask, int Byte, int Bit) { - size_t i; - int Cnt = 0; - int GetBit; - GetBit = (Byte * 8) + Bit; - for (i = 0; i < strlen(Bitmask); i++) { - if (Bitmask[i] != ' ') { - if (Cnt == GetBit) return Bitmask[i]; - Cnt++; - } - } - return '?'; -} - -void Display_Binary(char *Bitstream, int Count) { - int i, j; - for (i = 0; i < Count; i++) { - for (j = 7; j >= 0; j--) { - if ((Bitstream[i] & (1 << j)) != 0) printf("1"); - else printf("0"); - if (j == 4) printf(" "); - } - printf(" "); - if ((((i + 1) % 2) == 0) && (i != 0)) printf(" "); - } - printf("\n"); -} - - -int Match_Opcode(char *Bitmask, char *Bitstream) { - int i; - int Length; - int Byte_Mask, Bit_Mask; - int Byte_Stream, Bit_Stream; - char Mask_Val, Stream_Val; - - Clear_Registers(); - Length = Get_Bitmask_Length(Bitmask); - - for (i = 0; i < Length; i++) { - Byte_Mask = i / 8; - Bit_Mask = i % 8; - - Byte_Stream = i / 8; - Byte_Stream ^= 1; /* Invert last bit */ - Bit_Stream = 7 - (i % 8); - - Mask_Val = Get_From_Bitmask(Bitmask, Byte_Mask, Bit_Mask); - Stream_Val = (Bitstream[Byte_Stream] >> Bit_Stream) & 0x01; - -/* printf("Extracting Bit %2d: Maske = (%d, %d) [%c], Stream = (%d, %d) [%d] ",i,Byte_Mask,Bit_Mask,Mask_Val,Byte_Stream,Bit_Stream,Stream_Val); */ - if ((Mask_Val == '0') || (Mask_Val == '1')) { - /* This Bit is a identification Bit */ - if (Mask_Val == '0') { - if (Stream_Val == 1) { -/* printf("\nMatch failed.\n");*/ - return 0; - } - } else { - if (Stream_Val == 0) { -/* printf("\nMatch failed.\n");*/ - return 0; - } - } - } else { - /* This Bit is a register Bit, set in appropriate place */ - Registers[(int)Mask_Val] <<= 1; - Registers[(int)Mask_Val] |= Stream_Val; -/* printf("-> %d Stored [%x]",Stream_Val,Registers[(int)Mask_Val]); */ - } -/* printf("\n"); */ - } - return 1; -} - -int Get_Next_Opcode(char *Bitstream) { - int i; - for (i = 0; i < Number_Opcodes; i++) { - if (Match_Opcode(Opcodes[i].Opcode_String, Bitstream) == 1) { - return i; - } - } - return -1; -} - -void Disassemble(char *Filename) { - FILE *f; - char Bitstream[READ_BUFFER]; - int Read; - int Pos; - int Opcode; - int i; - -#ifndef DOS_BASED_OS - f = fopen(Filename, "r"); -#else - f = fopen(Filename, "rb"); -#endif - if (!f) { - fprintf(stderr, "Error opening file '%s' for disassembly: %s\n", Filename, strerror(errno)); - return; - } - - if (Options.Show_PseudoCode == 1) { - printf("#include \n"); - printf("\n"); - printf("/* Disassembly of %s (pseudocode) */\n", Filename); - printf("\n"); - printf("int r0, r1, r2, r3, r4, r5, r6, r7, r8, r9;\n"); - printf("int r10, r11, r12, r13, r14, r15, r16, r17, r18, r19;\n"); - printf("int r20, r21, r22, r23, r24, r25, r26, r27, r28, r29;\n"); - printf("int r30, r31, r32;\n"); - printf("\n"); - printf("int main(int argc, char **argv) {\n"); - } else { - if (Options.CodeStyle == CODESTYLE_AVRGCC) { - printf("; Disassembly of %s (avr-gcc style)\n", Filename); - } else { - printf("; Disassembly of %s (AVR instruction set style)\n", Filename); - } - printf("\n"); - } - - Read = fread(Bitstream, 1, READ_BUFFER, f); - Options.Pass = 1; - Pos = 0; - - if ((Options.Process_Labels == 1) || ((!Options.Show_PseudoCode) && (Options.CodeStyle == CODESTYLE_AVRGCC))) { - /* Preprocess to gather jump labels or to gain knowledge about registers which are being used */ - while (Pos < Read) { - Opcode = Get_Next_Opcode(Bitstream + Pos); - if (Opcode == -1) { - Pos += 2; - } else { - Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); - Pos += Get_Bitmask_Length(Opcodes[Opcode].Opcode_String) / 8; - } - } - Enumerate_Labels(); - Options.Pass = 2; - Pos = 0; - } - - if (Options.CodeStyle == CODESTYLE_AVRGCC) { - Emit_Used_IO_Registers(); - printf(".text\n"); - printf("main:\n"); - } - - while (Pos < Read) { - int Added; - - /* Check if this is actually code or maybe only data from tagfile */ - Added = Tagfile_Process_Data(Bitstream, Pos); - if (Added != 0) { - /* Data was added */ - Pos += Added; - continue; - } - - Opcode = Get_Next_Opcode(Bitstream + Pos); - if (Opcode != -1) { - Code_Line[0] = 0; - Comment_Line[0] = 0; - After_Code_Line[0] = 0; - Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); - - if (Options.Process_Labels) { - Print_JumpCalls(Pos); - } - - if (Options.Show_Addresses) printf("%4x: ", Pos); - if (Options.Show_Cycles) { - const char *Cycle = Cycles[Opcodes[Opcode].MNemonic]; - if (!Cycle) printf(" "); - else printf("[%-3s] ", Cycle); - } - - if (Options.Show_Opcodes) { - /* Now display the Opcode */ - for (i = 0; i < (Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8; i++) { - printf("%02x ", (unsigned char)(Bitstream[Pos+i])); - } - printf(" "); - /* Missing spaces */ - for (i = 0; i < 5 - ((Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8); i++) { - printf(" "); - } - } - - if (Code_Line[0] == 0) { - /* No code was generated? */ - printf("; - Not implemented opcode: %d -\n", Opcodes[Opcode].MNemonic); - } else { - if ((Comment_Line[0] == 0) || (!Options.Show_Comments)) { - /* No comment */ - printf("%s\n", Code_Line); - } else { - /* Comment available */ - if (!Options.Show_PseudoCode) { - printf("%-23s ; %s\n", Code_Line, Comment_Line); - } else { - printf("%-35s ; %s\n", Code_Line, Comment_Line); - } - } - } - printf("%s", After_Code_Line); - - Pos += Get_Bitmask_Length(Opcodes[Opcode].Opcode_String) / 8; - } else { - printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x (%d). Disassembler skipped two bytes.\n", ((unsigned char*)Bitstream)[Pos + 1], ((unsigned char *)Bitstream)[Pos], Pos, Pos); - Pos += 2; - } - } - fclose(f); - - if (Options.Show_PseudoCode) { - printf("}\n"); - printf("\n"); - } -} - -void Display_Opcodes() { - unsigned int i; - printf("%d opcodes registered:\n", Number_Opcodes); - for (i = 0; i < Number_Opcodes; i++) { - /* This invokes UB as a function pointer is converted to void* - beware */ - printf("%3d: '%-80s' -> %p\n", i, Opcodes[i].Opcode_String, (void*)Opcodes[i].Callback); - } -} - -int Get_Specifity(char *Opcode) { - size_t i; - int Specifity = 0; - for (i = 0; i < strlen(Opcode); i++) { - if ((Opcode[i] == '0') || (Opcode[i] == '1')) Specifity++; - } - return Specifity; -} - -int Comparison(const void *Element1, const void *Element2) { - struct Opcode *OC1, *OC2; - int SP1, SP2; - OC1 = (struct Opcode*)Element1; - OC2 = (struct Opcode*)Element2; - SP1 = Get_Specifity(OC1->Opcode_String); - SP2 = Get_Specifity(OC2->Opcode_String); - if (SP1 < SP2) return 1; - else if (SP2 == SP1) return 0; - return -1; -} - -int main(int argc, char **argv) { - Options_Default(&Options); - if (!Options_ParseCmdLine(&Options, argc, argv)) return 1; - - Activate_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &Options); - Activate_PC_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &Options); - Register_Opcode(adc_Callback, "0001 11rd dddd rrrr", OPCODE_adc); - Register_Opcode(add_Callback, "0000 11rd dddd rrrr", OPCODE_add); - Register_Opcode(adiw_Callback, "1001 0110 KKdd KKKK", OPCODE_adiw); - Register_Opcode(and_Callback, "0010 00rd dddd rrrr", OPCODE_and); - Register_Opcode(andi_Callback, "0111 KKKK dddd KKKK", OPCODE_andi); - Register_Opcode(asr_Callback, "1001 010d dddd 0101", OPCODE_asr); - Register_Opcode(bclr_Callback, "1001 0100 1sss 1000", OPCODE_bclr); - Register_Opcode(bld_Callback, "1111 100d dddd 0bbb", OPCODE_bld); - Register_Opcode(brbc_Callback, "1111 01kk kkkk ksss", OPCODE_brbc); - Register_Opcode(brbs_Callback, "1111 00kk kkkk ksss", OPCODE_brbs); - Register_Opcode(brcc_Callback, "1111 01kk kkkk k000", OPCODE_brcc); - Register_Opcode(brcs_Callback, "1111 00kk kkkk k000", OPCODE_brcs); - Register_Opcode(break_Callback, "1001 0101 1001 1000", OPCODE_break); - Register_Opcode(breq_Callback, "1111 00kk kkkk k001", OPCODE_breq); - Register_Opcode(brge_Callback, "1111 01kk kkkk k100", OPCODE_brge); - Register_Opcode(brhc_Callback, "1111 01kk kkkk k101", OPCODE_brhc); - Register_Opcode(brhs_Callback, "1111 00kk kkkk k101", OPCODE_brhs); - Register_Opcode(brid_Callback, "1111 01kk kkkk k111", OPCODE_brid); - Register_Opcode(brie_Callback, "1111 00kk kkkk k111", OPCODE_brie); - Register_Opcode(brlo_Callback, "1111 00kk kkkk k000", OPCODE_brlo); - Register_Opcode(brlt_Callback, "1111 00kk kkkk k100", OPCODE_brlt); - Register_Opcode(brmi_Callback, "1111 00kk kkkk k010", OPCODE_brmi); - Register_Opcode(brne_Callback, "1111 01kk kkkk k001", OPCODE_brne); - Register_Opcode(brpl_Callback, "1111 01kk kkkk k010", OPCODE_brpl); - Register_Opcode(brsh_Callback, "1111 01kk kkkk k000", OPCODE_brsh); - Register_Opcode(brtc_Callback, "1111 01kk kkkk k110", OPCODE_brtc); - Register_Opcode(brts_Callback, "1111 00kk kkkk k110", OPCODE_brts); - Register_Opcode(brvc_Callback, "1111 01kk kkkk k011", OPCODE_brvc); - Register_Opcode(brvs_Callback, "1111 00kk kkkk k011", OPCODE_brvs); - Register_Opcode(bset_Callback, "1001 0100 0sss 1000", OPCODE_bset); - Register_Opcode(bst_Callback, "1111 101d dddd 0bbb", OPCODE_bst); - Register_Opcode(call_Callback, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call); - Register_Opcode(cbi_Callback, "1001 1000 AAAA Abbb", OPCODE_cbi); - Register_Opcode(clc_Callback, "1001 0100 1000 1000", OPCODE_clc); - Register_Opcode(clh_Callback, "1001 0100 1101 1000", OPCODE_clh); - Register_Opcode(cli_Callback, "1001 0100 1111 1000", OPCODE_cli); - Register_Opcode(cln_Callback, "1001 0100 1010 1000", OPCODE_cln); -/* Register_Opcode(clr_Callback, "0010 01dd dddd dddd", OPCODE_clr); */ /* Implied by eor */ - Register_Opcode(cls_Callback, "1001 0100 1100 1000", OPCODE_cls); - Register_Opcode(clt_Callback, "1001 0100 1110 1000", OPCODE_clt); - Register_Opcode(clv_Callback, "1001 0100 1011 1000", OPCODE_clv); - Register_Opcode(clz_Callback, "1001 0100 1001 1000", OPCODE_clz); - Register_Opcode(com_Callback, "1001 010d dddd 0000", OPCODE_com); - Register_Opcode(cp_Callback, "0001 01rd dddd rrrr", OPCODE_cp); - Register_Opcode(cpc_Callback, "0000 01rd dddd rrrr", OPCODE_cpc); - Register_Opcode(cpi_Callback, "0011 KKKK dddd KKKK", OPCODE_cpi); - Register_Opcode(cpse_Callback, "0001 00rd dddd rrrr", OPCODE_cpse); - Register_Opcode(dec_Callback, "1001 010d dddd 1010", OPCODE_dec); - Register_Opcode(eicall_Callback, "1001 0101 0001 1001", OPCODE_eicall); - Register_Opcode(eijmp_Callback, "1001 0100 0001 1001", OPCODE_eijmp); - Register_Opcode(elpm1_Callback, "1001 0101 1101 1000", OPCODE_elpm_1); - Register_Opcode(elpm2_Callback, "1001 000d dddd 0110", OPCODE_elpm_2); - Register_Opcode(elpm3_Callback, "1001 000d dddd 0111", OPCODE_elpm_3); - Register_Opcode(eor_Callback, "0010 01rd dddd rrrr", OPCODE_eor); - Register_Opcode(fmul_Callback, "0000 0011 0ddd 1rrr", OPCODE_fmul); - Register_Opcode(fmuls_Callback, "0000 0011 1ddd 0rrr", OPCODE_fmuls); - Register_Opcode(fmulsu_Callback, "0000 0011 1ddd 1rrr", OPCODE_fmulsu); - Register_Opcode(icall_Callback, "1001 0101 0000 1001", OPCODE_icall); - Register_Opcode(ijmp_Callback, "1001 0100 0000 1001", OPCODE_ijmp); - Register_Opcode(in_Callback, "1011 0AAd dddd AAAA", OPCODE_in); - Register_Opcode(inc_Callback, "1001 010d dddd 0011", OPCODE_inc); - Register_Opcode(jmp_Callback, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp); - Register_Opcode(ld1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); - Register_Opcode(ld2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); - Register_Opcode(ld3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); - Register_Opcode(ldy1_Callback, "1000 000d dddd 1000", OPCODE_ld_4); - Register_Opcode(ldy2_Callback, "1001 000d dddd 1001", OPCODE_ld_5); - Register_Opcode(ldy3_Callback, "1001 000d dddd 1010", OPCODE_ld_6); - Register_Opcode(ldy4_Callback, "10q0 qq0d dddd 1qqq", OPCODE_ldd_1); - Register_Opcode(ldz1_Callback, "1000 000d dddd 0000", OPCODE_ld_7); - Register_Opcode(ldz2_Callback, "1001 000d dddd 0001", OPCODE_ld_8); - Register_Opcode(ldz3_Callback, "1001 000d dddd 0010", OPCODE_ld_9); - Register_Opcode(ldz4_Callback, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2); - Register_Opcode(ldi_Callback, "1110 KKKK dddd KKKK", OPCODE_ldi); - Register_Opcode(lds_Callback, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds); - Register_Opcode(lpm1_Callback, "1001 0101 1100 1000", OPCODE_lpm_1); - Register_Opcode(lpm2_Callback, "1001 000d dddd 0100", OPCODE_lpm_2); - Register_Opcode(lpm3_Callback, "1001 000d dddd 0101", OPCODE_lpm_3); -/* Register_Opcode(lsl_Callback, "0000 11dd dddd dddd", OPCODE_lsl); */ /* Implied by add */ - Register_Opcode(lsr_Callback, "1001 010d dddd 0110", OPCODE_lsr); - Register_Opcode(mov_Callback, "0010 11rd dddd rrrr", OPCODE_mov); - Register_Opcode(movw_Callback, "0000 0001 dddd rrrr", OPCODE_movw); - Register_Opcode(mul_Callback, "1001 11rd dddd rrrr", OPCODE_mul); - Register_Opcode(muls_Callback, "0000 0010 dddd rrrr", OPCODE_muls); - Register_Opcode(mulsu_Callback, "0000 0011 0ddd 0rrr", OPCODE_mulsu); - Register_Opcode(neg_Callback, "1001 010d dddd 0001", OPCODE_neg); - Register_Opcode(nop_Callback, "0000 0000 0000 0000", OPCODE_nop); - Register_Opcode(or_Callback, "0010 10rd dddd rrrr", OPCODE_or); - Register_Opcode(ori_Callback, "0110 KKKK dddd KKKK", OPCODE_ori); - Register_Opcode(out_Callback, "1011 1AAr rrrr AAAA", OPCODE_out); - Register_Opcode(pop_Callback, "1001 000d dddd 1111", OPCODE_pop); - Register_Opcode(push_Callback, "1001 001d dddd 1111", OPCODE_push); - Register_Opcode(rcall_Callback, "1101 kkkk kkkk kkkk", OPCODE_rcall); - Register_Opcode(ret_Callback, "1001 0101 0000 1000", OPCODE_ret); - Register_Opcode(reti_Callback, "1001 0101 0001 1000", OPCODE_reti); - Register_Opcode(rjmp_Callback, "1100 kkkk kkkk kkkk", OPCODE_rjmp); -/* Register_Opcode(rol_Callback, "0001 11dd dddd dddd", OPCODE_rol); */ /* Implied by adc */ - Register_Opcode(ror_Callback, "1001 010d dddd 0111", OPCODE_ror); - Register_Opcode(sbc_Callback, "0000 10rd dddd rrrr", OPCODE_sbc); - Register_Opcode(sbci_Callback, "0100 KKKK dddd KKKK", OPCODE_sbci); - Register_Opcode(sbi_Callback, "1001 1010 AAAA Abbb", OPCODE_sbi); - Register_Opcode(sbic_Callback, "1001 1001 AAAA Abbb", OPCODE_sbic); - Register_Opcode(sbis_Callback, "1001 1011 AAAA Abbb", OPCODE_sbis); - Register_Opcode(sbiw_Callback, "1001 0111 KKdd KKKK", OPCODE_sbiw); - Register_Opcode(sbr_Callback, "0110 KKKK dddd KKKK", OPCODE_sbr); - Register_Opcode(sbrc_Callback, "1111 110r rrrr 0bbb", OPCODE_sbrc); - Register_Opcode(sbrs_Callback, "1111 111r rrrr 0bbb", OPCODE_sbrs); - Register_Opcode(sec_Callback, "1001 0100 0000 1000", OPCODE_sec); - Register_Opcode(seh_Callback, "1001 0100 0101 1000", OPCODE_seh); - Register_Opcode(sei_Callback, "1001 0100 0111 1000", OPCODE_sei); - Register_Opcode(sen_Callback, "1001 0100 0010 1000", OPCODE_sen); - Register_Opcode(ser_Callback, "1110 1111 dddd 1111", OPCODE_ser); - Register_Opcode(ses_Callback, "1001 0100 0100 1000", OPCODE_ses); - Register_Opcode(set_Callback, "1001 0100 0110 1000", OPCODE_set); - Register_Opcode(sev_Callback, "1001 0100 0011 1000", OPCODE_sev); - Register_Opcode(sez_Callback, "1001 0100 0001 1000", OPCODE_sez); - Register_Opcode(sleep_Callback, "1001 0101 1000 1000", OPCODE_sleep); - Register_Opcode(spm_Callback, "1001 0101 1110 1000", OPCODE_spm); - Register_Opcode(st1_Callback, "1001 001r rrrr 1100", OPCODE_st_1); - Register_Opcode(st2_Callback, "1001 001r rrrr 1101", OPCODE_st_2); - Register_Opcode(st3_Callback, "1001 001r rrrr 1110", OPCODE_st_3); - Register_Opcode(sty1_Callback, "1000 001r rrrr 1000", OPCODE_st_4); - Register_Opcode(sty2_Callback, "1001 001r rrrr 1001", OPCODE_st_5); - Register_Opcode(sty3_Callback, "1001 001r rrrr 1010", OPCODE_st_6); - Register_Opcode(sty4_Callback, "10q0 qq1r rrrr 1qqq", OPCODE_std_1); - Register_Opcode(stz1_Callback, "1000 001r rrrr 0000", OPCODE_st_7); - Register_Opcode(stz2_Callback, "1001 001r rrrr 0001", OPCODE_st_8); - Register_Opcode(stz3_Callback, "1001 001r rrrr 0010", OPCODE_st_9); - Register_Opcode(stz4_Callback, "10q0 qq1r rrrr 0qqq", OPCODE_std_2); - Register_Opcode(sts_Callback, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts); - Register_Opcode(sub_Callback, "0001 10rd dddd rrrr", OPCODE_sub); - Register_Opcode(subi_Callback, "0101 KKKK dddd KKKK", OPCODE_subi); - Register_Opcode(swap_Callback, "1001 010d dddd 0010", OPCODE_swap); -/* Register_Opcode(tst_Callback, "0010 00dd dddd dddd", OPCODE_tst); */ /* Implied by and */ - Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); - - if (Options.Show_PseudoCode) { - Supersede_Opcode(adc_Callback_PC, OPCODE_adc); - Supersede_Opcode(add_Callback_PC, OPCODE_add); - Supersede_Opcode(sub_Callback_PC, OPCODE_sub); - Supersede_Opcode(sbc_Callback_PC, OPCODE_sbc); - Supersede_Opcode(mov_Callback_PC, OPCODE_mov); - Supersede_Opcode(brcc_Callback_PC, OPCODE_brcc); - Supersede_Opcode(brcs_Callback_PC, OPCODE_brcs); - Supersede_Opcode(breq_Callback_PC, OPCODE_breq); - Supersede_Opcode(brge_Callback_PC, OPCODE_brge); - Supersede_Opcode(brhc_Callback_PC, OPCODE_brhc); - Supersede_Opcode(brhs_Callback_PC, OPCODE_brhs); - Supersede_Opcode(brid_Callback_PC, OPCODE_brid); - Supersede_Opcode(brie_Callback_PC, OPCODE_brie); - Supersede_Opcode(brlo_Callback_PC, OPCODE_brlo); - Supersede_Opcode(brlt_Callback_PC, OPCODE_brlt); - Supersede_Opcode(brmi_Callback_PC, OPCODE_brmi); - Supersede_Opcode(brne_Callback_PC, OPCODE_brne); - Supersede_Opcode(brpl_Callback_PC, OPCODE_brpl); - Supersede_Opcode(brsh_Callback_PC, OPCODE_brsh); - Supersede_Opcode(brtc_Callback_PC, OPCODE_brtc); - Supersede_Opcode(brts_Callback_PC, OPCODE_brts); - Supersede_Opcode(brvc_Callback_PC, OPCODE_brvc); - Supersede_Opcode(brvs_Callback_PC, OPCODE_brvs); - Supersede_Opcode(out_Callback_PC, OPCODE_out); - Supersede_Opcode(in_Callback_PC, OPCODE_in); - Supersede_Opcode(cli_Callback_PC, OPCODE_cli); - Supersede_Opcode(sei_Callback_PC, OPCODE_sei); - Supersede_Opcode(ret_Callback_PC, OPCODE_ret); - Supersede_Opcode(reti_Callback_PC, OPCODE_reti); - Supersede_Opcode(andi_Callback_PC, OPCODE_andi); - Supersede_Opcode(subi_Callback_PC, OPCODE_subi); - Supersede_Opcode(sbci_Callback_PC, OPCODE_sbci); - Supersede_Opcode(sbr_Callback_PC, OPCODE_sbr); - Supersede_Opcode(ori_Callback_PC, OPCODE_ori); - Supersede_Opcode(ldi_Callback_PC, OPCODE_ldi); - Supersede_Opcode(lds_Callback_PC, OPCODE_lds); - Supersede_Opcode(sts_Callback_PC, OPCODE_sts); - Supersede_Opcode(call_Callback_PC, OPCODE_call); - Supersede_Opcode(rcall_Callback_PC, OPCODE_rcall); - Supersede_Opcode(ror_Callback_PC, OPCODE_ror); - Supersede_Opcode(lsr_Callback_PC, OPCODE_lsr); - Supersede_Opcode(eor_Callback_PC, OPCODE_eor); - Supersede_Opcode(swap_Callback_PC, OPCODE_swap); - Supersede_Opcode(jmp_Callback_PC, OPCODE_jmp); - Supersede_Opcode(rjmp_Callback_PC, OPCODE_rjmp); - Supersede_Opcode(cpi_Callback_PC, OPCODE_cpi); - Supersede_Opcode(asr_Callback_PC, OPCODE_asr); - Supersede_Opcode(inc_Callback_PC, OPCODE_inc); - Supersede_Opcode(dec_Callback_PC, OPCODE_dec); - Supersede_Opcode(cp_Callback_PC, OPCODE_cp); - Supersede_Opcode(cpc_Callback_PC, OPCODE_cpc); - Supersede_Opcode(cpse_Callback_PC, OPCODE_cpse); - Supersede_Opcode(and_Callback_PC, OPCODE_and); - Supersede_Opcode(or_Callback_PC, OPCODE_or); - Supersede_Opcode(mul_Callback_PC, OPCODE_mul); - Supersede_Opcode(sbi_Callback_PC, OPCODE_sbi); - Supersede_Opcode(sbis_Callback_PC, OPCODE_sbis); - Supersede_Opcode(sbic_Callback_PC, OPCODE_sbic); - Supersede_Opcode(cbi_Callback_PC, OPCODE_cbi); - Supersede_Opcode(ser_Callback_PC, OPCODE_ser); - Supersede_Opcode(movw_Callback_PC, OPCODE_movw); - Supersede_Opcode(adiw_Callback_PC, OPCODE_adiw); - Supersede_Opcode(lpm1_Callback_PC, OPCODE_lpm_1); - Supersede_Opcode(st2_Callback_PC, OPCODE_st_2); - } - - qsort(Opcodes, Number_Opcodes, sizeof(struct Opcode), Comparison); - - Disassemble(Options.Filename); - return 0; -} - diff --git a/src/disasm.c b/src/disasm.c new file mode 100644 index 00000000..3f097803 --- /dev/null +++ b/src/disasm.c @@ -0,0 +1,625 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "disasm_globals.h" +#include "disasm_callbacks_assembly.h" +#include "disasm_callbacks_pseudocode.h" +#include "disasm_options.h" +#include "disasm_jumpcall.h" +#include "disasm_ioregisters.h" +#include "disasm_mnemonics.h" +#include "disasm_tagfile.h" + +#define READ_BUFFER 131072 // 128 kB + +static int Number_Opcodes = 0; +static struct Opcode Opcodes[256]; +static int Registers[256]; + +struct Options Options; +static char Code_Line[256]; +static char Comment_Line[256]; +static char After_Code_Line[256]; + +void Display_Registers() { + int i; + + printf("Register dump:\n"); + for(i = 0; i < 256; i++) { + if(Registers[i] != 0) { + printf("Registers[%3d] '%c': %d = 0x%x\n", i, i, Registers[i], Registers[i]); + } + } + printf("End of register dump.\n"); +} + +int Compare_Opcode(char *Bitstream, char *Bitmask) { + size_t i; + char Bit; + + for(i = 0; i < strlen(Bitmask); i++) { + if((Bitmask[i] != 'x') && (Bitmask[i] != '1') && (Bitmask[i] != '0')) { + fprintf(stderr, "Invalid Bitmask!\n"); + return 0; + } + + if(Bitmask[i] == 'x') + continue; // Ignore character + // Retrieve the i-th Bit of Bitstream + Bit = (Bitstream[i / 8] >> (7 - (i % 8))) & 1; + + // printf("Bit %d is %d [should be %c]\n",i,Bit,Bitmask[i]); + if((Bitmask[i] == '1') && (Bit == 1)) + continue; + if((Bitmask[i] == '0') && (Bit == 0)) + continue; + return 0; // No match + } + return 1; // Match +} + +void Register_Opcode(void (*Callback)(char *, int, int), const char *New_Opcode_String, int New_MNemonic) { + Number_Opcodes++; + Opcodes[Number_Opcodes - 1].Opcode_String = malloc(strlen(New_Opcode_String) + 1); + strcpy(Opcodes[Number_Opcodes - 1].Opcode_String, New_Opcode_String); + Opcodes[Number_Opcodes - 1].MNemonic = New_MNemonic; + Opcodes[Number_Opcodes - 1].Callback = Callback; +} + +void Supersede_Opcode(void (*Callback)(char *, int, int), int New_MNemonic) { + int i; + + for(i = 0; i < Number_Opcodes; i++) { + if(Opcodes[i].MNemonic == New_MNemonic) { + // Supersede callback + Opcodes[i].Callback = Callback; + return; + } + } + fprintf(stderr, "Error: No callback to supersede opcode %d found (%s).\n", New_MNemonic, MNemonic[New_MNemonic]); +} + +int Get_Bitmask_Length(char *Bitmask) { + int Length = 0; + size_t i; + + for(i = 0; i < strlen(Bitmask); i++) { + if(Bitmask[i] != ' ') + Length++; + } + return Length; +} + +void Clear_Registers() { + int i; + + for(i = 0; i < 256; i++) + Registers[i] = 0; +} + +char Get_From_Bitmask(char *Bitmask, int Byte, int Bit) { + size_t i; + int Cnt = 0; + int GetBit; + + GetBit = (Byte * 8) + Bit; + for(i = 0; i < strlen(Bitmask); i++) { + if(Bitmask[i] != ' ') { + if(Cnt == GetBit) + return Bitmask[i]; + Cnt++; + } + } + return '?'; +} + +void Display_Binary(char *Bitstream, int Count) { + int i, j; + + for(i = 0; i < Count; i++) { + for(j = 7; j >= 0; j--) { + if((Bitstream[i] & (1 << j)) != 0) + printf("1"); + else + printf("0"); + if(j == 4) + printf(" "); + } + printf(" "); + if((((i + 1) % 2) == 0) && (i != 0)) + printf(" "); + } + printf("\n"); +} + +int Match_Opcode(char *Bitmask, char *Bitstream) { + int i; + int Length; + int Byte_Mask, Bit_Mask; + int Byte_Stream, Bit_Stream; + char Mask_Val, Stream_Val; + + Clear_Registers(); + Length = Get_Bitmask_Length(Bitmask); + + for(i = 0; i < Length; i++) { + Byte_Mask = i / 8; + Bit_Mask = i % 8; + + Byte_Stream = i / 8; + Byte_Stream ^= 1; // Invert last bit + Bit_Stream = 7 - (i % 8); + + Mask_Val = Get_From_Bitmask(Bitmask, Byte_Mask, Bit_Mask); + Stream_Val = (Bitstream[Byte_Stream] >> Bit_Stream) & 0x01; + + // printf("Extracting Bit %2d: Maske = (%d, %d) [%c], Stream = (%d, %d) [%d] ", i, Byte_Mask, Bit_Mask, Mask_Val, Byte_Stream, Bit_Stream, Stream_Val); + if((Mask_Val == '0') || (Mask_Val == '1')) { + // This Bit is a identification Bit + if(Mask_Val == '0') { + if(Stream_Val == 1) { + + // printf("\nMatch failed.\n") + return 0; + } + } else { + if(Stream_Val == 0) { + + /*/printf("\nMatch failed.\n") + return 0; + } + } + } else { + // This Bit is a register Bit, set in appropriate place + Registers[(int) Mask_Val] <<= 1; + Registers[(int) Mask_Val] |= Stream_Val; + + // printf("-> %d Stored [%x]",Stream_Val,Registers[(int)Mask_Val]); + } + + // printf("\n"); + } + return 1; +} + +int Get_Next_Opcode(char *Bitstream) { + int i; + + for(i = 0; i < Number_Opcodes; i++) { + if(Match_Opcode(Opcodes[i].Opcode_String, Bitstream) == 1) { + return i; + } + } + return -1; +} + +void Disassemble(char *Filename) { + FILE *f; + char Bitstream[READ_BUFFER]; + int Read; + int Pos; + int Opcode; + int i; + +#ifndef DOS_BASED_OS + f = fopen(Filename, "r"); +#else + f = fopen(Filename, "rb"); +#endif + + if(!f) { + fprintf(stderr, "Error opening file '%s' for disassembly: %s\n", Filename, strerror(errno)); + return; + } + + if(Options.Show_PseudoCode == 1) { + printf("#include \n"); + printf("\n"); + printf("/* Disassembly of %s (pseudocode) */\n", Filename); + printf("\n"); + printf("int r0, r1, r2, r3, r4, r5, r6, r7, r8, r9;\n"); + printf("int r10, r11, r12, r13, r14, r15, r16, r17, r18, r19;\n"); + printf("int r20, r21, r22, r23, r24, r25, r26, r27, r28, r29;\n"); + printf("int r30, r31, r32;\n"); + printf("\n"); + printf("int main(int argc, char **argv) {\n"); + } else { + if(Options.CodeStyle == CODESTYLE_AVRGCC) { + printf("; Disassembly of %s (avr-gcc style)\n", Filename); + } else { + printf("; Disassembly of %s (AVR instruction set style)\n", Filename); + } + printf("\n"); + } + + Read = fread(Bitstream, 1, READ_BUFFER, f); + Options.Pass = 1; + Pos = 0; + + if((Options.Process_Labels == 1) || ((!Options.Show_PseudoCode) && (Options.CodeStyle == CODESTYLE_AVRGCC))) { + // Preprocess to gather jump labels or to gain knowledge about registers which are being used + while(Pos < Read) { + Opcode = Get_Next_Opcode(Bitstream + Pos); + if(Opcode == -1) { + Pos += 2; + } else { + Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); + Pos += Get_Bitmask_Length(Opcodes[Opcode].Opcode_String) / 8; + } + } + Enumerate_Labels(); + Options.Pass = 2; + Pos = 0; + } + + if(Options.CodeStyle == CODESTYLE_AVRGCC) { + Emit_Used_IO_Registers(); + printf(".text\n"); + printf("main:\n"); + } + + while(Pos < Read) { + int Added; + + // Check if this is actually code or maybe only data from tagfile + Added = Tagfile_Process_Data(Bitstream, Pos); + if(Added != 0) { + // Data was added + Pos += Added; + continue; + } + + Opcode = Get_Next_Opcode(Bitstream + Pos); + if(Opcode != -1) { + Code_Line[0] = 0; + Comment_Line[0] = 0; + After_Code_Line[0] = 0; + Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); + + if(Options.Process_Labels) { + Print_JumpCalls(Pos); + } + + if(Options.Show_Addresses) + printf("%4x: ", Pos); + if(Options.Show_Cycles) { + const char *Cycle = Cycles[Opcodes[Opcode].MNemonic]; + + if(!Cycle) + printf(" "); + else + printf("[%-3s] ", Cycle); + } + + if(Options.Show_Opcodes) { + // Now display the Opcode + for(i = 0; i < (Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8; i++) { + printf("%02x ", (unsigned char) (Bitstream[Pos + i])); + } + printf(" "); + // Missing spaces + for(i = 0; i < 5 - ((Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8); i++) { + printf(" "); + } + } + + if(Code_Line[0] == 0) { + // No code was generated? + printf("; - Not implemented opcode: %d -\n", Opcodes[Opcode].MNemonic); + } else { + if((Comment_Line[0] == 0) || (!Options.Show_Comments)) { + // No comment + printf("%s\n", Code_Line); + } else { + // Comment available + if(!Options.Show_PseudoCode) { + printf("%-23s ; %s\n", Code_Line, Comment_Line); + } else { + printf("%-35s ; %s\n", Code_Line, Comment_Line); + } + } + } + printf("%s", After_Code_Line); + + Pos += Get_Bitmask_Length(Opcodes[Opcode].Opcode_String) / 8; + } else { + printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x (%d). Disassembler skipped two bytes.\n", + ((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], Pos, Pos); + Pos += 2; + } + } + fclose(f); + + if(Options.Show_PseudoCode) { + printf("}\n"); + printf("\n"); + } +} + +void Display_Opcodes() { + unsigned int i; + + printf("%d opcodes registered:\n", Number_Opcodes); + for(i = 0; i < Number_Opcodes; i++) { + // This invokes UB as a function pointer is converted to void* - beware + printf("%3d: '%-80s' -> %p\n", i, Opcodes[i].Opcode_String, (void *) Opcodes[i].Callback); + } +} + +int Get_Specifity(char *Opcode) { + size_t i; + int Specifity = 0; + + for(i = 0; i < strlen(Opcode); i++) { + if((Opcode[i] == '0') || (Opcode[i] == '1')) + Specifity++; + } + return Specifity; +} + +int Comparison(const void *Element1, const void *Element2) { + struct Opcode *OC1, *OC2; + int SP1, SP2; + + OC1 = (struct Opcode *) Element1; + OC2 = (struct Opcode *) Element2; + SP1 = Get_Specifity(OC1->Opcode_String); + SP2 = Get_Specifity(OC2->Opcode_String); + if(SP1 < SP2) + return 1; + else if(SP2 == SP1) + return 0; + return -1; +} + +int main(int argc, char **argv) { + Options_Default(&Options); + if(!Options_ParseCmdLine(&Options, argc, argv)) + return 1; + + Activate_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &Options); + Activate_PC_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &Options); + Register_Opcode(adc_Callback, "0001 11rd dddd rrrr", OPCODE_adc); + Register_Opcode(add_Callback, "0000 11rd dddd rrrr", OPCODE_add); + Register_Opcode(adiw_Callback, "1001 0110 KKdd KKKK", OPCODE_adiw); + Register_Opcode(and_Callback, "0010 00rd dddd rrrr", OPCODE_and); + Register_Opcode(andi_Callback, "0111 KKKK dddd KKKK", OPCODE_andi); + Register_Opcode(asr_Callback, "1001 010d dddd 0101", OPCODE_asr); + Register_Opcode(bclr_Callback, "1001 0100 1sss 1000", OPCODE_bclr); + Register_Opcode(bld_Callback, "1111 100d dddd 0bbb", OPCODE_bld); + Register_Opcode(brbc_Callback, "1111 01kk kkkk ksss", OPCODE_brbc); + Register_Opcode(brbs_Callback, "1111 00kk kkkk ksss", OPCODE_brbs); + Register_Opcode(brcc_Callback, "1111 01kk kkkk k000", OPCODE_brcc); + Register_Opcode(brcs_Callback, "1111 00kk kkkk k000", OPCODE_brcs); + Register_Opcode(break_Callback, "1001 0101 1001 1000", OPCODE_break); + Register_Opcode(breq_Callback, "1111 00kk kkkk k001", OPCODE_breq); + Register_Opcode(brge_Callback, "1111 01kk kkkk k100", OPCODE_brge); + Register_Opcode(brhc_Callback, "1111 01kk kkkk k101", OPCODE_brhc); + Register_Opcode(brhs_Callback, "1111 00kk kkkk k101", OPCODE_brhs); + Register_Opcode(brid_Callback, "1111 01kk kkkk k111", OPCODE_brid); + Register_Opcode(brie_Callback, "1111 00kk kkkk k111", OPCODE_brie); + Register_Opcode(brlo_Callback, "1111 00kk kkkk k000", OPCODE_brlo); + Register_Opcode(brlt_Callback, "1111 00kk kkkk k100", OPCODE_brlt); + Register_Opcode(brmi_Callback, "1111 00kk kkkk k010", OPCODE_brmi); + Register_Opcode(brne_Callback, "1111 01kk kkkk k001", OPCODE_brne); + Register_Opcode(brpl_Callback, "1111 01kk kkkk k010", OPCODE_brpl); + Register_Opcode(brsh_Callback, "1111 01kk kkkk k000", OPCODE_brsh); + Register_Opcode(brtc_Callback, "1111 01kk kkkk k110", OPCODE_brtc); + Register_Opcode(brts_Callback, "1111 00kk kkkk k110", OPCODE_brts); + Register_Opcode(brvc_Callback, "1111 01kk kkkk k011", OPCODE_brvc); + Register_Opcode(brvs_Callback, "1111 00kk kkkk k011", OPCODE_brvs); + Register_Opcode(bset_Callback, "1001 0100 0sss 1000", OPCODE_bset); + Register_Opcode(bst_Callback, "1111 101d dddd 0bbb", OPCODE_bst); + Register_Opcode(call_Callback, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call); + Register_Opcode(cbi_Callback, "1001 1000 AAAA Abbb", OPCODE_cbi); + Register_Opcode(clc_Callback, "1001 0100 1000 1000", OPCODE_clc); + Register_Opcode(clh_Callback, "1001 0100 1101 1000", OPCODE_clh); + Register_Opcode(cli_Callback, "1001 0100 1111 1000", OPCODE_cli); + Register_Opcode(cln_Callback, "1001 0100 1010 1000", OPCODE_cln); + + // Register_Opcode(clr_Callback, "0010 01dd dddd dddd", OPCODE_clr); // Implied by eor + Register_Opcode(cls_Callback, "1001 0100 1100 1000", OPCODE_cls); + Register_Opcode(clt_Callback, "1001 0100 1110 1000", OPCODE_clt); + Register_Opcode(clv_Callback, "1001 0100 1011 1000", OPCODE_clv); + Register_Opcode(clz_Callback, "1001 0100 1001 1000", OPCODE_clz); + Register_Opcode(com_Callback, "1001 010d dddd 0000", OPCODE_com); + Register_Opcode(cp_Callback, "0001 01rd dddd rrrr", OPCODE_cp); + Register_Opcode(cpc_Callback, "0000 01rd dddd rrrr", OPCODE_cpc); + Register_Opcode(cpi_Callback, "0011 KKKK dddd KKKK", OPCODE_cpi); + Register_Opcode(cpse_Callback, "0001 00rd dddd rrrr", OPCODE_cpse); + Register_Opcode(dec_Callback, "1001 010d dddd 1010", OPCODE_dec); + Register_Opcode(eicall_Callback, "1001 0101 0001 1001", OPCODE_eicall); + Register_Opcode(eijmp_Callback, "1001 0100 0001 1001", OPCODE_eijmp); + Register_Opcode(elpm1_Callback, "1001 0101 1101 1000", OPCODE_elpm_1); + Register_Opcode(elpm2_Callback, "1001 000d dddd 0110", OPCODE_elpm_2); + Register_Opcode(elpm3_Callback, "1001 000d dddd 0111", OPCODE_elpm_3); + Register_Opcode(eor_Callback, "0010 01rd dddd rrrr", OPCODE_eor); + Register_Opcode(fmul_Callback, "0000 0011 0ddd 1rrr", OPCODE_fmul); + Register_Opcode(fmuls_Callback, "0000 0011 1ddd 0rrr", OPCODE_fmuls); + Register_Opcode(fmulsu_Callback, "0000 0011 1ddd 1rrr", OPCODE_fmulsu); + Register_Opcode(icall_Callback, "1001 0101 0000 1001", OPCODE_icall); + Register_Opcode(ijmp_Callback, "1001 0100 0000 1001", OPCODE_ijmp); + Register_Opcode(in_Callback, "1011 0AAd dddd AAAA", OPCODE_in); + Register_Opcode(inc_Callback, "1001 010d dddd 0011", OPCODE_inc); + Register_Opcode(jmp_Callback, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp); + Register_Opcode(ld1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); + Register_Opcode(ld2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); + Register_Opcode(ld3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); + Register_Opcode(ldy1_Callback, "1000 000d dddd 1000", OPCODE_ld_4); + Register_Opcode(ldy2_Callback, "1001 000d dddd 1001", OPCODE_ld_5); + Register_Opcode(ldy3_Callback, "1001 000d dddd 1010", OPCODE_ld_6); + Register_Opcode(ldy4_Callback, "10q0 qq0d dddd 1qqq", OPCODE_ldd_1); + Register_Opcode(ldz1_Callback, "1000 000d dddd 0000", OPCODE_ld_7); + Register_Opcode(ldz2_Callback, "1001 000d dddd 0001", OPCODE_ld_8); + Register_Opcode(ldz3_Callback, "1001 000d dddd 0010", OPCODE_ld_9); + Register_Opcode(ldz4_Callback, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2); + Register_Opcode(ldi_Callback, "1110 KKKK dddd KKKK", OPCODE_ldi); + Register_Opcode(lds_Callback, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds); + Register_Opcode(lpm1_Callback, "1001 0101 1100 1000", OPCODE_lpm_1); + Register_Opcode(lpm2_Callback, "1001 000d dddd 0100", OPCODE_lpm_2); + Register_Opcode(lpm3_Callback, "1001 000d dddd 0101", OPCODE_lpm_3); + + // Register_Opcode(lsl_Callback, "0000 11dd dddd dddd", OPCODE_lsl); // Implied by add + Register_Opcode(lsr_Callback, "1001 010d dddd 0110", OPCODE_lsr); + Register_Opcode(mov_Callback, "0010 11rd dddd rrrr", OPCODE_mov); + Register_Opcode(movw_Callback, "0000 0001 dddd rrrr", OPCODE_movw); + Register_Opcode(mul_Callback, "1001 11rd dddd rrrr", OPCODE_mul); + Register_Opcode(muls_Callback, "0000 0010 dddd rrrr", OPCODE_muls); + Register_Opcode(mulsu_Callback, "0000 0011 0ddd 0rrr", OPCODE_mulsu); + Register_Opcode(neg_Callback, "1001 010d dddd 0001", OPCODE_neg); + Register_Opcode(nop_Callback, "0000 0000 0000 0000", OPCODE_nop); + Register_Opcode(or_Callback, "0010 10rd dddd rrrr", OPCODE_or); + Register_Opcode(ori_Callback, "0110 KKKK dddd KKKK", OPCODE_ori); + Register_Opcode(out_Callback, "1011 1AAr rrrr AAAA", OPCODE_out); + Register_Opcode(pop_Callback, "1001 000d dddd 1111", OPCODE_pop); + Register_Opcode(push_Callback, "1001 001d dddd 1111", OPCODE_push); + Register_Opcode(rcall_Callback, "1101 kkkk kkkk kkkk", OPCODE_rcall); + Register_Opcode(ret_Callback, "1001 0101 0000 1000", OPCODE_ret); + Register_Opcode(reti_Callback, "1001 0101 0001 1000", OPCODE_reti); + Register_Opcode(rjmp_Callback, "1100 kkkk kkkk kkkk", OPCODE_rjmp); + + // Register_Opcode(rol_Callback, "0001 11dd dddd dddd", OPCODE_rol); // Implied by adc + Register_Opcode(ror_Callback, "1001 010d dddd 0111", OPCODE_ror); + Register_Opcode(sbc_Callback, "0000 10rd dddd rrrr", OPCODE_sbc); + Register_Opcode(sbci_Callback, "0100 KKKK dddd KKKK", OPCODE_sbci); + Register_Opcode(sbi_Callback, "1001 1010 AAAA Abbb", OPCODE_sbi); + Register_Opcode(sbic_Callback, "1001 1001 AAAA Abbb", OPCODE_sbic); + Register_Opcode(sbis_Callback, "1001 1011 AAAA Abbb", OPCODE_sbis); + Register_Opcode(sbiw_Callback, "1001 0111 KKdd KKKK", OPCODE_sbiw); + Register_Opcode(sbr_Callback, "0110 KKKK dddd KKKK", OPCODE_sbr); + Register_Opcode(sbrc_Callback, "1111 110r rrrr 0bbb", OPCODE_sbrc); + Register_Opcode(sbrs_Callback, "1111 111r rrrr 0bbb", OPCODE_sbrs); + Register_Opcode(sec_Callback, "1001 0100 0000 1000", OPCODE_sec); + Register_Opcode(seh_Callback, "1001 0100 0101 1000", OPCODE_seh); + Register_Opcode(sei_Callback, "1001 0100 0111 1000", OPCODE_sei); + Register_Opcode(sen_Callback, "1001 0100 0010 1000", OPCODE_sen); + Register_Opcode(ser_Callback, "1110 1111 dddd 1111", OPCODE_ser); + Register_Opcode(ses_Callback, "1001 0100 0100 1000", OPCODE_ses); + Register_Opcode(set_Callback, "1001 0100 0110 1000", OPCODE_set); + Register_Opcode(sev_Callback, "1001 0100 0011 1000", OPCODE_sev); + Register_Opcode(sez_Callback, "1001 0100 0001 1000", OPCODE_sez); + Register_Opcode(sleep_Callback, "1001 0101 1000 1000", OPCODE_sleep); + Register_Opcode(spm_Callback, "1001 0101 1110 1000", OPCODE_spm); + Register_Opcode(st1_Callback, "1001 001r rrrr 1100", OPCODE_st_1); + Register_Opcode(st2_Callback, "1001 001r rrrr 1101", OPCODE_st_2); + Register_Opcode(st3_Callback, "1001 001r rrrr 1110", OPCODE_st_3); + Register_Opcode(sty1_Callback, "1000 001r rrrr 1000", OPCODE_st_4); + Register_Opcode(sty2_Callback, "1001 001r rrrr 1001", OPCODE_st_5); + Register_Opcode(sty3_Callback, "1001 001r rrrr 1010", OPCODE_st_6); + Register_Opcode(sty4_Callback, "10q0 qq1r rrrr 1qqq", OPCODE_std_1); + Register_Opcode(stz1_Callback, "1000 001r rrrr 0000", OPCODE_st_7); + Register_Opcode(stz2_Callback, "1001 001r rrrr 0001", OPCODE_st_8); + Register_Opcode(stz3_Callback, "1001 001r rrrr 0010", OPCODE_st_9); + Register_Opcode(stz4_Callback, "10q0 qq1r rrrr 0qqq", OPCODE_std_2); + Register_Opcode(sts_Callback, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts); + Register_Opcode(sub_Callback, "0001 10rd dddd rrrr", OPCODE_sub); + Register_Opcode(subi_Callback, "0101 KKKK dddd KKKK", OPCODE_subi); + Register_Opcode(swap_Callback, "1001 010d dddd 0010", OPCODE_swap); + + // Register_Opcode(tst_Callback, "0010 00dd dddd dddd", OPCODE_tst); // Implied by and + Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); + + if(Options.Show_PseudoCode) { + Supersede_Opcode(adc_Callback_PC, OPCODE_adc); + Supersede_Opcode(add_Callback_PC, OPCODE_add); + Supersede_Opcode(sub_Callback_PC, OPCODE_sub); + Supersede_Opcode(sbc_Callback_PC, OPCODE_sbc); + Supersede_Opcode(mov_Callback_PC, OPCODE_mov); + Supersede_Opcode(brcc_Callback_PC, OPCODE_brcc); + Supersede_Opcode(brcs_Callback_PC, OPCODE_brcs); + Supersede_Opcode(breq_Callback_PC, OPCODE_breq); + Supersede_Opcode(brge_Callback_PC, OPCODE_brge); + Supersede_Opcode(brhc_Callback_PC, OPCODE_brhc); + Supersede_Opcode(brhs_Callback_PC, OPCODE_brhs); + Supersede_Opcode(brid_Callback_PC, OPCODE_brid); + Supersede_Opcode(brie_Callback_PC, OPCODE_brie); + Supersede_Opcode(brlo_Callback_PC, OPCODE_brlo); + Supersede_Opcode(brlt_Callback_PC, OPCODE_brlt); + Supersede_Opcode(brmi_Callback_PC, OPCODE_brmi); + Supersede_Opcode(brne_Callback_PC, OPCODE_brne); + Supersede_Opcode(brpl_Callback_PC, OPCODE_brpl); + Supersede_Opcode(brsh_Callback_PC, OPCODE_brsh); + Supersede_Opcode(brtc_Callback_PC, OPCODE_brtc); + Supersede_Opcode(brts_Callback_PC, OPCODE_brts); + Supersede_Opcode(brvc_Callback_PC, OPCODE_brvc); + Supersede_Opcode(brvs_Callback_PC, OPCODE_brvs); + Supersede_Opcode(out_Callback_PC, OPCODE_out); + Supersede_Opcode(in_Callback_PC, OPCODE_in); + Supersede_Opcode(cli_Callback_PC, OPCODE_cli); + Supersede_Opcode(sei_Callback_PC, OPCODE_sei); + Supersede_Opcode(ret_Callback_PC, OPCODE_ret); + Supersede_Opcode(reti_Callback_PC, OPCODE_reti); + Supersede_Opcode(andi_Callback_PC, OPCODE_andi); + Supersede_Opcode(subi_Callback_PC, OPCODE_subi); + Supersede_Opcode(sbci_Callback_PC, OPCODE_sbci); + Supersede_Opcode(sbr_Callback_PC, OPCODE_sbr); + Supersede_Opcode(ori_Callback_PC, OPCODE_ori); + Supersede_Opcode(ldi_Callback_PC, OPCODE_ldi); + Supersede_Opcode(lds_Callback_PC, OPCODE_lds); + Supersede_Opcode(sts_Callback_PC, OPCODE_sts); + Supersede_Opcode(call_Callback_PC, OPCODE_call); + Supersede_Opcode(rcall_Callback_PC, OPCODE_rcall); + Supersede_Opcode(ror_Callback_PC, OPCODE_ror); + Supersede_Opcode(lsr_Callback_PC, OPCODE_lsr); + Supersede_Opcode(eor_Callback_PC, OPCODE_eor); + Supersede_Opcode(swap_Callback_PC, OPCODE_swap); + Supersede_Opcode(jmp_Callback_PC, OPCODE_jmp); + Supersede_Opcode(rjmp_Callback_PC, OPCODE_rjmp); + Supersede_Opcode(cpi_Callback_PC, OPCODE_cpi); + Supersede_Opcode(asr_Callback_PC, OPCODE_asr); + Supersede_Opcode(inc_Callback_PC, OPCODE_inc); + Supersede_Opcode(dec_Callback_PC, OPCODE_dec); + Supersede_Opcode(cp_Callback_PC, OPCODE_cp); + Supersede_Opcode(cpc_Callback_PC, OPCODE_cpc); + Supersede_Opcode(cpse_Callback_PC, OPCODE_cpse); + Supersede_Opcode(and_Callback_PC, OPCODE_and); + Supersede_Opcode(or_Callback_PC, OPCODE_or); + Supersede_Opcode(mul_Callback_PC, OPCODE_mul); + Supersede_Opcode(sbi_Callback_PC, OPCODE_sbi); + Supersede_Opcode(sbis_Callback_PC, OPCODE_sbis); + Supersede_Opcode(sbic_Callback_PC, OPCODE_sbic); + Supersede_Opcode(cbi_Callback_PC, OPCODE_cbi); + Supersede_Opcode(ser_Callback_PC, OPCODE_ser); + Supersede_Opcode(movw_Callback_PC, OPCODE_movw); + Supersede_Opcode(adiw_Callback_PC, OPCODE_adiw); + Supersede_Opcode(lpm1_Callback_PC, OPCODE_lpm_1); + Supersede_Opcode(st2_Callback_PC, OPCODE_st_2); + } + + qsort(Opcodes, Number_Opcodes, sizeof(struct Opcode), Comparison); + + Disassemble(Options.Filename); + return 0; +} diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c new file mode 100644 index 00000000..c0c74c7c --- /dev/null +++ b/src/disasm_callbacks_assembly.c @@ -0,0 +1,850 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include + +#include "disasm_mnemonics.h" +#include "disasm_globals.h" +#include "disasm_callbacks_assembly.h" +#include "disasm_jumpcall.h" +#include "disasm_ioregisters.h" +#include "disasm_functions.h" +#include "disasm_tools.h" +#include "disasm_tagfile.h" + +static char *Code_Line; +static char *Comment_Line; +static char *After_Code_Line; +static int *Registers; +static struct Options *Options; + +void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, + struct Options *New_Options) { + Code_Line = New_Code_Line; + Comment_Line = New_Comment_Line; + After_Code_Line = New_After_Code_Line; + Registers = New_Registers; + Options = New_Options; +} + +void Operation_Simple(int MNemonic_Int) { + snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); +} + +void Operation_Rd(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); +} + +void Operation_Rd16(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); +} + +void Operation_Rd_Rr(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); +} + +void Operation_Rd16_Rr16(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); +} + +void Operation_Rd16_K(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); + snprintf(Comment_Line, 255, "%d", RK); +} + +void Operation_Rd_K(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(Comment_Line, 255, "%d", RK); +} + +void Operation_RdW_K(int MNemonic_Int) { + if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + } + snprintf(Comment_Line, 255, "%d", RK); +} + +void Operation_RdW_RrW(int MNemonic_Int) { + if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); + } else { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); + } +} + +void Operation_s_k(int MNemonic_Int, int Position) { + int Bits, Offset; + int Target; + + Bits = Rs; + Offset = (2 * Rk); + if(Offset > 128) + Offset -= 256; + Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + if(Options->Process_Labels == 0) { + if(Offset > 0) { + snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); + } else { + snprintf(Code_Line, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); + } + snprintf(Comment_Line, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); + } else { + snprintf(Code_Line, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); + } +} + +void Operation_r_b(int MNemonic_Int) { + int Register, Bit; + + Register = Rr; + Bit = Rb; + snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void Operation_Rd_b(int MNemonic_Int) { + int Register, Bit; + + Register = Rd; + Bit = Rb; + snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void Operation_A_b(int MNemonic_Int) { + int Register, Bit; + const char *Register_Name; + + Register = RA; + Bit = Rb; + Register_Name = Resolve_IO_Register(Register); + if(Register_Name == NULL) { + snprintf(Code_Line, 255, "%-7s 0x%02x, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + } else { + snprintf(Code_Line, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + } +} + +void Operation_s(int MNemonic_Int) { + int Bit; + + Bit = Rs; + snprintf(Code_Line, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { + int Offset; + int Target; + + Offset = (2 * Rk); + if(Offset > 128) + Offset -= 256; + Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + if(Options->Process_Labels == 0) { + if(Offset > 0) { + snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + } else { + snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + } + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); + } +} + +/************* Now to the callback functions *************/ + +CALLBACK(adc_Callback) { + if(Rd == Rr) { + Operation_Rd(OPCODE_rol); + } else { + Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(add_Callback) { + if(Rd == Rr) { + Operation_Rd(OPCODE_lsl); + } else { + Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(adiw_Callback) { + if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); + } + snprintf(Comment_Line, 255, "%d", RK); +} + +CALLBACK(and_Callback) { + if(Rd == Rr) { + Operation_Rd(OPCODE_tst); + } else { + Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(andi_Callback) { + if(BitCount(RK) < 4) { + Operation_Rd16_K(MNemonic_Int); + } else { + RK = ~RK; + RK &= 0xff; + Operation_Rd16_K(OPCODE_cbr); + } +} + +CALLBACK(asr_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(bclr_Callback) { + Operation_s(MNemonic_Int); +} + +CALLBACK(bld_Callback) { + Operation_Rd_b(MNemonic_Int); +} + +CALLBACK(brbc_Callback) { + Operation_s_k(MNemonic_Int, Position); +} + +CALLBACK(brbs_Callback) { + Operation_s_k(MNemonic_Int, Position); +} + +CALLBACK(brcc_Callback) { + Operation_k(MNemonic_Int, Position, "Carry == 0"); +} + +CALLBACK(brcs_Callback) { + Operation_k(MNemonic_Int, Position, "Carry == 1"); +} + +CALLBACK(break_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(breq_Callback) { + Operation_k(MNemonic_Int, Position, "c1 == c2"); +} + +CALLBACK(brge_Callback) { + Operation_k(MNemonic_Int, Position, "c1 (signed)>= c2"); +} + +CALLBACK(brhc_Callback) { + Operation_k(MNemonic_Int, Position, "HalfCarry == 0"); +} + +CALLBACK(brhs_Callback) { + Operation_k(MNemonic_Int, Position, "HalfCarry == 1"); +} + +CALLBACK(brid_Callback) { + Operation_k(MNemonic_Int, Position, "Global_Interrupts_Disabled()"); +} + +CALLBACK(brie_Callback) { + Operation_k(MNemonic_Int, Position, "Global_Interrupts_Enabled()"); +} + +CALLBACK(brlo_Callback) { + Operation_k(MNemonic_Int, Position, "c1 (unsigned)< c2"); +} + +CALLBACK(brlt_Callback) { + Operation_k(MNemonic_Int, Position, "c1 (signed)< c2"); +} + +CALLBACK(brmi_Callback) { + Operation_k(MNemonic_Int, Position, "< 0"); +} + +CALLBACK(brne_Callback) { + Operation_k(MNemonic_Int, Position, "c1 != c2"); +} + +CALLBACK(brpl_Callback) { + Operation_k(MNemonic_Int, Position, "> 0"); +} + +CALLBACK(brsh_Callback) { + Operation_k(MNemonic_Int, Position, "c1 (unsigned)>= c2"); +} + +CALLBACK(brtc_Callback) { + Operation_k(MNemonic_Int, Position, "T == 0"); +} + +CALLBACK(brts_Callback) { + Operation_k(MNemonic_Int, Position, "T == 1"); +} + +CALLBACK(brvc_Callback) { + Operation_k(MNemonic_Int, Position, "Overflow == 0"); +} + +CALLBACK(brvs_Callback) { + Operation_k(MNemonic_Int, Position, "Overflow == 1"); +} + +CALLBACK(bset_Callback) { + Operation_s(MNemonic_Int); +} + +CALLBACK(bst_Callback) { + Operation_Rd_b(MNemonic_Int); +} + +CALLBACK(call_Callback) { + int Pos; + + Pos = FixTargetAddress(2 * Rk); + Register_JumpCall(Position, Pos, MNemonic_Int, 1); + if(!Options->Process_Labels) { + snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); + } else { + char *LabelName; + char *LabelComment = NULL; + + LabelName = Get_Label_Name(Pos, &LabelComment); + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); + if(LabelComment != NULL) + snprintf(Comment_Line, 255, "%s", LabelComment); + } +} + +CALLBACK(cbi_Callback) { + Operation_A_b(MNemonic_Int); +} + +CALLBACK(clc_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(clh_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(cli_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(cln_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(cls_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(clt_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(clv_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(clz_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(com_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(cp_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(cpc_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(cpi_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(cpse_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(dec_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(eicall_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(eijmp_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(elpm1_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(elpm2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(elpm3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(eor_Callback) { + if(Rd == Rr) { + Operation_Rd(OPCODE_clr); + } else { + Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(fmul_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(fmuls_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(fmulsu_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(icall_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(ijmp_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(in_Callback) { + int Register_Number; + const char *Register_Name; + + Register_Number = RA; + Register_Name = Resolve_IO_Register(Register_Number); + if(Register_Name != NULL) { + snprintf(Code_Line, 255, "%-7s r%d, %s", MNemonic[MNemonic_Int], Rd, Register_Name); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, Register_Number); + snprintf(Comment_Line, 255, "%d", RA); + } +} + +CALLBACK(inc_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(jmp_Callback) { + int Pos; + + Pos = FixTargetAddress(2 * Rk); + if(!Options->Process_Labels) { + snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); + } else { + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Pos, NULL)); + } + Register_JumpCall(Position, Pos, MNemonic_Int, 0); +} + +CALLBACK(ld1_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, X", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ld2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, X+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ld3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, -X", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldy1_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Y", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldy2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Y+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldy3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, -Y", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldy4_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Y+%d", MNemonic[MNemonic_Int], Rd, Rq); +} + +CALLBACK(ldz1_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldz2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldz3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, -Z", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(ldz4_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z+%d", MNemonic[MNemonic_Int], Rd, Rq); +} + +CALLBACK(ldi_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(lds_Callback) { + const char *MemAddress; + + snprintf(Code_Line, 255, "%-7s r%d, 0x%04x", MNemonic[MNemonic_Int], Rd, Rk); + MemAddress = Tagfile_Resolve_Mem_Address(Rk); + snprintf(Code_Line, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); + if(MemAddress) { + snprintf(Comment_Line, 255, "%s", MemAddress); + } +} + +CALLBACK(lpm1_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(lpm2_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(lpm3_Callback) { + snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); +} + +CALLBACK(lsr_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(mov_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(movw_Callback) { + Operation_RdW_RrW(MNemonic_Int); +} + +CALLBACK(mul_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(muls_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(mulsu_Callback) { + Operation_Rd16_Rr16(MNemonic_Int); +} + +CALLBACK(neg_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(nop_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(or_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(ori_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(out_Callback) { + int Register_Number; + const char *Register_Name; + + Register_Number = RA; + Register_Name = Resolve_IO_Register(Register_Number); + if(Register_Name != NULL) { + snprintf(Code_Line, 255, "%-7s %s, r%d", MNemonic[MNemonic_Int], Register_Name, Rr); + } else { + snprintf(Code_Line, 255, "%-7s 0x%02x, r%d", MNemonic[MNemonic_Int], Register_Number, Rr); + snprintf(Comment_Line, 255, "%d", RA); + } +} + +CALLBACK(pop_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(push_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(rcall_Callback) { + int Offset; + int Target; + + Offset = 2 * (Rk); + if(Offset > 4096) + Offset -= 8192; + Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 1); + if(Options->Process_Labels == 0) { + if(Offset > 0) { + snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + } else { + snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + } + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + char *LabelName; + char *LabelComment = NULL; + + LabelName = Get_Label_Name(Target, &LabelComment); + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); + if(LabelComment != NULL) + snprintf(Comment_Line, 255, "%s", LabelComment); + } +} + +CALLBACK(ret_Callback) { + Operation_Simple(MNemonic_Int); + snprintf(After_Code_Line, 255, "\n"); +} + +CALLBACK(reti_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(rjmp_Callback) { + int Offset; + int Target; + + Offset = 2 * (Rk); + if(Offset > 4096) + Offset -= 8192; + Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + + if(Options->Process_Labels == 0) { + if(Offset > 0) { + snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + } else { + snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + } + if(Target >= 0) { + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + snprintf(Comment_Line, 255, "-0x%02x - Illegal jump position -- specify flash size!", -Target); + } + } else { + snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); + } +} + +CALLBACK(ror_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(sbc_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(sbci_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(sbi_Callback) { + Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbic_Callback) { + Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbis_Callback) { + Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbiw_Callback) { + if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); + } + snprintf(Comment_Line, 255, "%d", RK); +} + +CALLBACK(sbr_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(sbrc_Callback) { + Operation_r_b(MNemonic_Int); +} + +CALLBACK(sbrs_Callback) { + Operation_r_b(MNemonic_Int); +} + +CALLBACK(sec_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(seh_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sei_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sen_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(ser_Callback) { + Operation_Rd16(MNemonic_Int); +} + +CALLBACK(ses_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(set_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sev_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sez_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(sleep_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(spm_Callback) { + Operation_Simple(MNemonic_Int); +} + +CALLBACK(st1_Callback) { + snprintf(Code_Line, 255, "%-7s X, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(st2_Callback) { + snprintf(Code_Line, 255, "%-7s X+, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(st3_Callback) { + snprintf(Code_Line, 255, "%-7s -X, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(sty1_Callback) { + snprintf(Code_Line, 255, "%-7s Y, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(sty2_Callback) { + snprintf(Code_Line, 255, "%-7s Y+, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(sty3_Callback) { + snprintf(Code_Line, 255, "%-7s -Y, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(sty4_Callback) { + snprintf(Code_Line, 255, "%-7s Y+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); +} + +CALLBACK(stz1_Callback) { + snprintf(Code_Line, 255, "%-7s Z, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(stz2_Callback) { + snprintf(Code_Line, 255, "%-7s Z+, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(stz3_Callback) { + snprintf(Code_Line, 255, "%-7s -Z, r%d", MNemonic[MNemonic_Int], Rr); +} + +CALLBACK(stz4_Callback) { + snprintf(Code_Line, 255, "%-7s Z+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); +} + +CALLBACK(sts_Callback) { + // The AVR instruction set 11/2005 defines operation as: "(k) <- Rr", however "(k) <- Rd" seems to be right + const char *MemAddress; + + MemAddress = Tagfile_Resolve_Mem_Address(Rk); + snprintf(Code_Line, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); + if(MemAddress) { + snprintf(Comment_Line, 255, "%s", MemAddress); + } +} + +CALLBACK(sub_Callback) { + Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(subi_Callback) { + Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(swap_Callback) { + Operation_Rd(MNemonic_Int); +} + +CALLBACK(wdr_Callback) { + Operation_Simple(MNemonic_Int); +} diff --git a/src/Callbacks_Assembly.h b/src/disasm_callbacks_assembly.h similarity index 97% rename from src/Callbacks_Assembly.h rename to src/disasm_callbacks_assembly.h index 3bca9c1d..ec9783b8 100644 --- a/src/Callbacks_Assembly.h +++ b/src/disasm_callbacks_assembly.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,13 +19,14 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ -void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, struct Options *New_Options); +void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, + struct Options *New_Options); void Operation_Simple(int MNemonic_Int); void Operation_Rd(int MNemonic_Int); void Operation_Rd16(int MNemonic_Int); diff --git a/src/disasm_callbacks_pseudocode.c b/src/disasm_callbacks_pseudocode.c new file mode 100644 index 00000000..16b0701e --- /dev/null +++ b/src/disasm_callbacks_pseudocode.c @@ -0,0 +1,687 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include + +#include "disasm_mnemonics.h" +#include "disasm_globals.h" +#include "disasm_callbacks_pseudocode.h" +#include "disasm_jumpcall.h" +#include "disasm_ioregisters.h" +#include "disasm_functions.h" +#include "disasm_tagfile.h" + +static char *Code_Line; +static char *Comment_Line; +static char *After_Code_Line; +static int *Registers; +static struct Options *Options; + +void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, + struct Options *New_Options) { + Code_Line = New_Code_Line; + Comment_Line = New_Comment_Line; + After_Code_Line = New_After_Code_Line; + Registers = New_Registers; + Options = New_Options; +} + +void PC_Operation_Simple(int MNemonic_Int) { + snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); +} + +void PC_Operation_Rd(int MNemonic_Int) { + switch (MNemonic_Int) { + case OPCODE_lsl: + snprintf(Code_Line, 255, "r%d <<= 1;", Rd); + snprintf(Comment_Line, 255, "_BV(0) = 0 (logical shift)"); + break; + case OPCODE_lsr: + snprintf(Code_Line, 255, "r%d >>= 1;", Rd); + snprintf(Comment_Line, 255, "_BV(7) = 0, Carry = _BV(0) (logical shift)"); + break; + case OPCODE_ror: + snprintf(Code_Line, 255, "r%d >>= 1;", Rd); + snprintf(Comment_Line, 255, "_BV(7) = Carry, Carry = _BV(0) (rotate right)"); + break; + case OPCODE_asr: + + // snprintf(Code_Line, 255, "r%d >>= 1;", Rd); + + // snprintf(Comment_Line, 255, "_BV(7) = Sign (Arithmetic Shift)"); + snprintf(Code_Line, 255, "r%d /= 2;", Rd); + snprintf(Comment_Line, 255, "arithmetic shift right"); + break; + case OPCODE_swap: + snprintf(Code_Line, 255, "r%d = ((r%d & 0xf0) >> 4) | ((r%d & 0x0f) << 4);", Rd, Rd, Rd); + snprintf(Comment_Line, 255, "swap nibbles"); + break; + case OPCODE_clr: + snprintf(Code_Line, 255, "r%d = 0x00;", Rd); + snprintf(Comment_Line, 255, "0"); + break; + default: + snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); + } +} + +void PC_Operation_Rd16(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); +} + +void PC_Operation_Rd_Rr(int MNemonic_Int) { + switch (MNemonic_Int) { + case OPCODE_add: + if(Rd != Rr) { + snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "No carry"); + } else { + snprintf(Code_Line, 255, "r%d *= 2;", Rd); + } + break; + case OPCODE_adc: + snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "With carry"); + break; + case OPCODE_sub: + snprintf(Code_Line, 255, "r%d -= r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "No carry"); + break; + case OPCODE_sbc: + snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "With carry"); + break; + case OPCODE_mul: + snprintf(Code_Line, 255, "r1:r0 = r%d * r%d;", Rd, Rr); + snprintf(Comment_Line, 255, "Unsigned"); + break; + case OPCODE_mov: + snprintf(Code_Line, 255, "r%d = r%d;", Rd, Rr); + break; + case OPCODE_eor: + snprintf(Code_Line, 255, "r%d ^= r%d;", Rd, Rr); + break; + case OPCODE_and: + if(Rd != Rr) { + snprintf(Code_Line, 255, "r%d &= r%d;", Rd, Rr); + } else { + snprintf(Code_Line, 255, "(r%d == 0) || (r%d < 0);", Rd, Rd); + snprintf(Comment_Line, 255, "test r%d", Rd); + } + break; + case OPCODE_or: + snprintf(Code_Line, 255, "r%d |= r%d;", Rd, Rr); + break; + case OPCODE_cp: + snprintf(Code_Line, 255, "cmp(r%d, r%d);", Rd, Rr); + break; + case OPCODE_cpc: + snprintf(Code_Line, 255, "cmp(r%d, r%d);", Rd, Rr); + snprintf(Comment_Line, 255, "with carry"); + break; + case OPCODE_cpse: + snprintf(Code_Line, 255, "skipif (r%d == r%d)", Rd, Rr); + break; + default: + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); + } +} + +void PC_Operation_Rd16_Rr16(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); +} + +void PC_Operation_Rd16_K(int MNemonic_Int) { + switch (MNemonic_Int) { + case OPCODE_andi: + snprintf(Code_Line, 255, "r%d &= %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x", RK); + break; + case OPCODE_subi: + snprintf(Code_Line, 255, "r%d -= %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x, no carry", RK); + break; + case OPCODE_sbci: + snprintf(Code_Line, 255, "r%d -= %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x, with carry", RK); + break; + case OPCODE_sbr: + case OPCODE_ori: + snprintf(Code_Line, 255, "r%d |= %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x", RK); + break; + default: + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); + snprintf(Comment_Line, 255, "%d", RK); + } +} + +void PC_Operation_Rd_K(int MNemonic_Int) { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(Comment_Line, 255, "%d", RK); +} + +void PC_Operation_RdW_K(int MNemonic_Int) { + if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); + } else { + snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + } + snprintf(Comment_Line, 255, "%d", RK); +} + +void PC_Operation_RdW_RrW(int MNemonic_Int) { + if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); + } else { + snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); + } +} + +void PC_Operation_s_k(int MNemonic_Int, int Position) { + int Bits, Offset; + + Bits = Rs; + Offset = (2 * Rk); + if(Offset > 128) + Offset -= 256; + + int Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + if(Options->Process_Labels == 0) { + if(Offset > 0) { + snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); + } else { + snprintf(Code_Line, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); + } + snprintf(Comment_Line, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); + } else { + snprintf(Code_Line, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); + } +} + +void PC_Operation_r_b(int MNemonic_Int) { + int Register, Bit; + + Register = Rr; + Bit = Rb; + snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void PC_Operation_Rd_b(int MNemonic_Int) { + int Register, Bit; + + Register = Rd; + Bit = Rb; + snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void PC_Operation_A_b(int MNemonic_Int) { + int Register, Bit; + const char *Register_Name; + char Register_Value[5]; + + Register = RA; + Bit = Rb; + Register_Name = Resolve_IO_Register(Register); + if(Register_Name == NULL) { + snprintf(Register_Value, sizeof(Register_Value), "0x%02x", Register); + Register_Name = Register_Value; + } + switch (MNemonic_Int) { + case OPCODE_cbi: + snprintf(Code_Line, 255, "IO[%s] &= ~(_BV(%d));", Register_Name, Bit); + break; + case OPCODE_sbi: + snprintf(Code_Line, 255, "IO[%s] |= _BV(%d);", Register_Name, Bit); + break; + case OPCODE_sbis: + snprintf(Code_Line, 255, "skipif (IO[%s] & _BV(%d))", Register_Name, Bit); + break; + case OPCODE_sbic: + snprintf(Code_Line, 255, "skipif (!(IO[%s] & _BV(%d)))", Register_Name, Bit); + break; + default: + snprintf(Code_Line, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); + } + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void PC_Operation_s(int MNemonic_Int) { + int Bit; + + Bit = Rs; + snprintf(Code_Line, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); + snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); +} + +void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { + int Offset; + + Offset = (2 * Rk); + if(Offset > 128) + Offset -= 256; + + int Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + if(Options->Process_Labels == 0) { + if(Offset > 0) { + snprintf(Code_Line, 255, "if (%s) goto .+%d;", Pseudocode, Offset); + } else { + snprintf(Code_Line, 255, "if (%s) goto .%d", Pseudocode, Offset); + } + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + snprintf(Code_Line, 255, "if (%s) goto %s;", Pseudocode, Get_Label_Name(Target, NULL)); + } +} + +/************* Now to the callback functions *************/ + +CALLBACK(adc_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(add_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(sub_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(sbc_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(mov_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(brcc_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "!Carry"); +} + +CALLBACK(brcs_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Carry"); +} + +CALLBACK(breq_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 == c2"); +} + +CALLBACK(brge_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 (signed)>= c2"); +} + +CALLBACK(brhc_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "!HalfCarry"); +} + +CALLBACK(brhs_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "HalfCarry"); +} + +CALLBACK(brid_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Global_Interrupts_Disabled()"); +} + +CALLBACK(brie_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Global_Interrupts_Enabled()"); +} + +CALLBACK(brlo_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 (unsigned)< c2"); +} + +CALLBACK(brlt_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 (signed)< c2"); +} + +CALLBACK(brmi_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "< 0"); +} + +CALLBACK(brne_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 != c2"); +} + +CALLBACK(brpl_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "> 0"); +} + +CALLBACK(brsh_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "c1 (unsigned)>= c2"); +} + +CALLBACK(brtc_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "T == 0"); +} + +CALLBACK(brts_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "T == 1"); +} + +CALLBACK(brvc_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Overflow == 0"); +} + +CALLBACK(brvs_Callback_PC) { + PC_Operation_k(MNemonic_Int, Position, "Overflow == 1"); +} + +CALLBACK(out_Callback_PC) { + int Register_Number; + const char *Register_Name; + + Register_Number = RA; + Register_Name = Resolve_IO_Register(Register_Number); + if(Register_Name) { + snprintf(Code_Line, 255, "IO[%s] = r%d;", Register_Name, Rr); + } else { + snprintf(Code_Line, 255, "IO[0x%02x] = r%d;", Register_Number, Rr); + snprintf(Comment_Line, 255, "%d", RA); + } +} + +CALLBACK(in_Callback_PC) { + int Register_Number; + const char *Register_Name; + + Register_Number = RA; + Register_Name = Resolve_IO_Register(Register_Number); + if(Register_Name) { + snprintf(Code_Line, 255, "r%d = IO[%s];", Rd, Register_Name); + } else { + snprintf(Code_Line, 255, "r%d = IO[0x%02x];", Rd, Register_Number); + snprintf(Comment_Line, 255, "%d", RA); + } +} + +CALLBACK(cli_Callback_PC) { + snprintf(Code_Line, 255, "Disable_Interrupts();"); +} + +CALLBACK(sei_Callback_PC) { + snprintf(Code_Line, 255, "Enable_Interrupts();"); +} + +CALLBACK(ret_Callback_PC) { + snprintf(Code_Line, 255, "return;"); + snprintf(After_Code_Line, 255, "\n"); +} + +CALLBACK(reti_Callback_PC) { + snprintf(Code_Line, 255, "ireturn;"); + snprintf(After_Code_Line, 255, "\n"); +} + +CALLBACK(andi_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(subi_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(sbci_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(sbr_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(ori_Callback_PC) { + PC_Operation_Rd16_K(MNemonic_Int); +} + +CALLBACK(ldi_Callback_PC) { + snprintf(Code_Line, 255, "r%d = %d;", Rd + 16, RK); + snprintf(Comment_Line, 255, "0x%02x", RK); +} + +CALLBACK(lds_Callback_PC) { + const char *MemAddress; + + MemAddress = Tagfile_Resolve_Mem_Address(Rk); + if(!MemAddress) { + snprintf(Code_Line, 255, "r%d = Memory[0x%04x];", Rd, Rk); + snprintf(Comment_Line, 255, "%d", Rk); + } else { + snprintf(Code_Line, 255, "r%d = %s;", Rd, MemAddress); + snprintf(Comment_Line, 255, "0x%04x", Rk); + } +} + +CALLBACK(sts_Callback_PC) { + const char *MemAddress; + + MemAddress = Tagfile_Resolve_Mem_Address(Rk); + if(!MemAddress) { + snprintf(Code_Line, 255, "Memory[0x%04x] = r%d;", Rk, Rd); + snprintf(Comment_Line, 255, "%d", Rk); + } else { + snprintf(Code_Line, 255, "%s = r%d;", MemAddress, Rd); + snprintf(Comment_Line, 255, "0x%04x", Rk); + } +} + +CALLBACK(call_Callback_PC) { + int Pos; + + Pos = FixTargetAddress(2 * Rk); + Register_JumpCall(Position, Pos, MNemonic_Int, 1); + if(Options->Process_Labels == 0) { + snprintf(Code_Line, 255, "0x%02x();", Pos); + } else { + char *LabelName; + char *LabelComment = NULL; + + LabelName = Get_Label_Name(Pos, &LabelComment); + snprintf(Code_Line, 255, "%s();", LabelName); + if(LabelComment != NULL) { + snprintf(Comment_Line, 255, "%s", LabelComment); + } + } +} + +CALLBACK(rcall_Callback_PC) { + int Offset; + + Offset = 2 * (Rk); + if(Offset > 4096) + Offset -= 8192; + + int Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 1); + if(!Options->Process_Labels) { + snprintf(Comment_Line, 255, "0x%02x();", Target); + } else { + char *LabelName; + char *LabelComment = NULL; + + LabelName = Get_Label_Name(Target, &LabelComment); + snprintf(Code_Line, 255, "%s();", LabelName); + if(LabelComment != NULL) { + snprintf(Comment_Line, 255, "%s", LabelComment); + } + } +} + +CALLBACK(ror_Callback_PC) { + PC_Operation_Rd(MNemonic_Int); +} + +CALLBACK(lsr_Callback_PC) { + PC_Operation_Rd(MNemonic_Int); +} + +CALLBACK(swap_Callback_PC) { + PC_Operation_Rd(MNemonic_Int); +} + +CALLBACK(eor_Callback_PC) { + if(Rd == Rr) { + PC_Operation_Rd(OPCODE_clr); + } else { + PC_Operation_Rd_Rr(MNemonic_Int); + } +} + +CALLBACK(jmp_Callback_PC) { + int Pos; + + Pos = FixTargetAddress(2 * Rk); + if(Options->Process_Labels == 0) { + snprintf(Code_Line, 255, "goto 0x%02x;", Pos); + } else { + snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Pos, NULL)); + } + Register_JumpCall(Position, Pos, MNemonic_Int, 0); +} + +CALLBACK(rjmp_Callback_PC) { + int Offset; + + Offset = 2 * (Rk); + if(Offset > 4096) + Offset -= 8192; + + int Target = FixTargetAddress(Position + Offset + 2); + + Register_JumpCall(Position, Target, MNemonic_Int, 0); + + if(Options->Process_Labels == 0) { + if(Offset > 0) { + snprintf(Code_Line, 255, "goto .+%d;", Offset); + } else { + snprintf(Code_Line, 255, "goto .%d", Offset); + } + if(Target >= 0) { + snprintf(Comment_Line, 255, "0x%02x", Target); + } else { + snprintf(Comment_Line, 255, "-0x%02x - Illegal jump position -- specify flash size!", -(Target)); + } + } else { + snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Position + Offset + 2, NULL)); + } +} + +CALLBACK(cpi_Callback_PC) { + if(RK == 0) { + snprintf(Code_Line, 255, "cmp(r%d, 0);", Rd + 16); + } else { + snprintf(Code_Line, 255, "cmp(r%d, 0x%02x);", Rd + 16, RK); + snprintf(Comment_Line, 255, "%d", RK); + } +} + +CALLBACK(asr_Callback_PC) { + PC_Operation_Rd(MNemonic_Int); +} + +CALLBACK(dec_Callback_PC) { + snprintf(Code_Line, 255, "r%d--;", Rd); +} + +CALLBACK(inc_Callback_PC) { + snprintf(Code_Line, 255, "r%d++;", Rd); +} + +CALLBACK(cp_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(cpc_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(cpse_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(and_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(or_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(mul_Callback_PC) { + PC_Operation_Rd_Rr(MNemonic_Int); +} + +CALLBACK(sbi_Callback_PC) { + PC_Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbic_Callback_PC) { + PC_Operation_A_b(MNemonic_Int); +} + +CALLBACK(sbis_Callback_PC) { + PC_Operation_A_b(MNemonic_Int); +} + +CALLBACK(cbi_Callback_PC) { + PC_Operation_A_b(MNemonic_Int); +} + +CALLBACK(ser_Callback_PC) { + snprintf(Code_Line, 255, "r%d = 0xff;", Rd + 16); + snprintf(Comment_Line, 255, "255"); +} + +CALLBACK(adiw_Callback_PC) { + if(RK != 1) { + snprintf(Code_Line, 255, "[r%d:r%d] += 0x%02x;", 2 * Rd + 25, 2 * Rd + 24, RK); + snprintf(Comment_Line, 255, "%d", RK); + } else { + snprintf(Code_Line, 255, "[r%d:r%d]++;", 2 * Rd + 25, 2 * Rd + 24); + } +} + +CALLBACK(movw_Callback_PC) { + snprintf(Code_Line, 255, "[r%d:r%d] = [r%d:r%d];", (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); +} + +CALLBACK(lpm1_Callback_PC) { + snprintf(Code_Line, 255, "r0 = Flash[r30:r31];"); +} + +CALLBACK(st2_Callback_PC) { + snprintf(Code_Line, 255, "Flash[[r26:r27]++] = r%d;", Rr); +} diff --git a/src/Callbacks_PseudoCode.h b/src/disasm_callbacks_pseudocode.h similarity index 95% rename from src/Callbacks_PseudoCode.h rename to src/disasm_callbacks_pseudocode.h index 13d9f2c6..c37fef52 100644 --- a/src/Callbacks_PseudoCode.h +++ b/src/disasm_callbacks_pseudocode.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,13 +19,14 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ -void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, struct Options *New_Options); +void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, + struct Options *New_Options); void PC_Operation_Simple(int MNemonic_Int); void PC_Operation_Rd(int MNemonic_Int); void PC_Operation_Rd16(int MNemonic_Int); diff --git a/src/Functions.h b/src/disasm_functions.h similarity index 66% rename from src/Functions.h rename to src/disasm_functions.h index a7aa1008..f97b1594 100644 --- a/src/Functions.h +++ b/src/disasm_functions.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,18 +19,17 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ #ifdef DOS_BASED_OS - #define snprintf _snprintf +#define snprintf _snprintf #endif #ifdef DESPERATE_SPRINTF_FALLBACK - #warning "Your C library does not support snprintf. Please upgrade! Fallback to sprintf used." - #define snprintf(dest, len, str...) sprintf(dest, str) +#warning "Your C library does not support snprintf. Please upgrade! Fallback to sprintf used." +#define snprintf(dest, len, str...) sprintf(dest, str) #endif - diff --git a/src/disasm_globals.h b/src/disasm_globals.h new file mode 100644 index 00000000..c648d661 --- /dev/null +++ b/src/disasm_globals.h @@ -0,0 +1,212 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#define Rd (Registers[(int)'d']) +#define Rr (Registers[(int)'r']) +#define Rk (Registers[(int)'k']) +#define RK (Registers[(int)'K']) +#define Rs (Registers[(int)'s']) +#define RA (Registers[(int)'A']) +#define Rb (Registers[(int)'b']) +#define Rq (Registers[(int)'q']) + +#define CALLBACK(name) void name(char *Bitstream, int Position, int MNemonic_Int) + +#define CODESTYLE_AVR_INSTRUCTION_SET 0 +#define CODESTYLE_AVRGCC 1 + +struct Opcode { + char *Opcode_String; + void (*Callback)(char *, int, int); + int MNemonic; +}; + +struct JumpCall { + int From; + int To; + int Type; + unsigned int LabelNumber; + unsigned char FunctionCall; +}; + +struct Options { + char Show_Addresses; + char Show_Opcodes; + char Show_Comments; + char Show_Cycles; + char Show_PseudoCode; + char Filename[256]; + char MCU[8]; + char Tagfile[256]; + char CodeStyle; + char Process_Labels; + char Pass; + int FlashSize; +}; + +struct IO_Register { + int Address; + char Name[16]; + unsigned char Used; +}; + +#define OPCODE_adc 0 +#define OPCODE_add 1 +#define OPCODE_adiw 2 +#define OPCODE_and 3 +#define OPCODE_andi 4 +#define OPCODE_asr 5 +#define OPCODE_bclr 6 +#define OPCODE_bld 7 +#define OPCODE_brbc 8 +#define OPCODE_brbs 9 +#define OPCODE_brcc 10 +#define OPCODE_brcs 11 +#define OPCODE_break 12 +#define OPCODE_breq 13 +#define OPCODE_brge 14 +#define OPCODE_brhc 15 +#define OPCODE_brhs 16 +#define OPCODE_brid 17 +#define OPCODE_brie 18 +#define OPCODE_brlo 19 +#define OPCODE_brlt 20 +#define OPCODE_brmi 21 +#define OPCODE_brne 22 +#define OPCODE_brpl 23 +#define OPCODE_brsh 24 +#define OPCODE_brtc 25 +#define OPCODE_brts 26 +#define OPCODE_brvc 27 +#define OPCODE_brvs 28 +#define OPCODE_bset 29 +#define OPCODE_bst 30 +#define OPCODE_call 31 +#define OPCODE_cbi 32 +#define OPCODE_cbr 33 +#define OPCODE_clc 34 +#define OPCODE_clh 35 +#define OPCODE_cli 36 +#define OPCODE_cln 37 +#define OPCODE_clr 38 +#define OPCODE_cls 39 +#define OPCODE_clt 40 +#define OPCODE_clv 41 +#define OPCODE_clz 42 +#define OPCODE_com 43 +#define OPCODE_cp 44 +#define OPCODE_cpc 45 +#define OPCODE_cpi 46 +#define OPCODE_cpse 47 +#define OPCODE_dec 48 +#define OPCODE_eicall 49 +#define OPCODE_eijmp 50 +#define OPCODE_elpm_1 51 +#define OPCODE_elpm_2 52 +#define OPCODE_elpm_3 53 +#define OPCODE_eor 54 +#define OPCODE_fmul 55 +#define OPCODE_fmuls 56 +#define OPCODE_fmulsu 57 +#define OPCODE_icall 58 +#define OPCODE_ijmp 59 +#define OPCODE_in 60 +#define OPCODE_inc 61 +#define OPCODE_jmp 62 +#define OPCODE_ld_1 63 +#define OPCODE_ld_2 64 +#define OPCODE_ld_3 65 +#define OPCODE_ld_4 66 +#define OPCODE_ld_5 67 +#define OPCODE_ld_6 68 +#define OPCODE_ldd_1 69 +#define OPCODE_ld_7 70 +#define OPCODE_ld_8 71 +#define OPCODE_ld_9 72 +#define OPCODE_ldd_2 73 +#define OPCODE_ldi 74 +#define OPCODE_lds 75 +#define OPCODE_lpm_1 76 +#define OPCODE_lpm_2 77 +#define OPCODE_lpm_3 78 +#define OPCODE_lsl 79 +#define OPCODE_lsr 80 +#define OPCODE_mov 81 +#define OPCODE_movw 82 +#define OPCODE_mul 83 +#define OPCODE_muls 84 +#define OPCODE_mulsu 85 +#define OPCODE_neg 86 +#define OPCODE_nop 87 +#define OPCODE_or 88 +#define OPCODE_ori 89 +#define OPCODE_out 90 +#define OPCODE_pop 91 +#define OPCODE_push 92 +#define OPCODE_rcall 93 +#define OPCODE_ret 94 +#define OPCODE_reti 95 +#define OPCODE_rjmp 96 +#define OPCODE_rol 97 +#define OPCODE_ror 98 +#define OPCODE_sbc 99 +#define OPCODE_sbci 100 +#define OPCODE_sbi 101 +#define OPCODE_sbic 102 +#define OPCODE_sbis 103 +#define OPCODE_sbiw 104 +#define OPCODE_sbr 105 +#define OPCODE_sbrc 106 +#define OPCODE_sbrs 107 +#define OPCODE_sec 108 +#define OPCODE_seh 109 +#define OPCODE_sei 110 +#define OPCODE_sen 111 +#define OPCODE_ser 112 +#define OPCODE_ses 113 +#define OPCODE_set 114 +#define OPCODE_sev 115 +#define OPCODE_sez 116 +#define OPCODE_sleep 117 +#define OPCODE_spm 118 +#define OPCODE_st_1 119 +#define OPCODE_st_2 120 +#define OPCODE_st_3 121 +#define OPCODE_st_4 122 +#define OPCODE_st_5 123 +#define OPCODE_st_6 124 +#define OPCODE_std_1 125 +#define OPCODE_st_7 126 +#define OPCODE_st_8 127 +#define OPCODE_st_9 128 +#define OPCODE_std_2 129 +#define OPCODE_sts 130 +#define OPCODE_sub 131 +#define OPCODE_subi 132 +#define OPCODE_swap 133 +#define OPCODE_tst 134 +#define OPCODE_wdr 135 diff --git a/src/disasm_ioregisters.c b/src/disasm_ioregisters.c new file mode 100644 index 00000000..b4d4ec8b --- /dev/null +++ b/src/disasm_ioregisters.c @@ -0,0 +1,126 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include + +#include "disasm_globals.h" + +extern struct Options Options; + +static struct IO_Register *KnownIORegisters = NULL; +static unsigned int KnownIORegistersCount = 0; + +unsigned int ReadIORegisterFile() { + FILE *f; + + f = fopen("/etc/disasm.conf", "r"); + if(!f) { + f = fopen("disasm.conf", "r"); + } + if(!f) { + fprintf(stderr, "Could not read any configuration file.\n"); + return 0; + } + + { + char Buffer[256]; + int CurrentMCU = 0; + + while(fgets(Buffer, sizeof(Buffer), f)) { + char *Token; + struct IO_Register TempRegister; + + if(!(Token = strtok(Buffer, "\t\n"))) + continue; + if(!strcmp(Token, "Register")) { + if(!CurrentMCU) + continue; + if(!(Token = strtok(NULL, "\t\n"))) + continue; + if(strlen(Token) == 0) + continue; + if(Token[1] == 'x') { + TempRegister.Address = strtol(Token + 2, NULL, 16); + } else { + TempRegister.Address = atoi(Token); + } + if(!(Token = strtok(NULL, "\t\n"))) + continue; + strncpy(TempRegister.Name, Token, 16); + TempRegister.Used = 0; + + KnownIORegisters = + (struct IO_Register *) realloc(KnownIORegisters, sizeof(struct IO_Register) * (KnownIORegistersCount + 1)); + KnownIORegisters[KnownIORegistersCount] = TempRegister; + KnownIORegistersCount++; + } else if(!strcmp(Token, "Unit")) { + if(!(Token = strtok(NULL, "\t\n"))) + continue; + CurrentMCU = (!strcmp(Token, Options.MCU)) || (!strcmp(Token, "Global")); + } + } + } + + fclose(f); + return KnownIORegistersCount; +} + +const char *Resolve_IO_Register(int Number) { + int Resolved; + unsigned int i; + + if(!strcmp(Options.MCU, "None")) + return NULL; + + Resolved = -1; + for(i = 0; i < KnownIORegistersCount; i++) { + if(KnownIORegisters[i].Address == Number) { + Resolved = i; + break; + } + } + + if(Resolved != -1) { + KnownIORegisters[Resolved].Used = 1; + return KnownIORegisters[Resolved].Name; + } else { + return NULL; + } +} + +void Emit_Used_IO_Registers() { + unsigned int i; + + if(Options.Show_PseudoCode) + return; + for(i = 0; i < KnownIORegistersCount; i++) { + if(KnownIORegisters[i].Used) + printf(".equ %s, 0x%x\n", KnownIORegisters[i].Name, KnownIORegisters[i].Address); + } +} diff --git a/src/IORegisters.h b/src/disasm_ioregisters.h similarity index 74% rename from src/IORegisters.h rename to src/disasm_ioregisters.h index cc367f7c..b6b3c634 100644 --- a/src/IORegisters.h +++ b/src/disasm_ioregisters.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,12 +19,12 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ unsigned int ReadIORegisterFile(); -const char* Resolve_IO_Register(int Number); +const char *Resolve_IO_Register(int Number); void Emit_Used_IO_Registers(); diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c new file mode 100644 index 00000000..5ffe3172 --- /dev/null +++ b/src/disasm_jumpcall.c @@ -0,0 +1,196 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include + +#include "disasm_globals.h" +#include "disasm_mnemonics.h" +#include "disasm_tagfile.h" +#include "disasm_jumpcall.h" + +extern struct Options Options; +static int JumpCall_Count; +static struct JumpCall *JumpCalls; + +void Display_JumpCalls() { + int i; + + printf("%d jumps/calls found:\n", JumpCall_Count); + for(i = 0; i < JumpCall_Count; i++) { + printf("%3d: 0x%-4x -> 0x%-4x %s (%d)\n", i, (unsigned int) JumpCalls[i].From, (unsigned int) JumpCalls[i].To, + MNemonic[JumpCalls[i].Type], JumpCalls[i].FunctionCall); + } +} + +int FixTargetAddress(int Address) { + if(Options.FlashSize) { + Address %= Options.FlashSize; + if(Address < 0) { + Address += Options.FlashSize; + } + } + return Address; +} + +void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { + if((Options.Process_Labels == 1) && (Options.Pass == 1)) { + JumpCall_Count++; + JumpCalls = realloc(JumpCalls, sizeof(struct JumpCall) * (JumpCall_Count)); + JumpCalls[JumpCall_Count - 1].From = From; + JumpCalls[JumpCall_Count - 1].To = To; + JumpCalls[JumpCall_Count - 1].Type = Type; + JumpCalls[JumpCall_Count - 1].LabelNumber = 0; + JumpCalls[JumpCall_Count - 1].FunctionCall = FunctionCall; + } +} + +int JC_Comparison(const void *Element1, const void *Element2) { + struct JumpCall *JC1, *JC2; + + JC1 = (struct JumpCall *) Element1; + JC2 = (struct JumpCall *) Element2; + if((JC1->To) > (JC2->To)) + return 1; + else if((JC1->To) == (JC2->To)) + return 0; + return -1; +} + +void Sort_JumpCalls() { + qsort(JumpCalls, JumpCall_Count, sizeof(struct JumpCall), JC_Comparison); +} + +void Correct_Label_Types(void) { + int i, j; + int LastIdx = 0; + int LastDest = JumpCalls[0].To; + char CurType = JumpCalls[0].FunctionCall; + + for(i = 1; i < JumpCall_Count; i++) { + if(JumpCalls[i].To != LastDest) { + for(j = LastIdx; j < i; j++) + JumpCalls[j].FunctionCall = CurType; + LastIdx = i; + LastDest = JumpCalls[i].To; + CurType = 0; + } + CurType = (CurType || JumpCalls[i].FunctionCall); + } + for(j = LastIdx; j < JumpCall_Count; j++) + JumpCalls[j].FunctionCall = CurType; +} + +void Enumerate_Labels(void) { + int i; + int CurrentLabelNumber = 0; + int CurrentFunctionNumber = 0; + int Destination; + + if(JumpCall_Count < 2) + return; + + Sort_JumpCalls(); + Correct_Label_Types(); + + Destination = JumpCalls[0].To; + if(JumpCalls[0].FunctionCall) + CurrentFunctionNumber++; + else + CurrentLabelNumber++; + for(i = 0; i < JumpCall_Count; i++) { + if(Destination != JumpCalls[i].To) { + if(JumpCalls[i].FunctionCall) + CurrentFunctionNumber++; + else + CurrentLabelNumber++; + Destination = JumpCalls[i].To; + } + if(JumpCalls[i].FunctionCall) + JumpCalls[i].LabelNumber = CurrentFunctionNumber; + else + JumpCalls[i].LabelNumber = CurrentLabelNumber; + } +} + +char *Get_Label_Name(int Destination, char **LabelComment) { + int i; + static char Buffer[256]; + int TagIndex; + char *TagLabel; + + TagIndex = Tagfile_FindLabelAddress(Destination); + if(TagIndex != -1) { + TagLabel = Tagfile_GetLabel(TagIndex); + snprintf(Buffer, sizeof(Buffer), "%s", TagLabel); + if(LabelComment != NULL) + *LabelComment = Tagfile_GetLabelComment(TagIndex); + return Buffer; + } + + for(i = 0; i < JumpCall_Count; i++) { + if((JumpCalls[i].To) == Destination) { + if(JumpCalls[i].FunctionCall) { + snprintf(Buffer, sizeof(Buffer), "Function%d", JumpCalls[i].LabelNumber); + } else { + snprintf(Buffer, sizeof(Buffer), "Label%d", JumpCalls[i].LabelNumber); + } + return Buffer; + } + } + + snprintf(Buffer, sizeof(Buffer), "UNKNOWN"); + return Buffer; +} + +// Show all references which refer to "Position" as destination +void Print_JumpCalls(int Position) { + int i; + int Match = 0; + + for(i = 0; i < JumpCall_Count; i++) { + if((JumpCalls[i].To) == Position) { + if(Match == 0) { + printf("\n"); + Match = 1; + } + printf("; Referenced from offset 0x%02x by %s\n", JumpCalls[i].From, MNemonic[JumpCalls[i].Type]); + } + } + if(Match == 1) { + char *LabelName; + char *LabelComment = NULL; + + LabelName = Get_Label_Name(Position, &LabelComment); + if(LabelComment == NULL) { + printf("%s:\n", LabelName); + } else { + printf("%s: ; %s\n", LabelName, LabelComment); + } + } +} diff --git a/src/JumpCall.h b/src/disasm_jumpcall.h similarity index 82% rename from src/JumpCall.h rename to src/disasm_jumpcall.h index 57eef251..30a13b43 100644 --- a/src/JumpCall.h +++ b/src/disasm_jumpcall.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,10 +19,10 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ void Display_JumpCalls(); diff --git a/src/disasm_mnemonics.c b/src/disasm_mnemonics.c new file mode 100644 index 00000000..c69bd3e3 --- /dev/null +++ b/src/disasm_mnemonics.c @@ -0,0 +1,445 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include + +const char *MNemonic[] = { + "adc", + "add", + "adiw", + "and", + "andi", + "asr", + "bclr", + "bld", + "brbc", + "brbs", + "brcc", + "brcs", + "break", + "breq", + "brge", + "brhc", + "brhs", + "brid", + "brie", + "brlo", + "brlt", + "brmi", + "brne", + "brpl", + "brsh", + "brtc", + "brts", + "brvc", + "brvs", + "bset", + "bst", + "call", + "cbi", + "cbr", + "clc", + "clh", + "cli", + "cln", + "clr", + "cls", + "clt", + "clv", + "clz", + "com", + "cp", + "cpc", + "cpi", + "cpse", + "dec", + "eicall", + "eijmp", + "elpm", + "elpm", + "elpm", + "eor", + "fmul", + "fmuls", + "fmulsu", + "icall", + "ijmp", + "in", + "inc", + "jmp", + "ld", + "ld", + "ld", + "ld", + "ld", + "ld", + "ldd", + "ld", + "ld", + "ld", + "ldd", + "ldi", + "lds", + "lpm", + "lpm", + "lpm", + "lsl", + "lsr", + "mov", + "movw", + "mul", + "muls", + "mulsu", + "neg", + "nop", + "or", + "ori", + "out", + "pop", + "push", + "rcall", + "ret", + "reti", + "rjmp", + "rol", + "ror", + "sbc", + "sbci", + "sbi", + "sbic", + "sbis", + "sbiw", + "sbr", + "sbrc", + "sbrs", + "sec", + "seh", + "sei", + "sen", + "ser", + "ses", + "set", + "sev", + "sez", + "sleep", + "spm", + "st", + "st", + "st", + "st", + "st", + "st", + "std", + "st", + "st", + "st", + "std", + "sts", + "sub", + "subi", + "swap", + "tst", + "wdr" +}; + +const char *Cycles[] = { + "1", // adc + "1", // add + "2", // adiw + "1", // and + "1", // andi + "1", // asr + "1", // bclr + "1", // bld + "1/2", // brbc + "1/2", // brbs + "1/2", // brcc + "1/2", // brcs + "N/A", // break + "1/2", // breq + "1/2", // brge + "1/2", // brhc + "1/2", // brhs + "1/2", // brid + "1/2", // brie + "1/2", // brlo + "1/2", // brlt + "1/2", // brmi + "1/2", // brne + "1/2", // brpl + "1/2", // brsh + "1/2", // brtc + "1/2", // brts + "1/2", // brvc + "1/2", // brvs + "1", // bset + "1", // bst + "4", // call + "2", // cbi + "1", // cbr + "1", // clc + "", // clh + "1", // cli + "1", // cln + "1", // clr + "1", // cls + "1", // clt + "1", // clv + "1", // clz + "1", // com + "1", // cp + "1", // cpc + "1", // cpi + "1-3", // cpse + "1", // dec + NULL, + NULL, + NULL, + NULL, + NULL, + "1", // eor + "2", // fmul + "2", // fmuls + "2", // fmulsu + "3", // icall + "2", // ijmp + "1", // in + "1", // inc + "3", // jmp + "2", // ld + "2", // ld + "2", // ld + "2", // ld + "2", // ld + "2", // ld + "2", // ldd + "2", // ld + "2", // ld + "2", // ld + "2", // ldd + "1", // ldi + "2", // lds + "3", // lpm + "3", // lpm + "3", // lpm + "1", // lsl + "1", // lsr + "1", // mov + "1", // movw + "2", // mul + "2", // muls + "2", // mulsu + "1", // neg + "1", // nop + "1", // or + "1", // ori + "1", // out + "2", // pop + "2", // push + "3", // rcall + "4", // ret + "4", // reti + "2", // rjmp + "1", // rol + "1", // ror + "1", // sbc + "1", // sbci + "2", // sbi + "1-3", // sbic + "1-3", // sbis + "2", // sbiw + "1", // sbr + "1-3", // sbrc + "1-3", // sbrs + "1", // sec + "1", // seh + "1", // sei + "1", // sen + "1", // ser + "1", // ses + "1", // set + "1", // sev + "1", // sez + "1", // sleep + "-", // spm + "2", // st + "2", // st + "2", // st + "2", // st + "2", // st + "2", // st + "2", // std + "2", // st + "2", // st + "2", // st + "2", // std + "2", // sts + "1", // sub + "1", // subi + "1", // swap + "1", // tst + "1" // wdr +}; + +/* +adc +add +adiw +and +andi +asr +bclr +bld +brbc +brbs +brcc +brcs +break +breq +brge +brhc +brhs +brid +brie +brlo +brlt +brmi +brne +brpl +brsh +brtc +brts +brvc +brvs +bset +bst +call +cbi +cbr +clc +clh +cli +cln +clr +cls +clt +clv +clz +com +cp +cpc +cpi +cpse +dec +eicall +eijmp +elpm +elpm +elpm +eor +fmul +fmuls +fmulsu +icall +ijmp +in +inc +jmp +ld +ld +ld +ld +ld +ld +ldd +ld +ld +ld +ldd +ldi +lds +lpm +lpm +lpm +lsl +lsr +mov +movw +mul +muls +mulsu +neg +nop +or +ori +out +pop +push +rcall +ret +reti +rjmp +rol +ror +sbc +sbci +sbi +sbic +sbis +sbiw +sbr +sbrc +sbrs +sec +seh +sei +sen +ser +ses +set +sev +sez +sleep +spm +st +st +st +st +st +st +std +st +st +st +std +sts +sub +subi +swap +tst +wdr +*/ diff --git a/src/MNemonics.h b/src/disasm_mnemonics.h similarity index 77% rename from src/MNemonics.h rename to src/disasm_mnemonics.h index 40e37646..516fd4a4 100644 --- a/src/MNemonics.h +++ b/src/disasm_mnemonics.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,13 +19,11 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ extern const char *MNemonic[]; extern const char *Cycles[]; - - diff --git a/src/disasm_options.c b/src/disasm_options.c new file mode 100644 index 00000000..a7978190 --- /dev/null +++ b/src/disasm_options.c @@ -0,0 +1,188 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include + +#include "disasm_globals.h" +#include "disasm_ioregisters.h" +#include "disasm_tagfile.h" +#include "disasm_options.h" + +#ifndef AVRDISAS_VERSION +#define AVRDISAS_VERSION "dev" +#endif + +void Options_Default(struct Options *Options) { + Options->Show_Addresses = 0; + Options->Show_Opcodes = 0; + Options->Show_Comments = 1; + Options->Show_Cycles = 0; + Options->Show_PseudoCode = 0; + Options->Filename[0] = 0; + Options->MCU[0] = 0; + Options->Tagfile[0] = 0; + Options->CodeStyle = 1; // 0 = AVR Instruction Set, 1 = avr-gcc + Options->Process_Labels = 1; + Options->Pass = 1; + Options->FlashSize = 0; +} + +int StringStart(const char *String1, const char *String2) { + size_t Length1, Length2; + int MinLen; + + Length1 = strlen(String1); + Length2 = strlen(String2); + if(Length1 < Length2) + MinLen = Length1; + else + MinLen = Length2; + + return strncmp(String1, String2, MinLen); +} + +void Show_Help(char *ProgramName) { + fprintf(stderr, "%s [Options] [Filename]\n", ProgramName); + fprintf(stderr, "'n' can either be 0 or 1 and means 'off' or 'on':\n"); + fprintf(stderr, " -an Do or don't show addresses\n"); + fprintf(stderr, " -on Do or don't show opcodes\n"); + fprintf(stderr, " -cn Do or don't show comments\n"); + fprintf(stderr, " -qn Do or don't show call cycles\n"); + fprintf(stderr, " -sn Do or don't use avr-gcc codestyle\n"); + fprintf(stderr, " -pn Do or don't include pseodocode\n"); + fprintf(stderr, " -ln Do or don't do jump/call-preprocessing\n"); + fprintf(stderr, " -mMCU Set the MCU for IO-register resolving\n"); + fprintf(stderr, " -tFile Set the tagfile to be used\n"); + fprintf(stderr, " -fSize Set the size of the flash area\n"); + fprintf(stderr, " --help Show this helppage\n"); + fprintf(stderr, " -h Show this helppage\n"); + fprintf(stderr, "\n"); + fprintf(stderr, "Example:\n"); + fprintf(stderr, "%s -a0 -o1 -c0 -m2313 -s1 -l1 -ttags.txt -f8192 Myfile.bin\n", ProgramName); + fprintf(stderr, "\n"); + fprintf(stderr, "Version: " AVRDISAS_VERSION "\n"); +} + +int SetVal(char *Argument, char *Destination, char *Description, char Min, char Max) { + int Value; + + Value = atoi(Argument); + if((Value < Min) || (Value > Max)) { + fprintf(stderr, "Invalid argument for '%s': must be between %d and %d.\n", Description, Min, Max); + return 0; + } + *Destination = Value; + return 1; +} + +int SetValInt(const char *Argument, int *Destination, char *Description, int Min, int Max) { + int Value; + + Value = atoi(Argument); + if((Value < Min) || (Value > Max)) { + fprintf(stderr, "Invalid argument for '%s': must be between %d and %d.\n", Description, Min, Max); + return 0; + } + *Destination = Value; + return 1; +} + +int SetMCU(char *Argument, char *Destination) { + strncpy(Destination, Argument, 7); + if(ReadIORegisterFile() == 0) { + fprintf(stderr, "Invalid argument for MCU! Must be one of the following:\n"); + // List_Supported_MCUs(); + return 0; + } + return 1; +} + +char Options_ParseCmdLine(struct Options *Options, int argc, char **argv) { + int i; + char *Argument; + + for(i = 1; i < argc; i++) { + Argument = argv[i]; + + if(StringStart(Argument, "-a") == 0) { + if(SetVal(Argument + 2, &(Options->Show_Addresses), "show addresses", 0, 1) == 0) + return 0; + } else if(StringStart(Argument, "-o") == 0) { + if(SetVal(Argument + 2, &(Options->Show_Opcodes), "show opcodes", 0, 1) == 0) + return 0; + } else if(StringStart(Argument, "-c") == 0) { + if(SetVal(Argument + 2, &(Options->Show_Comments), "show comments", 0, 1) == 0) + return 0; + } else if(StringStart(Argument, "-q") == 0) { + if(SetVal(Argument + 2, &(Options->Show_Cycles), "show cycles", 0, 1) == 0) + return 0; + } else if(StringStart(Argument, "-p") == 0) { + if(SetVal(Argument + 2, &(Options->Show_PseudoCode), "show pseudocode", 0, 1) == 0) + return 0; + } else if(StringStart(Argument, "-s") == 0) { + if(SetVal(Argument + 2, &(Options->CodeStyle), "codestyle", 0, 2) == 0) + return 0; + } else if(StringStart(Argument, "-l") == 0) { + if(SetVal(Argument + 2, &(Options->Process_Labels), "process labels", 0, 1) == 0) + return 0; + } else if(StringStart(Argument, "-m") == 0) { + if(SetMCU(Argument + 2, Options->MCU) == 0) + return 0; + } else if(StringStart(Argument, "-t") == 0) { + strncpy(Options->Tagfile, Argument + 2, 256); + } else if(StringStart(Argument, "-f") == 0) { + if(SetValInt(Argument + 2, &(Options->FlashSize), "flash size", 32, 1024 * 1024) == 0) + return 0; + } else if(StringStart(Argument, "--help") == 0) { + Show_Help(argv[0]); + return 0; + } else if(StringStart(Argument, "-h") == 0) { + Show_Help(argv[0]); + return 0; + } else { + if(Options->Filename[0] != 0) { + fprintf(stderr, "Filename '%s' was already supplied!\n", Options->Filename); + return 0; + } + strncpy(Options->Filename, Argument, 255); + } + } + + if(Options->Filename[0] == 0) { + fprintf(stderr, "Error: No filename supplied.\n"); + return 0; + } + + if(Options->Tagfile[0] != 0) { + if(!Read_Tagfile(Options->Tagfile)) + return 0; + } + + return 1; +} diff --git a/src/Options.h b/src/disasm_options.h similarity index 79% rename from src/Options.h rename to src/disasm_options.h index 6358e267..d955f869 100644 --- a/src/Options.h +++ b/src/disasm_options.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,12 +19,11 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ void Options_Default(struct Options *Options); char Options_ParseCmdLine(struct Options *Options, int argc, char **argv); - diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c new file mode 100644 index 00000000..b05646dd --- /dev/null +++ b/src/disasm_tagfile.c @@ -0,0 +1,523 @@ + +/* + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. + + avrdisas is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + avrdisas is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with avrdisas; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de +*/ + +#include +#include +#include +#include + +#include "disasm_tagfile.h" + +struct CodeLabel { + int Address; + char *Text; + char *Comment; +}; + +struct PGMLabel { + int Address; + char Type; + unsigned int Count; + char *Comment; +}; + +struct MemLabel { + int Address; + char Type; + unsigned int Count; + char *Comment; +}; + +static int CodeLabelCount = 0; +static struct CodeLabel *CodeLabels; + +static int PGMLabelCount = 0; +static struct PGMLabel *PGMLabels = NULL; + +static int MemLabelCount = 0; +static struct MemLabel *MemLabels = NULL; + +/* +static void Display_Tagfile() { + int i; + printf("%d code labels:\n", CodeLabelCount); + for(i = 0; i < CodeLabelCount; i++) + printf("%d: 0x%x = %s\n", i, CodeLabels[i].Address, CodeLabels[i].Text); + + printf("%d PGM labels:\n", PGMLabelCount); + for(i = 0; i < PGMLabelCount; i++) + printf("%d: 0x%x = %d * %d\n", i, PGMLabels[i].Address, PGMLabels[i].Count, PGMLabels[i].Type); +} +*/ + +static int LineError(const char *Token, const char *Message, int LineNo) { + if((Token == NULL) || (strlen(Token) == 0)) { + fprintf(stderr, "Error: %s in tagfile, line %d.\n", Message, LineNo); + return 1; + } + return 0; +} + +static int ahtoi(const char *String) { + int Value; + size_t i, l; + + if(strlen(String) < 3) + return atoi(String); + if((String[0] != '0') || (String[1] != 'x')) + return atoi(String); + String += 2; + Value = 0; + l = strlen(String); + for(i = 0; i < l; i++) { + Value *= 16; + if((String[i] >= '0') && (String[i] <= '9')) + Value += String[i] - '0'; + else if((String[i] >= 'a') && (String[i] <= 'f')) + Value += String[i] - 'a' + 10; + else if((String[i] >= 'A') && (String[i] <= 'F')) + Value += String[i] - 'A' + 10; + else + return 0; + } + return Value; +} + +static void Add_LabelTag(int Address, const char *LabelText, const char *LabelComment) { + CodeLabelCount++; + + CodeLabels = (struct CodeLabel *) realloc(CodeLabels, sizeof(struct CodeLabel) * CodeLabelCount); + CodeLabels[CodeLabelCount - 1].Address = Address; + + CodeLabels[CodeLabelCount - 1].Text = (char *) malloc(strlen(LabelText) + 1); + strcpy(CodeLabels[CodeLabelCount - 1].Text, LabelText); + + if(LabelComment != NULL) { + CodeLabels[CodeLabelCount - 1].Comment = (char *) malloc(strlen(LabelComment) + 1); + strcpy(CodeLabels[CodeLabelCount - 1].Comment, LabelComment); + } else { + CodeLabels[CodeLabelCount - 1].Comment = NULL; + } +} + +static void Add_PGM_Tag(int Address, char Type, unsigned int Count, const char *Comment) { + PGMLabelCount++; + + PGMLabels = (struct PGMLabel *) realloc(PGMLabels, sizeof(struct PGMLabel) * PGMLabelCount); + PGMLabels[PGMLabelCount - 1].Address = Address; + PGMLabels[PGMLabelCount - 1].Type = Type; + PGMLabels[PGMLabelCount - 1].Count = Count; + if(Comment != NULL) { + PGMLabels[PGMLabelCount - 1].Comment = (char *) malloc(strlen(Comment) + 1); + strcpy(PGMLabels[PGMLabelCount - 1].Comment, Comment); + } else { + PGMLabels[PGMLabelCount - 1].Comment = NULL; + } +} + +static void Add_Mem_Tag(int Address, char Type, unsigned int Count, const char *Comment) { + MemLabelCount++; + + MemLabels = (struct MemLabel *) realloc(MemLabels, sizeof(struct MemLabel) * MemLabelCount); + MemLabels[MemLabelCount - 1].Address = Address; + MemLabels[MemLabelCount - 1].Type = Type; + MemLabels[MemLabelCount - 1].Count = Count; + if(Comment != NULL) { + MemLabels[MemLabelCount - 1].Comment = (char *) malloc(strlen(Comment) + 1); + strcpy(MemLabels[MemLabelCount - 1].Comment, Comment); + } else { + MemLabels[MemLabelCount - 1].Comment = NULL; + } +} + +static void Tagfile_Readline(char *Line, int LineNo) { + char *Token; + int Address; + char Type, Subtype; + int Count; + + if(Line[0] == '#') + return; + if(strlen(Line) <= 1) + return; + + Token = strtok(Line, "\t\n"); + if(LineError(Token, "nonempty line", LineNo)) + return; + + // Token now holds an address, determine if hex or dec + Address = ahtoi(Token); + + Token = strtok(NULL, "\t\n"); + if(LineError(Token, "no second argument", LineNo)) + return; + if(strlen(Token) != 1) { + LineError(NULL, "second argument too long", LineNo); + return; + } + + Type = Token[0]; + Token = strtok(NULL, "\t\n"); + if(LineError(Token, "no third argument", LineNo)) + return; + + if(Type == 'L') { + char *LabelName = Token; + + Token = strtok(NULL, "\t\n"); + Add_LabelTag(Address, LabelName, Token); + return; + } + + if(LineError(Token, "no fourth argument", LineNo)) + return; + Subtype = Token[0]; + + // Either B(yte), W(ord), A(utoterminated string) or S(tring) + switch (Subtype) { + case 'B': + Subtype = TYPE_BYTE; + break; + case 'W': + Subtype = TYPE_WORD; + break; + case 'A': + Subtype = TYPE_ASTRING; + break; + case 'S': + Subtype = TYPE_STRING; + break; + default: + Subtype = 0; + } + if(!Subtype) { + LineError(NULL, "invalid type (expected one of L, B, W, A or S)", LineNo); + return; + } + if((Type == 'M') && ((Subtype != TYPE_BYTE) && (Subtype != TYPE_WORD))) { + LineError(NULL, "memory labels can only be of type B or W", LineNo); + return; + } + + Token = strtok(NULL, "\t\n"); + Count = ahtoi(Token); + if(Count < 1) { + LineError(NULL, "invalid count given", LineNo); + return; + } + + Token = strtok(NULL, "\t\n"); + if(Type == 'P') { + Add_PGM_Tag(Address, Subtype, Count, Token); + } else if(Type == 'M') { + Add_Mem_Tag(Address, Subtype, Count, Token); + } else { + fprintf(stderr, "Invalid tag type '%c'.\n", Type); + } +} + +static int CodeLabelSort(const void *A, const void *B) { + const struct CodeLabel *X, *Y; + + X = (const struct CodeLabel *) A; + Y = (const struct CodeLabel *) B; + if(X->Address == Y->Address) + return 0; + if(X->Address < Y->Address) + return -1; + return 1; +} + +static int PGMLabelSort(const void *A, const void *B) { + const struct PGMLabel *X, *Y; + + X = (const struct PGMLabel *) A; + Y = (const struct PGMLabel *) B; + if(X->Address == Y->Address) + return 0; + if(X->Address < Y->Address) + return -1; + return 1; +} + +static int MemLabelSort(const void *A, const void *B) { + const struct MemLabel *X, *Y; + + X = (const struct MemLabel *) A; + Y = (const struct MemLabel *) B; + if(X->Address == Y->Address) + return 0; + if(X->Address < Y->Address) + return -1; + return 1; +} + +static void Tagfile_SortLabels() { + qsort(CodeLabels, CodeLabelCount, sizeof(struct CodeLabel), CodeLabelSort); + qsort(PGMLabels, PGMLabelCount, sizeof(struct PGMLabel), PGMLabelSort); + qsort(MemLabels, MemLabelCount, sizeof(struct MemLabel), MemLabelSort); +} + +int Read_Tagfile(const char *Filename) { + FILE *f; + + f = fopen(Filename, "r"); + if(!f) { + fprintf(stderr, "Error opening tagfile '%s': %s\n", Filename, strerror(errno)); + return 0; + } + + { + char Buffer[256]; + int LineNo = 1; + + while(fgets(Buffer, sizeof(Buffer), f) != NULL) { + Tagfile_Readline(Buffer, LineNo++); + } + } + + fclose(f); + + Tagfile_SortLabels(); + return 1; +} + +int Tagfile_FindLabelAddress(int Address) { + struct CodeLabel Goal; + struct CodeLabel *Result; + + Goal.Address = Address; + Result = bsearch(&Goal, CodeLabels, CodeLabelCount, sizeof(struct CodeLabel), CodeLabelSort); + if(Result == NULL) + return -1; + return Result - CodeLabels; +} + +char *Tagfile_GetLabel(int TagIndex) { + return CodeLabels[TagIndex].Text; +} + +char *Tagfile_GetLabelComment(int TagIndex) { + return CodeLabels[TagIndex].Comment; +} + +int Tagfile_FindPGMAddress(int Address) { + struct PGMLabel Goal; + struct PGMLabel *Result; + + Goal.Address = Address; + Result = bsearch(&Goal, PGMLabels, PGMLabelCount, sizeof(struct PGMLabel), PGMLabelSort); + if(Result == NULL) + return -1; + return Result - PGMLabels; +} + +const char *Tagfile_Resolve_Mem_Address(int Address) { + static char Buffer[64]; + int i; + + for(i = 0; i < MemLabelCount; i++) { + int Start, End, Size; + + Size = 0; + if(MemLabels[i].Address > Address) + return NULL; + + Start = MemLabels[i].Address; + switch (MemLabels[i].Type) { + case TYPE_BYTE: + Size = 1; + break; + case TYPE_WORD: + Size = 2; + break; + } + End = MemLabels[i].Address + MemLabels[i].Count * Size - 1; + + if((Address >= Start) && (Address <= End)) { + if(MemLabels[i].Count == 1) { + // Single variable + if(Size == 1) { + strncpy(Buffer, MemLabels[i].Comment, sizeof(Buffer)); + } else { + if((Address - Start) == 0) { + snprintf(Buffer, sizeof(Buffer), "_lo8(%s)", MemLabels[i].Comment); + } else { + snprintf(Buffer, sizeof(Buffer), "_hi8(%s)", MemLabels[i].Comment); + } + } + } else { + // Array + if(Size == 1) { + snprintf(Buffer, sizeof(Buffer), "%s[%d]", MemLabels[i].Comment, (Address - Start) / 1); + } else { + int HiLo = (Address - Start) % 2; + + if(HiLo == 0) { + snprintf(Buffer, sizeof(Buffer), "_lo8(%s[%d])", MemLabels[i].Comment, (Address - Start) / 2); + } else { + snprintf(Buffer, sizeof(Buffer), "_hi8(%s[%d])", MemLabels[i].Comment, (Address - Start) / 2); + } + } + } + return Buffer; + } + } + return NULL; +} + +static int Tagfile_Process_Byte(char *Bitstream, int Position, int ArgumentNo, const char *Label) { + printf(".byte 0x%02x\n", ((unsigned char *) Bitstream)[Position]); + return 1; +} + +static int Tagfile_Process_Word(char *Bitstream, int Position, int ArgumentNo, const char *Label) { + printf(".word 0x%02x%02x\n", ((unsigned char *) Bitstream)[Position + 1], ((unsigned char *) Bitstream)[Position]); + return 2; +} + +static int Tagfile_Process_String(char *Bitstream, int Position, int ArgumentNo, const char *Label) { + int i; + unsigned char c; + unsigned int InString = 0; + + printf("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); + i = 0; + while((c = ((unsigned char *) Bitstream)[Position + i])) { + if((c >= 32) && (c <= 127)) { + if(!InString) + printf(".ascii \""); + printf("%c", c); + InString = 1; + } else { + if(InString) + printf("\"\n"); + printf(".byte 0x%02x\n", c); + InString = 0; + } + i++; + } + if(InString) + printf("\\0\"\n"); + else + printf(".byte 0x00\n"); + + printf("\n"); + return i + 1; +} + +static void Sanitize_String(char *String) { + size_t i; + size_t l = strlen(String); + + for(i = 0; i < l; i++) { + if(!(((String[i] >= 'a') && (String[i] <= 'z')) || + (((String[i] >= 'A') && (String[i] <= 'Z'))) || (((String[i] >= '0') && (String[i] <= '9'))))) { + String[i] = '_'; + } + } +} + +int Tagfile_Process_Data(char *Bitstream, int Position) { + int i; + int BytesAdvanced; + int Index; + int (*ProcessingFunction)(char *, int, int, const char *) = NULL; + char Buffer[32]; + + Index = Tagfile_FindPGMAddress(Position); + if(Index == -1) + return 0; + + switch (PGMLabels[Index].Type) { + case TYPE_BYTE: + ProcessingFunction = Tagfile_Process_Byte; + break; + case TYPE_WORD: + ProcessingFunction = Tagfile_Process_Word; + break; + case TYPE_ASTRING: + ProcessingFunction = Tagfile_Process_String; + break; + case TYPE_STRING: + ProcessingFunction = Tagfile_Process_String; + break; + } + + printf("; Inline PGM data: %d ", PGMLabels[Index].Count); + switch (PGMLabels[Index].Type) { + case TYPE_BYTE: + printf("byte"); + break; + case TYPE_WORD: + printf("word"); + break; + case TYPE_ASTRING: + printf("autoaligned string"); + break; + case TYPE_STRING: + printf("string"); + break; + } + if(PGMLabels[Index].Count != 1) + printf("s"); + printf(" starting at 0x%x", Position); + + if(PGMLabels[Index].Comment != NULL) { + printf(" (%s)", PGMLabels[Index].Comment); + } + printf("\n"); + + if((PGMLabels[Index].Type == TYPE_ASTRING) || (PGMLabels[Index].Type == TYPE_STRING)) { + if(PGMLabels[Index].Comment != NULL) { + snprintf(Buffer, sizeof(Buffer), "%x_%s", Position, PGMLabels[Index].Comment); + Sanitize_String(Buffer); + } else { + snprintf(Buffer, sizeof(Buffer), "%x", Position); + } + } + + BytesAdvanced = 0; + for(i = 0; i < PGMLabels[Index].Count; i++) { + BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, i, Buffer); + } + + if(PGMLabels[Index].Type == TYPE_ASTRING) { + // Autoaligned string + if((BytesAdvanced % 2) != 0) { + // Not yet aligned correctly + if(Bitstream[Position + BytesAdvanced] != 0x00) + fprintf(stderr, "Warning in autoalignment: expected zero but got 0x%0x padding. Ignored.\n", + ((unsigned char *) Bitstream)[Position + BytesAdvanced]); + printf(".byte 0x%02x ; String Autoalignment\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); + BytesAdvanced++; + } + } + + printf("\n"); + return BytesAdvanced; +} diff --git a/src/Tagfile.h b/src/disasm_tagfile.h similarity index 72% rename from src/Tagfile.h rename to src/disasm_tagfile.h index d41c53b5..703be183 100644 --- a/src/Tagfile.h +++ b/src/disasm_tagfile.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,22 +19,21 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ -#define TYPE_BYTE 1 -#define TYPE_WORD 2 -#define TYPE_ASTRING 3 -#define TYPE_STRING 4 +#define TYPE_BYTE 1 +#define TYPE_WORD 2 +#define TYPE_ASTRING 3 +#define TYPE_STRING 4 int Read_Tagfile(const char *Filename); int Tagfile_FindLabelAddress(int Address); char *Tagfile_GetLabel(int TagIndex); char *Tagfile_GetLabelComment(int TagIndex); int Tagfile_FindPGMAddress(int Address); -const char* Tagfile_Resolve_Mem_Address(int Address); +const char *Tagfile_Resolve_Mem_Address(int Address); int Tagfile_Process_Data(char *Bitstream, int Position); - diff --git a/src/Tools.c b/src/disasm_tools.c similarity index 66% rename from src/Tools.c rename to src/disasm_tools.c index f39a35cc..5dcf421c 100644 --- a/src/Tools.c +++ b/src/disasm_tools.c @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,20 +19,22 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ -#include "Tools.h" +#include "disasm_tools.h" unsigned char BitCount(unsigned char Number) { - unsigned char Result = 0; - int i; - for (i = 0; i < 8; i++) { - if (Number & 0x01) Result++; - Number >>= 1; - } - return Result; + unsigned char Result = 0; + int i; + + for(i = 0; i < 8; i++) { + if(Number & 0x01) + Result++; + Number >>= 1; + } + return Result; } diff --git a/src/Tools.h b/src/disasm_tools.h similarity index 77% rename from src/Tools.h rename to src/disasm_tools.h index 2bfcd164..64785253 100644 --- a/src/Tools.h +++ b/src/disasm_tools.h @@ -1,8 +1,9 @@ + /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. + avrdisas - A disassembler for AVR microcontroller units + Copyright (C) 2007 Johannes Bauer + + This file is part of avrdisas. avrdisas is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,10 +19,10 @@ along with avrdisas; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de + Johannes Bauer + Mussinanstr. 140 + 92318 Neumarkt/Opf. + JohannesBauer@gmx.de */ unsigned char BitCount(unsigned char Number); From b2ead9a4efd6fa9112361217bf3683011ebfcf67 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 11:10:55 +0100 Subject: [PATCH 274/422] Make disasm files part of compilation --- src/CMakeLists.txt | 19 +++++++++++++++++++ src/Makefile.am | 19 +++++++++++++++++++ src/disasm.c | 4 ++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d8a2669..ff7ac84b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -180,6 +180,25 @@ add_library(libavrdude confwin.c crc16.c crc16.h + disasm.c + disasm_callbacks_assembly.c + disasm_callbacks_assembly.h + disasm_callbacks_pseudocode.c + disasm_callbacks_pseudocode.h + disasm_functions.h + disasm_globals.h + disasm_ioregisters.c + disasm_ioregisters.h + disasm_jumpcall.c + disasm_jumpcall.h + disasm_mnemonics.c + disasm_mnemonics.h + disasm_options.c + disasm_options.h + disasm_tagfile.c + disasm_tagfile.h + disasm_tools.c + disasm_tools.h dfu.c dfu.h dryrun.c diff --git a/src/Makefile.am b/src/Makefile.am index 9e7a76ad..bdb7fb2b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -118,6 +118,25 @@ libavrdude_a_SOURCES = \ confwin.c \ crc16.c \ crc16.h \ + disasm.c \ + disasm_callbacks_assembly.c \ + disasm_callbacks_assembly.h \ + disasm_callbacks_pseudocode.c \ + disasm_callbacks_pseudocode.h \ + disasm_functions.h \ + disasm_globals.h \ + disasm_ioregisters.c \ + disasm_ioregisters.h \ + disasm_jumpcall.c \ + disasm_jumpcall.h \ + disasm_mnemonics.c \ + disasm_mnemonics.h \ + disasm_options.c \ + disasm_options.h \ + disasm_tagfile.c \ + disasm_tagfile.h \ + disasm_tools.c \ + disasm_tools.h \ dfu.c \ dfu.h \ dryrun.c \ diff --git a/src/disasm.c b/src/disasm.c index 3f097803..a9c852be 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -197,7 +197,7 @@ int Match_Opcode(char *Bitmask, char *Bitstream) { } else { if(Stream_Val == 0) { - /*/printf("\nMatch failed.\n") + // printf("\nMatch failed.\n") return 0; } } @@ -404,7 +404,7 @@ int Comparison(const void *Element1, const void *Element2) { return -1; } -int main(int argc, char **argv) { +int disasm(int argc, char **argv) { Options_Default(&Options); if(!Options_ParseCmdLine(&Options, argc, argv)) return 1; From d3dbf3505abc1d503e87b048b84296fe3b8d9de4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 11:17:14 +0100 Subject: [PATCH 275/422] Remove tools.[ch] and functions.h & rewrite BitCount() --- src/CMakeLists.txt | 3 --- src/Makefile.am | 3 --- src/disasm_callbacks_assembly.c | 13 ++++++++-- src/disasm_callbacks_pseudocode.c | 1 - src/disasm_functions.h | 35 --------------------------- src/disasm_tools.c | 40 ------------------------------- src/disasm_tools.h | 28 ---------------------- 7 files changed, 11 insertions(+), 112 deletions(-) delete mode 100644 src/disasm_functions.h delete mode 100644 src/disasm_tools.c delete mode 100644 src/disasm_tools.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ff7ac84b..4c60b388 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -185,7 +185,6 @@ add_library(libavrdude disasm_callbacks_assembly.h disasm_callbacks_pseudocode.c disasm_callbacks_pseudocode.h - disasm_functions.h disasm_globals.h disasm_ioregisters.c disasm_ioregisters.h @@ -197,8 +196,6 @@ add_library(libavrdude disasm_options.h disasm_tagfile.c disasm_tagfile.h - disasm_tools.c - disasm_tools.h dfu.c dfu.h dryrun.c diff --git a/src/Makefile.am b/src/Makefile.am index bdb7fb2b..77453850 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,7 +123,6 @@ libavrdude_a_SOURCES = \ disasm_callbacks_assembly.h \ disasm_callbacks_pseudocode.c \ disasm_callbacks_pseudocode.h \ - disasm_functions.h \ disasm_globals.h \ disasm_ioregisters.c \ disasm_ioregisters.h \ @@ -135,8 +134,6 @@ libavrdude_a_SOURCES = \ disasm_options.h \ disasm_tagfile.c \ disasm_tagfile.h \ - disasm_tools.c \ - disasm_tools.h \ dfu.c \ dfu.h \ dryrun.c \ diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index c0c74c7c..ea075de4 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -33,8 +33,6 @@ #include "disasm_callbacks_assembly.h" #include "disasm_jumpcall.h" #include "disasm_ioregisters.h" -#include "disasm_functions.h" -#include "disasm_tools.h" #include "disasm_tagfile.h" static char *Code_Line; @@ -52,6 +50,17 @@ void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_A Options = New_Options; } +// Return the number of bits set in Number +static unsigned BitCount(unsigned n) { + unsigned ret; + + // A la Kernighan (and Richie): iteratively clear the least significant bit set + for(ret = 0; n; ret++) + n &= n -1; + + return ret; +} + void Operation_Simple(int MNemonic_Int) { snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); } diff --git a/src/disasm_callbacks_pseudocode.c b/src/disasm_callbacks_pseudocode.c index 16b0701e..c23af1ba 100644 --- a/src/disasm_callbacks_pseudocode.c +++ b/src/disasm_callbacks_pseudocode.c @@ -33,7 +33,6 @@ #include "disasm_callbacks_pseudocode.h" #include "disasm_jumpcall.h" #include "disasm_ioregisters.h" -#include "disasm_functions.h" #include "disasm_tagfile.h" static char *Code_Line; diff --git a/src/disasm_functions.h b/src/disasm_functions.h deleted file mode 100644 index f97b1594..00000000 --- a/src/disasm_functions.h +++ /dev/null @@ -1,35 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#ifdef DOS_BASED_OS -#define snprintf _snprintf -#endif - -#ifdef DESPERATE_SPRINTF_FALLBACK -#warning "Your C library does not support snprintf. Please upgrade! Fallback to sprintf used." -#define snprintf(dest, len, str...) sprintf(dest, str) -#endif diff --git a/src/disasm_tools.c b/src/disasm_tools.c deleted file mode 100644 index 5dcf421c..00000000 --- a/src/disasm_tools.c +++ /dev/null @@ -1,40 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include "disasm_tools.h" - -unsigned char BitCount(unsigned char Number) { - unsigned char Result = 0; - int i; - - for(i = 0; i < 8; i++) { - if(Number & 0x01) - Result++; - Number >>= 1; - } - return Result; -} diff --git a/src/disasm_tools.h b/src/disasm_tools.h deleted file mode 100644 index 64785253..00000000 --- a/src/disasm_tools.h +++ /dev/null @@ -1,28 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -unsigned char BitCount(unsigned char Number); From ec285290febd608fce420756e87faff9fd272f9c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 14:43:34 +0100 Subject: [PATCH 276/422] Remove option parsing from disasm files --- src/CMakeLists.txt | 2 - src/Makefile.am | 2 - src/disasm.c | 87 ++++---------- src/disasm_callbacks_assembly.c | 26 ++--- src/disasm_callbacks_assembly.h | 2 +- src/disasm_callbacks_pseudocode.c | 22 ++-- src/disasm_callbacks_pseudocode.h | 2 +- src/disasm_globals.h | 18 --- src/disasm_ioregisters.c | 10 +- src/disasm_jumpcall.c | 11 +- src/disasm_mnemonics.c | 2 + src/disasm_options.c | 188 ------------------------------ src/disasm_options.h | 29 ----- src/disasm_tagfile.c | 2 + src/libavrdude.h | 25 ++++ 15 files changed, 90 insertions(+), 338 deletions(-) delete mode 100644 src/disasm_options.c delete mode 100644 src/disasm_options.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c60b388..abab7c60 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,8 +192,6 @@ add_library(libavrdude disasm_jumpcall.h disasm_mnemonics.c disasm_mnemonics.h - disasm_options.c - disasm_options.h disasm_tagfile.c disasm_tagfile.h dfu.c diff --git a/src/Makefile.am b/src/Makefile.am index 77453850..f0b76811 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -130,8 +130,6 @@ libavrdude_a_SOURCES = \ disasm_jumpcall.h \ disasm_mnemonics.c \ disasm_mnemonics.h \ - disasm_options.c \ - disasm_options.h \ disasm_tagfile.c \ disasm_tagfile.h \ dfu.c \ diff --git a/src/disasm.c b/src/disasm.c index a9c852be..a7f9c86b 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -33,22 +33,20 @@ #include #include +#include "libavrdude.h" + #include "disasm_globals.h" #include "disasm_callbacks_assembly.h" #include "disasm_callbacks_pseudocode.h" -#include "disasm_options.h" #include "disasm_jumpcall.h" #include "disasm_ioregisters.h" #include "disasm_mnemonics.h" #include "disasm_tagfile.h" -#define READ_BUFFER 131072 // 128 kB - static int Number_Opcodes = 0; static struct Opcode Opcodes[256]; static int Registers[256]; -struct Options Options; static char Code_Line[256]; static char Comment_Line[256]; static char After_Code_Line[256]; @@ -225,50 +223,15 @@ int Get_Next_Opcode(char *Bitstream) { return -1; } -void Disassemble(char *Filename) { - FILE *f; - char Bitstream[READ_BUFFER]; - int Read; +void Disassemble(char *Bitstream, int Read) { int Pos; int Opcode; int i; -#ifndef DOS_BASED_OS - f = fopen(Filename, "r"); -#else - f = fopen(Filename, "rb"); -#endif - - if(!f) { - fprintf(stderr, "Error opening file '%s' for disassembly: %s\n", Filename, strerror(errno)); - return; - } - - if(Options.Show_PseudoCode == 1) { - printf("#include \n"); - printf("\n"); - printf("/* Disassembly of %s (pseudocode) */\n", Filename); - printf("\n"); - printf("int r0, r1, r2, r3, r4, r5, r6, r7, r8, r9;\n"); - printf("int r10, r11, r12, r13, r14, r15, r16, r17, r18, r19;\n"); - printf("int r20, r21, r22, r23, r24, r25, r26, r27, r28, r29;\n"); - printf("int r30, r31, r32;\n"); - printf("\n"); - printf("int main(int argc, char **argv) {\n"); - } else { - if(Options.CodeStyle == CODESTYLE_AVRGCC) { - printf("; Disassembly of %s (avr-gcc style)\n", Filename); - } else { - printf("; Disassembly of %s (AVR instruction set style)\n", Filename); - } - printf("\n"); - } - - Read = fread(Bitstream, 1, READ_BUFFER, f); - Options.Pass = 1; + cx->dis_opts.Pass = 1; Pos = 0; - if((Options.Process_Labels == 1) || ((!Options.Show_PseudoCode) && (Options.CodeStyle == CODESTYLE_AVRGCC))) { + if((cx->dis_opts.Process_Labels == 1) || ((!cx->dis_opts.Show_PseudoCode) && (cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC))) { // Preprocess to gather jump labels or to gain knowledge about registers which are being used while(Pos < Read) { Opcode = Get_Next_Opcode(Bitstream + Pos); @@ -280,15 +243,12 @@ void Disassemble(char *Filename) { } } Enumerate_Labels(); - Options.Pass = 2; + cx->dis_opts.Pass = 2; Pos = 0; } - if(Options.CodeStyle == CODESTYLE_AVRGCC) { + if(cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC) Emit_Used_IO_Registers(); - printf(".text\n"); - printf("main:\n"); - } while(Pos < Read) { int Added; @@ -308,13 +268,13 @@ void Disassemble(char *Filename) { After_Code_Line[0] = 0; Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); - if(Options.Process_Labels) { + if(cx->dis_opts.Process_Labels) { Print_JumpCalls(Pos); } - if(Options.Show_Addresses) + if(cx->dis_opts.Show_Addresses) printf("%4x: ", Pos); - if(Options.Show_Cycles) { + if(cx->dis_opts.Show_Cycles) { const char *Cycle = Cycles[Opcodes[Opcode].MNemonic]; if(!Cycle) @@ -323,7 +283,7 @@ void Disassemble(char *Filename) { printf("[%-3s] ", Cycle); } - if(Options.Show_Opcodes) { + if(cx->dis_opts.Show_Opcodes) { // Now display the Opcode for(i = 0; i < (Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8; i++) { printf("%02x ", (unsigned char) (Bitstream[Pos + i])); @@ -339,12 +299,12 @@ void Disassemble(char *Filename) { // No code was generated? printf("; - Not implemented opcode: %d -\n", Opcodes[Opcode].MNemonic); } else { - if((Comment_Line[0] == 0) || (!Options.Show_Comments)) { + if((Comment_Line[0] == 0) || (!cx->dis_opts.Show_Comments)) { // No comment printf("%s\n", Code_Line); } else { // Comment available - if(!Options.Show_PseudoCode) { + if(!cx->dis_opts.Show_PseudoCode) { printf("%-23s ; %s\n", Code_Line, Comment_Line); } else { printf("%-35s ; %s\n", Code_Line, Comment_Line); @@ -360,9 +320,8 @@ void Disassemble(char *Filename) { Pos += 2; } } - fclose(f); - if(Options.Show_PseudoCode) { + if(cx->dis_opts.Show_PseudoCode) { // { printf("}\n"); printf("\n"); } @@ -404,13 +363,15 @@ int Comparison(const void *Element1, const void *Element2) { return -1; } -int disasm(int argc, char **argv) { - Options_Default(&Options); - if(!Options_ParseCmdLine(&Options, argc, argv)) - return 1; +int disasm(char *Bitstream, int Read, int addr) { + if(cx->dis_opts.Tagfile) + if(!Read_Tagfile(cx->dis_opts.Tagfile)) + return 0; - Activate_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &Options); - Activate_PC_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &Options); + Number_Opcodes = 0; + + Activate_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &cx->dis_opts); + Activate_PC_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &cx->dis_opts); Register_Opcode(adc_Callback, "0001 11rd dddd rrrr", OPCODE_adc); Register_Opcode(add_Callback, "0000 11rd dddd rrrr", OPCODE_add); Register_Opcode(adiw_Callback, "1001 0110 KKdd KKKK", OPCODE_adiw); @@ -551,7 +512,7 @@ int disasm(int argc, char **argv) { // Register_Opcode(tst_Callback, "0010 00dd dddd dddd", OPCODE_tst); // Implied by and Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); - if(Options.Show_PseudoCode) { + if(cx->dis_opts.Show_PseudoCode) { Supersede_Opcode(adc_Callback_PC, OPCODE_adc); Supersede_Opcode(add_Callback_PC, OPCODE_add); Supersede_Opcode(sub_Callback_PC, OPCODE_sub); @@ -620,6 +581,6 @@ int disasm(int argc, char **argv) { qsort(Opcodes, Number_Opcodes, sizeof(struct Opcode), Comparison); - Disassemble(Options.Filename); + Disassemble(Bitstream, Read); return 0; } diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index ea075de4..ca980c95 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -28,6 +28,8 @@ #include #include +#include "libavrdude.h" + #include "disasm_mnemonics.h" #include "disasm_globals.h" #include "disasm_callbacks_assembly.h" @@ -39,15 +41,13 @@ static char *Code_Line; static char *Comment_Line; static char *After_Code_Line; static int *Registers; -static struct Options *Options; void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, - struct Options *New_Options) { + Disasm_options *New_Options) { Code_Line = New_Code_Line; Comment_Line = New_Comment_Line; After_Code_Line = New_After_Code_Line; Registers = New_Registers; - Options = New_Options; } // Return the number of bits set in Number @@ -92,7 +92,7 @@ void Operation_Rd_K(int MNemonic_Int) { } void Operation_RdW_K(int MNemonic_Int) { - if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); } else { snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); @@ -101,7 +101,7 @@ void Operation_RdW_K(int MNemonic_Int) { } void Operation_RdW_RrW(int MNemonic_Int) { - if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); } else { snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); @@ -119,7 +119,7 @@ void Operation_s_k(int MNemonic_Int, int Position) { Target = FixTargetAddress(Position + Offset + 2); Register_JumpCall(Position, Target, MNemonic_Int, 0); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); } else { @@ -184,7 +184,7 @@ void Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { Target = FixTargetAddress(Position + Offset + 2); Register_JumpCall(Position, Target, MNemonic_Int, 0); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); } else { @@ -215,7 +215,7 @@ CALLBACK(add_Callback) { } CALLBACK(adiw_Callback) { - if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); } else { snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); @@ -350,7 +350,7 @@ CALLBACK(call_Callback) { Pos = FixTargetAddress(2 * Rk); Register_JumpCall(Position, Pos, MNemonic_Int, 1); - if(!Options->Process_Labels) { + if(!cx->dis_opts.Process_Labels) { snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); } else { char *LabelName; @@ -493,7 +493,7 @@ CALLBACK(jmp_Callback) { int Pos; Pos = FixTargetAddress(2 * Rk); - if(!Options->Process_Labels) { + if(!cx->dis_opts.Process_Labels) { snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); } else { snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Pos, NULL)); @@ -644,7 +644,7 @@ CALLBACK(rcall_Callback) { Target = FixTargetAddress(Position + Offset + 2); Register_JumpCall(Position, Target, MNemonic_Int, 1); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); } else { @@ -682,7 +682,7 @@ CALLBACK(rjmp_Callback) { Register_JumpCall(Position, Target, MNemonic_Int, 0); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); } else { @@ -723,7 +723,7 @@ CALLBACK(sbis_Callback) { } CALLBACK(sbiw_Callback) { - if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); } else { snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); diff --git a/src/disasm_callbacks_assembly.h b/src/disasm_callbacks_assembly.h index ec9783b8..33971f80 100644 --- a/src/disasm_callbacks_assembly.h +++ b/src/disasm_callbacks_assembly.h @@ -26,7 +26,7 @@ */ void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, - struct Options *New_Options); + Disasm_options *New_Options); void Operation_Simple(int MNemonic_Int); void Operation_Rd(int MNemonic_Int); void Operation_Rd16(int MNemonic_Int); diff --git a/src/disasm_callbacks_pseudocode.c b/src/disasm_callbacks_pseudocode.c index c23af1ba..6da390fa 100644 --- a/src/disasm_callbacks_pseudocode.c +++ b/src/disasm_callbacks_pseudocode.c @@ -28,6 +28,8 @@ #include #include +#include "libavrdude.h" + #include "disasm_mnemonics.h" #include "disasm_globals.h" #include "disasm_callbacks_pseudocode.h" @@ -39,15 +41,13 @@ static char *Code_Line; static char *Comment_Line; static char *After_Code_Line; static int *Registers; -static struct Options *Options; void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, - struct Options *New_Options) { + Disasm_options *New_Options) { Code_Line = New_Code_Line; Comment_Line = New_Comment_Line; After_Code_Line = New_After_Code_Line; Registers = New_Registers; - Options = New_Options; } void PC_Operation_Simple(int MNemonic_Int) { @@ -186,7 +186,7 @@ void PC_Operation_Rd_K(int MNemonic_Int) { } void PC_Operation_RdW_K(int MNemonic_Int) { - if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); } else { snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); @@ -195,7 +195,7 @@ void PC_Operation_RdW_K(int MNemonic_Int) { } void PC_Operation_RdW_RrW(int MNemonic_Int) { - if(Options->CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { + if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); } else { snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); @@ -213,7 +213,7 @@ void PC_Operation_s_k(int MNemonic_Int, int Position) { int Target = FixTargetAddress(Position + Offset + 2); Register_JumpCall(Position, Target, MNemonic_Int, 0); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); } else { @@ -293,7 +293,7 @@ void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { int Target = FixTargetAddress(Position + Offset + 2); Register_JumpCall(Position, Target, MNemonic_Int, 0); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(Code_Line, 255, "if (%s) goto .+%d;", Pseudocode, Offset); } else { @@ -501,7 +501,7 @@ CALLBACK(call_Callback_PC) { Pos = FixTargetAddress(2 * Rk); Register_JumpCall(Position, Pos, MNemonic_Int, 1); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { snprintf(Code_Line, 255, "0x%02x();", Pos); } else { char *LabelName; @@ -525,7 +525,7 @@ CALLBACK(rcall_Callback_PC) { int Target = FixTargetAddress(Position + Offset + 2); Register_JumpCall(Position, Target, MNemonic_Int, 1); - if(!Options->Process_Labels) { + if(!cx->dis_opts.Process_Labels) { snprintf(Comment_Line, 255, "0x%02x();", Target); } else { char *LabelName; @@ -563,7 +563,7 @@ CALLBACK(jmp_Callback_PC) { int Pos; Pos = FixTargetAddress(2 * Rk); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { snprintf(Code_Line, 255, "goto 0x%02x;", Pos); } else { snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Pos, NULL)); @@ -582,7 +582,7 @@ CALLBACK(rjmp_Callback_PC) { Register_JumpCall(Position, Target, MNemonic_Int, 0); - if(Options->Process_Labels == 0) { + if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(Code_Line, 255, "goto .+%d;", Offset); } else { diff --git a/src/disasm_callbacks_pseudocode.h b/src/disasm_callbacks_pseudocode.h index c37fef52..b89fcaf3 100644 --- a/src/disasm_callbacks_pseudocode.h +++ b/src/disasm_callbacks_pseudocode.h @@ -26,7 +26,7 @@ */ void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, - struct Options *New_Options); + Disasm_options *New_Options); void PC_Operation_Simple(int MNemonic_Int); void PC_Operation_Rd(int MNemonic_Int); void PC_Operation_Rd16(int MNemonic_Int); diff --git a/src/disasm_globals.h b/src/disasm_globals.h index c648d661..024292a1 100644 --- a/src/disasm_globals.h +++ b/src/disasm_globals.h @@ -36,9 +36,6 @@ #define CALLBACK(name) void name(char *Bitstream, int Position, int MNemonic_Int) -#define CODESTYLE_AVR_INSTRUCTION_SET 0 -#define CODESTYLE_AVRGCC 1 - struct Opcode { char *Opcode_String; void (*Callback)(char *, int, int); @@ -53,21 +50,6 @@ struct JumpCall { unsigned char FunctionCall; }; -struct Options { - char Show_Addresses; - char Show_Opcodes; - char Show_Comments; - char Show_Cycles; - char Show_PseudoCode; - char Filename[256]; - char MCU[8]; - char Tagfile[256]; - char CodeStyle; - char Process_Labels; - char Pass; - int FlashSize; -}; - struct IO_Register { int Address; char Name[16]; diff --git a/src/disasm_ioregisters.c b/src/disasm_ioregisters.c index b4d4ec8b..ce87ca49 100644 --- a/src/disasm_ioregisters.c +++ b/src/disasm_ioregisters.c @@ -29,9 +29,9 @@ #include #include -#include "disasm_globals.h" +#include "libavrdude.h" -extern struct Options Options; +#include "disasm_globals.h" static struct IO_Register *KnownIORegisters = NULL; static unsigned int KnownIORegistersCount = 0; @@ -82,7 +82,7 @@ unsigned int ReadIORegisterFile() { } else if(!strcmp(Token, "Unit")) { if(!(Token = strtok(NULL, "\t\n"))) continue; - CurrentMCU = (!strcmp(Token, Options.MCU)) || (!strcmp(Token, "Global")); + CurrentMCU = (!strcmp(Token, cx->dis_opts.MCU)) || (!strcmp(Token, "Global")); } } } @@ -95,7 +95,7 @@ const char *Resolve_IO_Register(int Number) { int Resolved; unsigned int i; - if(!strcmp(Options.MCU, "None")) + if(!strcmp(cx->dis_opts.MCU, "None")) return NULL; Resolved = -1; @@ -117,7 +117,7 @@ const char *Resolve_IO_Register(int Number) { void Emit_Used_IO_Registers() { unsigned int i; - if(Options.Show_PseudoCode) + if(cx->dis_opts.Show_PseudoCode) return; for(i = 0; i < KnownIORegistersCount; i++) { if(KnownIORegisters[i].Used) diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 5ffe3172..80355032 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -29,12 +29,13 @@ #include #include +#include "libavrdude.h" + #include "disasm_globals.h" #include "disasm_mnemonics.h" #include "disasm_tagfile.h" #include "disasm_jumpcall.h" -extern struct Options Options; static int JumpCall_Count; static struct JumpCall *JumpCalls; @@ -49,17 +50,17 @@ void Display_JumpCalls() { } int FixTargetAddress(int Address) { - if(Options.FlashSize) { - Address %= Options.FlashSize; + if(cx->dis_opts.FlashSize) { + Address %= cx->dis_opts.FlashSize; if(Address < 0) { - Address += Options.FlashSize; + Address += cx->dis_opts.FlashSize; } } return Address; } void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { - if((Options.Process_Labels == 1) && (Options.Pass == 1)) { + if((cx->dis_opts.Process_Labels == 1) && (cx->dis_opts.Pass == 1)) { JumpCall_Count++; JumpCalls = realloc(JumpCalls, sizeof(struct JumpCall) * (JumpCall_Count)); JumpCalls[JumpCall_Count - 1].From = From; diff --git a/src/disasm_mnemonics.c b/src/disasm_mnemonics.c index c69bd3e3..c660f7e9 100644 --- a/src/disasm_mnemonics.c +++ b/src/disasm_mnemonics.c @@ -27,6 +27,8 @@ #include +#include "libavrdude.h" + const char *MNemonic[] = { "adc", "add", diff --git a/src/disasm_options.c b/src/disasm_options.c deleted file mode 100644 index a7978190..00000000 --- a/src/disasm_options.c +++ /dev/null @@ -1,188 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include -#include - -#include "disasm_globals.h" -#include "disasm_ioregisters.h" -#include "disasm_tagfile.h" -#include "disasm_options.h" - -#ifndef AVRDISAS_VERSION -#define AVRDISAS_VERSION "dev" -#endif - -void Options_Default(struct Options *Options) { - Options->Show_Addresses = 0; - Options->Show_Opcodes = 0; - Options->Show_Comments = 1; - Options->Show_Cycles = 0; - Options->Show_PseudoCode = 0; - Options->Filename[0] = 0; - Options->MCU[0] = 0; - Options->Tagfile[0] = 0; - Options->CodeStyle = 1; // 0 = AVR Instruction Set, 1 = avr-gcc - Options->Process_Labels = 1; - Options->Pass = 1; - Options->FlashSize = 0; -} - -int StringStart(const char *String1, const char *String2) { - size_t Length1, Length2; - int MinLen; - - Length1 = strlen(String1); - Length2 = strlen(String2); - if(Length1 < Length2) - MinLen = Length1; - else - MinLen = Length2; - - return strncmp(String1, String2, MinLen); -} - -void Show_Help(char *ProgramName) { - fprintf(stderr, "%s [Options] [Filename]\n", ProgramName); - fprintf(stderr, "'n' can either be 0 or 1 and means 'off' or 'on':\n"); - fprintf(stderr, " -an Do or don't show addresses\n"); - fprintf(stderr, " -on Do or don't show opcodes\n"); - fprintf(stderr, " -cn Do or don't show comments\n"); - fprintf(stderr, " -qn Do or don't show call cycles\n"); - fprintf(stderr, " -sn Do or don't use avr-gcc codestyle\n"); - fprintf(stderr, " -pn Do or don't include pseodocode\n"); - fprintf(stderr, " -ln Do or don't do jump/call-preprocessing\n"); - fprintf(stderr, " -mMCU Set the MCU for IO-register resolving\n"); - fprintf(stderr, " -tFile Set the tagfile to be used\n"); - fprintf(stderr, " -fSize Set the size of the flash area\n"); - fprintf(stderr, " --help Show this helppage\n"); - fprintf(stderr, " -h Show this helppage\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Example:\n"); - fprintf(stderr, "%s -a0 -o1 -c0 -m2313 -s1 -l1 -ttags.txt -f8192 Myfile.bin\n", ProgramName); - fprintf(stderr, "\n"); - fprintf(stderr, "Version: " AVRDISAS_VERSION "\n"); -} - -int SetVal(char *Argument, char *Destination, char *Description, char Min, char Max) { - int Value; - - Value = atoi(Argument); - if((Value < Min) || (Value > Max)) { - fprintf(stderr, "Invalid argument for '%s': must be between %d and %d.\n", Description, Min, Max); - return 0; - } - *Destination = Value; - return 1; -} - -int SetValInt(const char *Argument, int *Destination, char *Description, int Min, int Max) { - int Value; - - Value = atoi(Argument); - if((Value < Min) || (Value > Max)) { - fprintf(stderr, "Invalid argument for '%s': must be between %d and %d.\n", Description, Min, Max); - return 0; - } - *Destination = Value; - return 1; -} - -int SetMCU(char *Argument, char *Destination) { - strncpy(Destination, Argument, 7); - if(ReadIORegisterFile() == 0) { - fprintf(stderr, "Invalid argument for MCU! Must be one of the following:\n"); - // List_Supported_MCUs(); - return 0; - } - return 1; -} - -char Options_ParseCmdLine(struct Options *Options, int argc, char **argv) { - int i; - char *Argument; - - for(i = 1; i < argc; i++) { - Argument = argv[i]; - - if(StringStart(Argument, "-a") == 0) { - if(SetVal(Argument + 2, &(Options->Show_Addresses), "show addresses", 0, 1) == 0) - return 0; - } else if(StringStart(Argument, "-o") == 0) { - if(SetVal(Argument + 2, &(Options->Show_Opcodes), "show opcodes", 0, 1) == 0) - return 0; - } else if(StringStart(Argument, "-c") == 0) { - if(SetVal(Argument + 2, &(Options->Show_Comments), "show comments", 0, 1) == 0) - return 0; - } else if(StringStart(Argument, "-q") == 0) { - if(SetVal(Argument + 2, &(Options->Show_Cycles), "show cycles", 0, 1) == 0) - return 0; - } else if(StringStart(Argument, "-p") == 0) { - if(SetVal(Argument + 2, &(Options->Show_PseudoCode), "show pseudocode", 0, 1) == 0) - return 0; - } else if(StringStart(Argument, "-s") == 0) { - if(SetVal(Argument + 2, &(Options->CodeStyle), "codestyle", 0, 2) == 0) - return 0; - } else if(StringStart(Argument, "-l") == 0) { - if(SetVal(Argument + 2, &(Options->Process_Labels), "process labels", 0, 1) == 0) - return 0; - } else if(StringStart(Argument, "-m") == 0) { - if(SetMCU(Argument + 2, Options->MCU) == 0) - return 0; - } else if(StringStart(Argument, "-t") == 0) { - strncpy(Options->Tagfile, Argument + 2, 256); - } else if(StringStart(Argument, "-f") == 0) { - if(SetValInt(Argument + 2, &(Options->FlashSize), "flash size", 32, 1024 * 1024) == 0) - return 0; - } else if(StringStart(Argument, "--help") == 0) { - Show_Help(argv[0]); - return 0; - } else if(StringStart(Argument, "-h") == 0) { - Show_Help(argv[0]); - return 0; - } else { - if(Options->Filename[0] != 0) { - fprintf(stderr, "Filename '%s' was already supplied!\n", Options->Filename); - return 0; - } - strncpy(Options->Filename, Argument, 255); - } - } - - if(Options->Filename[0] == 0) { - fprintf(stderr, "Error: No filename supplied.\n"); - return 0; - } - - if(Options->Tagfile[0] != 0) { - if(!Read_Tagfile(Options->Tagfile)) - return 0; - } - - return 1; -} diff --git a/src/disasm_options.h b/src/disasm_options.h deleted file mode 100644 index d955f869..00000000 --- a/src/disasm_options.h +++ /dev/null @@ -1,29 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -void Options_Default(struct Options *Options); -char Options_ParseCmdLine(struct Options *Options, int argc, char **argv); diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index b05646dd..e2991dc4 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -30,6 +30,8 @@ #include #include +#include "libavrdude.h" + #include "disasm_tagfile.h" struct CodeLabel { diff --git a/src/libavrdude.h b/src/libavrdude.h index e0d2d5c0..624b3d48 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1445,6 +1445,24 @@ typedef struct { #define STR_XINT32 STR_4 #define STR_XINT64 STR_8 +typedef struct { + char Show_Addresses; + char Show_Opcodes; + char Show_Comments; + char Show_Cycles; + char Show_PseudoCode; + char Filename[256]; + char MCU[8]; + const char *Tagfile; + char CodeStyle; + char Process_Labels; + char Pass; + int FlashSize; +} Disasm_options; + +#define CODESTYLE_AVR_INSTRUCTION_SET 0 +#define CODESTYLE_AVRGCC 1 + #ifdef __cplusplus extern "C" { #endif @@ -1545,10 +1563,13 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); +int disasm(char *buf, int len, int addr); + #ifdef __cplusplus } #endif + /* * Context structure * @@ -1635,6 +1656,10 @@ typedef struct { // Static variable from fileio.c int reccount; + // Static variables from disasm*.c + Disasm_options dis_opts; + int dis_initopts; + // Static variables from usb_libusb.c #include "usbdevs.h" char usb_buf[USBDEV_MAX_XFER_3]; From 825c93e64f43477246c2afe5317b69f3f77a28a0 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 14:44:47 +0100 Subject: [PATCH 277/422] Provide disasm terminal command --- src/term.c | 188 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 161 insertions(+), 27 deletions(-) diff --git a/src/term.c b/src/term.c index a25d63b1..8999548b 100644 --- a/src/term.c +++ b/src/term.c @@ -65,6 +65,7 @@ struct command { static int cmd_dump (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); +static int cmd_disasm (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_write (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_save (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); static int cmd_backup (const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]); @@ -98,6 +99,7 @@ static int cmd_quell (const PROGRAMMER *pgm, const AVRPART *p, int argc, const struct command cmd[] = { { "dump", cmd_dump, _fo(read_byte_cached), "display a memory section as hex dump" }, { "read", cmd_dump, _fo(read_byte_cached), "alias for dump" }, + { "disasm", cmd_disasm, _fo(read_byte_cached), "disassemble a memory section" }, { "write", cmd_write, _fo(write_byte_cached), "write data to memory; flash and EEPROM are cached" }, { "save", cmd_save, _fo(write_byte_cached), "save memory segments to file" }, { "backup", cmd_backup, _fo(write_byte_cached), "backup memories to file" }, @@ -211,27 +213,43 @@ static int hexdump_buf(const FILE *f, const AVRMEM *m, int startaddr, const unsi } -static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { - int i = cx->term_mi; - const char *cmd = tolower(**argv) == 'd'? "dump": "read"; +// Just read in memory; used by cmd_dump() and cmd_disasm() +static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[], + const AVRMEM **memp, int *baddr, int *blen) { + int i = cx->term_mi; + const char *cmd = tolower(**argv) == 'r'? "read": str_casestarts(*argv, "di")? "disasm []": "dump"; if ((argc < 2 && cx->term_rmem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { msg_error( - "Syntax: %s # display entire region\n" - " %s # start at \n" - " %s # Continue displaying memory where left off\n" - " %s # Continue displaying most recently shown \n" - "Function: display memory section as hex dump\n" - "\n" + "Syntax: %s # Entire region\n" + " %s # Start at \n" + " %s # Continue with memory where left off\n" + " %s # Continue with most recently shown \n" + "Function: %s\n", + cmd, cmd, cmd, cmd, + cmd[1] == 'i'? "disassemble memory section": "display memory section as hex dump" + ); + if(cmd[1] == 'i') { + msg_error("Options:\n" + " -a show addresses, -A don't show addresses\n" + " -o show opcodes, -O don't show opcodes\n" + " -c show comments, -C don't show comments\n" + " -q show call cycles, -Q don't show call cycles\n" + " -s use avr-gcc code style, -S use AVR instruction set code style\n" + " -p include pseudocode, -P don't include pseudocode\n" + " -l preprocess jump/call, -L don't preprocess jump/call\n" + " -t= set the tagfile to be used\n" + ); + } + msg_error("\n" "Both the and can be negative numbers; a negative starts\n" "an interval from that many bytes below the memory size; a negative ends\n" "the interval at that many bytes below the memory size.\n" "\n" "The latter two versions of the command page through the memory with a page\n" - "size of the last used effective length (256 bytes default)\n", - cmd, cmd, cmd, cmd + "size of the last used effective length (256 bytes default)\n" ); - return -1; + return NULL; } enum { read_size = 256 }; @@ -243,13 +261,13 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha const AVRMEM *mem = avr_locate_mem(p, memstr); if (mem == NULL) { pmsg_error("(%s) memory %s not defined for part %s\n", cmd, memstr, p->desc); - return -1; + return NULL; } int maxsize = mem->size; if(maxsize <= 0) { // Sanity check pmsg_error("(%s) cannot read memory %s of size %d\n", cmd, mem->desc, maxsize); - return -1; + return NULL; } // Iterate through the cx->term_rmem structs to find relevant address and length info @@ -265,7 +283,7 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha if(i >= 32) { // Catch highly unlikely case pmsg_error("(%s) cx->term_rmem[] under-dimensioned; increase and recompile\n", cmd); - return -1; + return NULL;; } cx->term_mi = i; @@ -275,7 +293,7 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha int addr = str_int(argv[2], STR_INT32, &errptr); if(errptr) { pmsg_error("(%s) address %s: %s\n", cmd, argv[2], errptr); - return -1; + return NULL; } // Turn negative addr value (counting from top and down) into an actual memory address @@ -286,7 +304,7 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha int digits = mem->size > 0x10000? 5: 4; pmsg_error("(%s) %s address %s is out of range [-0x%0*x, 0x%0*x]\n", cmd, mem->desc, argv[2], digits, maxsize, digits, maxsize-1); - return -1; + return NULL; } cx->term_rmem[i].addr = addr; } @@ -301,18 +319,25 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha int len = str_int(argv[3], STR_INT32, &errptr); if(errptr) { pmsg_error("(%s) length %s: %s\n", cmd, argv[3], errptr); - return -1; + return NULL; } // Turn negative len value (number of bytes from top of memory) into an actual length if (len < 0) len = maxsize + len + 1 - cx->term_rmem[i].addr; - if (len == 0) - return 0; + if (len == 0) { + if(memp) + *memp = mem; + if(baddr) + *baddr = 0; + if(blen) + *blen = 0; + return mmt_malloc(1); + } if (len < 0) { pmsg_error("(%s) invalid effective length %d\n", cmd, len); - return -1; + return NULL; } cx->term_rmem[i].len = len; } @@ -341,19 +366,128 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha if (rc == -1) imsg_error("%*sread operation not supported on memory %s\n", 7, "", mem->desc); mmt_free(buf); - return -1; + return NULL; } report_progress(j, cx->term_rmem[i].len, NULL); } report_progress(1, 1, NULL); - hexdump_buf(stdout, mem, cx->term_rmem[i].addr, buf, cx->term_rmem[i].len); - lterm_out(""); - - mmt_free(buf); + if(memp) + *memp = mem; + if(baddr) + *baddr = cx->term_rmem[i].addr; + if(blen) + *blen = cx->term_rmem[i].len; cx->term_rmem[i].addr = (cx->term_rmem[i].addr + cx->term_rmem[i].len) % maxsize; + return buf; +} + +static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { + int addr, len; + const AVRMEM *mem = NULL; + uint8_t *buf = readbuf(pgm, p, argc, argv, &mem, &addr, &len); + + if(!buf) + return -1; + + hexdump_buf(stdout, mem, addr, buf, len); + lterm_out(""); + mmt_free(buf); + + return 0; +} + + +static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { + int addr, len; + const AVRMEM *mem = NULL; + uint8_t *buf; + + int help = 0, invalid = 0, itemac = 1, chr; + + if(!cx->dis_initopts) { + cx->dis_opts.Show_Addresses = 0; + cx->dis_opts.Show_Opcodes = 0; + cx->dis_opts.Show_Comments = 1; + cx->dis_opts.Show_Cycles = 0; + cx->dis_opts.Show_PseudoCode = 0; + cx->dis_opts.Filename[0] = 0; + cx->dis_opts.MCU[0] = 0; + cx->dis_opts.Tagfile = NULL; + cx->dis_opts.CodeStyle = CODESTYLE_AVRGCC; // CODESTYLE_AVR_INSTRUCTION_SET + cx->dis_opts.Process_Labels = 1; + cx->dis_opts.FlashSize = 0; + cx->dis_initopts++; + } + cx->dis_opts.Pass = 1; + + for(int ai = 0; --argc > 0; ) { // Simple option parsing + const char *q; + if(*(q = argv[++ai]) != '-' || !q[1]) + argv[itemac++] = argv[ai]; + else { + while(*++q) { + switch((chr = *q & 0xff)) { + case '?': + case 'h': + help++; + break; + case 'a': case 'A': + cx->dis_opts.Show_Addresses = tolower(chr); + break; + case 'o': case 'O': + cx->dis_opts.Show_Opcodes = tolower(chr); + break; + case 'c': case 'C': + cx->dis_opts.Show_Comments = tolower(chr); + break; + case 'q': case 'Q': + cx->dis_opts.Show_Cycles = tolower(chr); + break; + case 'p': case 'P': + cx->dis_opts.Show_PseudoCode = tolower(chr); + break; + case 's': case 'S': + cx->dis_opts.CodeStyle = tolower(chr)? CODESTYLE_AVRGCC: CODESTYLE_AVR_INSTRUCTION_SET; + break; + case 'l': case 'L': + cx->dis_opts.Process_Labels = tolower(chr); + break; + case 't': + if(*++q == '=') + q++; + cx->dis_opts.Tagfile = q; + q = "x"; + break; + default: + if(!invalid++) + pmsg_error("(disasm) invalid option %c, see usage:\n", chr); + q = "x"; + } + } + } + } + argc = itemac; // (arg,c argv) still valid but options have been removed + + if(help || invalid) { + const char *help[] = { "disasm", "-?", NULL, }; + readbuf(pgm, p, 2, help, NULL, NULL, NULL); + return -1; + } + + + buf = readbuf(pgm, p, argc, argv, &mem, &addr, &len); + + if(!buf) + return -1; + + if(len > 0) + disasm((char *) buf, len, addr); + lterm_out(""); + mmt_free(buf); + return 0; } @@ -1364,7 +1498,7 @@ static void printfuse(Cnfg *cc, int ii, FL_item *fc, int nf, int printed, Cfg_op // Show or change configuration properties of the part static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { Cfg_opts o = { 0 }; - int help = 0, invalid = 0, itemac=1; + int help = 0, invalid = 0, itemac = 1; for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; From a7cf1439348c81fa90bace38004d890429767f4d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 15:10:03 +0100 Subject: [PATCH 278/422] Assert const-ness of pointer arguments --- src/disasm.c | 24 +-- src/disasm_callbacks_assembly.c | 2 +- src/disasm_callbacks_assembly.h | 264 +++++++++++++++--------------- src/disasm_callbacks_pseudocode.h | 128 +++++++-------- src/disasm_globals.h | 4 +- src/disasm_tagfile.c | 16 +- src/disasm_tagfile.h | 2 +- src/libavrdude.h | 2 +- 8 files changed, 221 insertions(+), 221 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index a7f9c86b..259dc365 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -63,7 +63,7 @@ void Display_Registers() { printf("End of register dump.\n"); } -int Compare_Opcode(char *Bitstream, char *Bitmask) { +int Compare_Opcode(const char *Bitstream, const char *Bitmask) { size_t i; char Bit; @@ -78,7 +78,7 @@ int Compare_Opcode(char *Bitstream, char *Bitmask) { // Retrieve the i-th Bit of Bitstream Bit = (Bitstream[i / 8] >> (7 - (i % 8))) & 1; - // printf("Bit %d is %d [should be %c]\n",i,Bit,Bitmask[i]); + // printf("Bit %d is %d [should be %c]\n", i, Bit, Bitmask[i]); if((Bitmask[i] == '1') && (Bit == 1)) continue; if((Bitmask[i] == '0') && (Bit == 0)) @@ -88,7 +88,7 @@ int Compare_Opcode(char *Bitstream, char *Bitmask) { return 1; // Match } -void Register_Opcode(void (*Callback)(char *, int, int), const char *New_Opcode_String, int New_MNemonic) { +void Register_Opcode(void (*Callback)(const char *, int, int), const char *New_Opcode_String, int New_MNemonic) { Number_Opcodes++; Opcodes[Number_Opcodes - 1].Opcode_String = malloc(strlen(New_Opcode_String) + 1); strcpy(Opcodes[Number_Opcodes - 1].Opcode_String, New_Opcode_String); @@ -96,7 +96,7 @@ void Register_Opcode(void (*Callback)(char *, int, int), const char *New_Opcode_ Opcodes[Number_Opcodes - 1].Callback = Callback; } -void Supersede_Opcode(void (*Callback)(char *, int, int), int New_MNemonic) { +void Supersede_Opcode(void (*Callback)(const char *, int, int), int New_MNemonic) { int i; for(i = 0; i < Number_Opcodes; i++) { @@ -109,7 +109,7 @@ void Supersede_Opcode(void (*Callback)(char *, int, int), int New_MNemonic) { fprintf(stderr, "Error: No callback to supersede opcode %d found (%s).\n", New_MNemonic, MNemonic[New_MNemonic]); } -int Get_Bitmask_Length(char *Bitmask) { +int Get_Bitmask_Length(const char *Bitmask) { int Length = 0; size_t i; @@ -127,7 +127,7 @@ void Clear_Registers() { Registers[i] = 0; } -char Get_From_Bitmask(char *Bitmask, int Byte, int Bit) { +char Get_From_Bitmask(const char *Bitmask, int Byte, int Bit) { size_t i; int Cnt = 0; int GetBit; @@ -143,7 +143,7 @@ char Get_From_Bitmask(char *Bitmask, int Byte, int Bit) { return '?'; } -void Display_Binary(char *Bitstream, int Count) { +void Display_Binary(const char *Bitstream, int Count) { int i, j; for(i = 0; i < Count; i++) { @@ -162,7 +162,7 @@ void Display_Binary(char *Bitstream, int Count) { printf("\n"); } -int Match_Opcode(char *Bitmask, char *Bitstream) { +int Match_Opcode(const char *Bitmask, const char *Bitstream) { int i; int Length; int Byte_Mask, Bit_Mask; @@ -212,7 +212,7 @@ int Match_Opcode(char *Bitmask, char *Bitstream) { return 1; } -int Get_Next_Opcode(char *Bitstream) { +int Get_Next_Opcode(const char *Bitstream) { int i; for(i = 0; i < Number_Opcodes; i++) { @@ -223,7 +223,7 @@ int Get_Next_Opcode(char *Bitstream) { return -1; } -void Disassemble(char *Bitstream, int Read) { +void Disassemble(const char *Bitstream, int Read) { int Pos; int Opcode; int i; @@ -337,7 +337,7 @@ void Display_Opcodes() { } } -int Get_Specifity(char *Opcode) { +int Get_Specifity(const char *Opcode) { size_t i; int Specifity = 0; @@ -363,7 +363,7 @@ int Comparison(const void *Element1, const void *Element2) { return -1; } -int disasm(char *Bitstream, int Read, int addr) { +int disasm(const char *Bitstream, int Read, int addr) { if(cx->dis_opts.Tagfile) if(!Read_Tagfile(cx->dis_opts.Tagfile)) return 0; diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index ca980c95..0b171e6f 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -174,7 +174,7 @@ void Operation_s(int MNemonic_Int) { snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { +void Operation_k(int MNemonic_Int, int Position, const char *Pseudocode) { int Offset; int Target; diff --git a/src/disasm_callbacks_assembly.h b/src/disasm_callbacks_assembly.h index 33971f80..f58116aa 100644 --- a/src/disasm_callbacks_assembly.h +++ b/src/disasm_callbacks_assembly.h @@ -41,135 +41,135 @@ void Operation_r_b(int MNemonic_Int); void Operation_Rd_b(int MNemonic_Int); void Operation_A_b(int MNemonic_Int); void Operation_s(int MNemonic_Int); -void Operation_k(int MNemonic_Int, int Position, char *Pseudocode); -void adc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void add_Callback(char *Bitstream, int Position, int MNemonic_Int); -void adiw_Callback(char *Bitstream, int Position, int MNemonic_Int); -void and_Callback(char *Bitstream, int Position, int MNemonic_Int); -void andi_Callback(char *Bitstream, int Position, int MNemonic_Int); -void asr_Callback(char *Bitstream, int Position, int MNemonic_Int); -void bclr_Callback(char *Bitstream, int Position, int MNemonic_Int); -void bld_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brbc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brbs_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brcc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brcs_Callback(char *Bitstream, int Position, int MNemonic_Int); -void break_Callback(char *Bitstream, int Position, int MNemonic_Int); -void breq_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brge_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brhc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brhs_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brid_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brie_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brlo_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brlt_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brmi_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brne_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brpl_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brsh_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brtc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brts_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brvc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void brvs_Callback(char *Bitstream, int Position, int MNemonic_Int); -void bset_Callback(char *Bitstream, int Position, int MNemonic_Int); -void bst_Callback(char *Bitstream, int Position, int MNemonic_Int); -void call_Callback(char *Bitstream, int Position, int MNemonic_Int); -void cbi_Callback(char *Bitstream, int Position, int MNemonic_Int); -void clc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void clh_Callback(char *Bitstream, int Position, int MNemonic_Int); -void cli_Callback(char *Bitstream, int Position, int MNemonic_Int); -void cln_Callback(char *Bitstream, int Position, int MNemonic_Int); -void cls_Callback(char *Bitstream, int Position, int MNemonic_Int); -void clt_Callback(char *Bitstream, int Position, int MNemonic_Int); -void clv_Callback(char *Bitstream, int Position, int MNemonic_Int); -void clz_Callback(char *Bitstream, int Position, int MNemonic_Int); -void com_Callback(char *Bitstream, int Position, int MNemonic_Int); -void cp_Callback(char *Bitstream, int Position, int MNemonic_Int); -void cpc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void cpi_Callback(char *Bitstream, int Position, int MNemonic_Int); -void cpse_Callback(char *Bitstream, int Position, int MNemonic_Int); -void dec_Callback(char *Bitstream, int Position, int MNemonic_Int); -void eicall_Callback(char *Bitstream, int Position, int MNemonic_Int); -void eijmp_Callback(char *Bitstream, int Position, int MNemonic_Int); -void elpm1_Callback(char *Bitstream, int Position, int MNemonic_Int); -void elpm2_Callback(char *Bitstream, int Position, int MNemonic_Int); -void elpm3_Callback(char *Bitstream, int Position, int MNemonic_Int); -void eor_Callback(char *Bitstream, int Position, int MNemonic_Int); -void fmul_Callback(char *Bitstream, int Position, int MNemonic_Int); -void fmuls_Callback(char *Bitstream, int Position, int MNemonic_Int); -void fmulsu_Callback(char *Bitstream, int Position, int MNemonic_Int); -void icall_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ijmp_Callback(char *Bitstream, int Position, int MNemonic_Int); -void in_Callback(char *Bitstream, int Position, int MNemonic_Int); -void inc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void jmp_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ld1_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ld2_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ld3_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldy1_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldy2_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldy3_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldy4_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldz1_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldz2_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldz3_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldz4_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ldi_Callback(char *Bitstream, int Position, int MNemonic_Int); -void lds_Callback(char *Bitstream, int Position, int MNemonic_Int); -void lpm1_Callback(char *Bitstream, int Position, int MNemonic_Int); -void lpm2_Callback(char *Bitstream, int Position, int MNemonic_Int); -void lpm3_Callback(char *Bitstream, int Position, int MNemonic_Int); -void lsr_Callback(char *Bitstream, int Position, int MNemonic_Int); -void mov_Callback(char *Bitstream, int Position, int MNemonic_Int); -void movw_Callback(char *Bitstream, int Position, int MNemonic_Int); -void mul_Callback(char *Bitstream, int Position, int MNemonic_Int); -void muls_Callback(char *Bitstream, int Position, int MNemonic_Int); -void mulsu_Callback(char *Bitstream, int Position, int MNemonic_Int); -void neg_Callback(char *Bitstream, int Position, int MNemonic_Int); -void nop_Callback(char *Bitstream, int Position, int MNemonic_Int); -void or_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ori_Callback(char *Bitstream, int Position, int MNemonic_Int); -void out_Callback(char *Bitstream, int Position, int MNemonic_Int); -void pop_Callback(char *Bitstream, int Position, int MNemonic_Int); -void push_Callback(char *Bitstream, int Position, int MNemonic_Int); -void rcall_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ret_Callback(char *Bitstream, int Position, int MNemonic_Int); -void reti_Callback(char *Bitstream, int Position, int MNemonic_Int); -void rjmp_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ror_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbci_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbi_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbic_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbis_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbiw_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbr_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbrc_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sbrs_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sec_Callback(char *Bitstream, int Position, int MNemonic_Int); -void seh_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sei_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sen_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ser_Callback(char *Bitstream, int Position, int MNemonic_Int); -void ses_Callback(char *Bitstream, int Position, int MNemonic_Int); -void set_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sev_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sez_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sleep_Callback(char *Bitstream, int Position, int MNemonic_Int); -void spm_Callback(char *Bitstream, int Position, int MNemonic_Int); -void st1_Callback(char *Bitstream, int Position, int MNemonic_Int); -void st2_Callback(char *Bitstream, int Position, int MNemonic_Int); -void st3_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sty1_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sty2_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sty3_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sty4_Callback(char *Bitstream, int Position, int MNemonic_Int); -void stz1_Callback(char *Bitstream, int Position, int MNemonic_Int); -void stz2_Callback(char *Bitstream, int Position, int MNemonic_Int); -void stz3_Callback(char *Bitstream, int Position, int MNemonic_Int); -void stz4_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sts_Callback(char *Bitstream, int Position, int MNemonic_Int); -void sub_Callback(char *Bitstream, int Position, int MNemonic_Int); -void subi_Callback(char *Bitstream, int Position, int MNemonic_Int); -void swap_Callback(char *Bitstream, int Position, int MNemonic_Int); -void wdr_Callback(char *Bitstream, int Position, int MNemonic_Int); +void Operation_k(int MNemonic_Int, int Position, const char *Pseudocode); +void adc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void add_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void adiw_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void and_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void andi_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void asr_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void bclr_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void bld_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brbc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brbs_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brcc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brcs_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void break_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void breq_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brge_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brhc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brhs_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brid_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brie_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brlo_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brlt_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brmi_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brne_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brpl_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brsh_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brtc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brts_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brvc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void brvs_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void bset_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void bst_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void call_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void cbi_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void clc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void clh_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void cli_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void cln_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void cls_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void clt_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void clv_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void clz_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void com_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void cp_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void cpc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void cpi_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void cpse_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void dec_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void eicall_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void eijmp_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void elpm1_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void elpm2_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void elpm3_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void eor_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void fmul_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void fmuls_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void fmulsu_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void icall_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ijmp_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void in_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void inc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void jmp_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ld1_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ld2_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ld3_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldy1_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldy2_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldy3_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldy4_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldz1_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldz2_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldz3_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldz4_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ldi_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void lds_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void lpm1_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void lpm2_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void lpm3_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void lsr_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void mov_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void movw_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void mul_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void muls_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void mulsu_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void neg_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void nop_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void or_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ori_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void out_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void pop_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void push_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void rcall_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ret_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void reti_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void rjmp_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ror_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbci_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbi_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbic_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbis_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbiw_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbr_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbrc_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sbrs_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sec_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void seh_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sei_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sen_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ser_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void ses_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void set_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sev_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sez_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sleep_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void spm_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void st1_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void st2_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void st3_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sty1_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sty2_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sty3_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sty4_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void stz1_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void stz2_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void stz3_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void stz4_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sts_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void sub_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void subi_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void swap_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void wdr_Callback(const char *Bitstream, int Position, int MNemonic_Int); diff --git a/src/disasm_callbacks_pseudocode.h b/src/disasm_callbacks_pseudocode.h index b89fcaf3..c98978f9 100644 --- a/src/disasm_callbacks_pseudocode.h +++ b/src/disasm_callbacks_pseudocode.h @@ -42,67 +42,67 @@ void PC_Operation_Rd_b(int MNemonic_Int); void PC_Operation_A_b(int MNemonic_Int); void PC_Operation_s(int MNemonic_Int); void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode); -void adc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void add_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sub_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sbc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void mov_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brcc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brcs_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void breq_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brge_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brhc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brhs_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brid_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brie_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brlo_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brlt_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brmi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brne_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brpl_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brsh_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brtc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brts_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brvc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void brvs_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void out_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void in_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void cli_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sei_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void ret_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void reti_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void andi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void subi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sbci_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sbr_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void ori_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void ldi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void lds_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sts_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void call_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void rcall_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void ror_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void lsr_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void swap_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void eor_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void jmp_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void rjmp_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void cpi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void asr_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void dec_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void inc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void cp_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void cpc_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void cpse_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void and_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void or_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void mul_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sbi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sbic_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void sbis_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void cbi_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void ser_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void adiw_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void movw_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void lpm1_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); -void st2_Callback_PC(char *Bitstream, int Position, int MNemonic_Int); +void adc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void add_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sub_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sbc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void mov_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brcc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brcs_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void breq_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brge_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brhc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brhs_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brid_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brie_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brlo_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brlt_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brmi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brne_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brpl_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brsh_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brtc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brts_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brvc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void brvs_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void out_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void in_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void cli_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sei_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void ret_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void reti_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void andi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void subi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sbci_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sbr_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void ori_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void ldi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void lds_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sts_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void call_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void rcall_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void ror_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void lsr_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void swap_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void eor_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void jmp_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void rjmp_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void cpi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void asr_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void dec_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void inc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void cp_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void cpc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void cpse_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void and_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void or_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void mul_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sbi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sbic_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void sbis_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void cbi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void ser_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void adiw_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void movw_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void lpm1_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void st2_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); diff --git a/src/disasm_globals.h b/src/disasm_globals.h index 024292a1..143f235b 100644 --- a/src/disasm_globals.h +++ b/src/disasm_globals.h @@ -34,11 +34,11 @@ #define Rb (Registers[(int)'b']) #define Rq (Registers[(int)'q']) -#define CALLBACK(name) void name(char *Bitstream, int Position, int MNemonic_Int) +#define CALLBACK(name) void name(const char *Bitstream, int Position, int MNemonic_Int) struct Opcode { char *Opcode_String; - void (*Callback)(char *, int, int); + void (*Callback)(const char *, int, int); int MNemonic; }; diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index e2991dc4..31d91d51 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -392,24 +392,24 @@ const char *Tagfile_Resolve_Mem_Address(int Address) { return NULL; } -static int Tagfile_Process_Byte(char *Bitstream, int Position, int ArgumentNo, const char *Label) { - printf(".byte 0x%02x\n", ((unsigned char *) Bitstream)[Position]); +static int Tagfile_Process_Byte(const char *Bitstream, int Position, int ArgumentNo, const char *Label) { + printf(".byte 0x%02x\n", Bitstream[Position] & 0xff); return 1; } -static int Tagfile_Process_Word(char *Bitstream, int Position, int ArgumentNo, const char *Label) { - printf(".word 0x%02x%02x\n", ((unsigned char *) Bitstream)[Position + 1], ((unsigned char *) Bitstream)[Position]); +static int Tagfile_Process_Word(const char *Bitstream, int Position, int ArgumentNo, const char *Label) { + printf(".word 0x%02x%02x\n", Bitstream[Position + 1] & 0xff, Bitstream[Position] & 0xff); return 2; } -static int Tagfile_Process_String(char *Bitstream, int Position, int ArgumentNo, const char *Label) { +static int Tagfile_Process_String(const char *Bitstream, int Position, int ArgumentNo, const char *Label) { int i; unsigned char c; unsigned int InString = 0; printf("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); i = 0; - while((c = ((unsigned char *) Bitstream)[Position + i])) { + while((c = Bitstream[Position + i])) { if((c >= 32) && (c <= 127)) { if(!InString) printf(".ascii \""); @@ -444,11 +444,11 @@ static void Sanitize_String(char *String) { } } -int Tagfile_Process_Data(char *Bitstream, int Position) { +int Tagfile_Process_Data(const char *Bitstream, int Position) { int i; int BytesAdvanced; int Index; - int (*ProcessingFunction)(char *, int, int, const char *) = NULL; + int (*ProcessingFunction)(const char *, int, int, const char *) = NULL; char Buffer[32]; Index = Tagfile_FindPGMAddress(Position); diff --git a/src/disasm_tagfile.h b/src/disasm_tagfile.h index 703be183..1247491e 100644 --- a/src/disasm_tagfile.h +++ b/src/disasm_tagfile.h @@ -36,4 +36,4 @@ char *Tagfile_GetLabel(int TagIndex); char *Tagfile_GetLabelComment(int TagIndex); int Tagfile_FindPGMAddress(int Address); const char *Tagfile_Resolve_Mem_Address(int Address); -int Tagfile_Process_Data(char *Bitstream, int Position); +int Tagfile_Process_Data(const char *Bitstream, int Position); diff --git a/src/libavrdude.h b/src/libavrdude.h index 624b3d48..4d4e4c29 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1563,7 +1563,7 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); -int disasm(char *buf, int len, int addr); +int disasm(const char *buf, int len, int addr); #ifdef __cplusplus } From ae414be93d6a770008e61769bf1a0af7bb3cfc19 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 19:49:57 +0100 Subject: [PATCH 279/422] Move global disasm variables into context structure --- src/disasm.c | 100 +++++------ src/disasm_callbacks_assembly.c | 197 +++++++++++----------- src/disasm_callbacks_assembly.h | 2 - src/disasm_callbacks_pseudocode.c | 265 ++++++++++++++---------------- src/disasm_callbacks_pseudocode.h | 2 - src/disasm_globals.h | 22 +-- src/libavrdude.h | 12 +- 7 files changed, 282 insertions(+), 318 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 259dc365..885c3b94 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -43,21 +43,13 @@ #include "disasm_mnemonics.h" #include "disasm_tagfile.h" -static int Number_Opcodes = 0; -static struct Opcode Opcodes[256]; -static int Registers[256]; - -static char Code_Line[256]; -static char Comment_Line[256]; -static char After_Code_Line[256]; - void Display_Registers() { int i; printf("Register dump:\n"); for(i = 0; i < 256; i++) { - if(Registers[i] != 0) { - printf("Registers[%3d] '%c': %d = 0x%x\n", i, i, Registers[i], Registers[i]); + if(cx->dis_regs[i] != 0) { + printf("Registers[%3d] '%c': %d = 0x%x\n", i, i, cx->dis_regs[i], cx->dis_regs[i]); } } printf("End of register dump.\n"); @@ -89,20 +81,20 @@ int Compare_Opcode(const char *Bitstream, const char *Bitmask) { } void Register_Opcode(void (*Callback)(const char *, int, int), const char *New_Opcode_String, int New_MNemonic) { - Number_Opcodes++; - Opcodes[Number_Opcodes - 1].Opcode_String = malloc(strlen(New_Opcode_String) + 1); - strcpy(Opcodes[Number_Opcodes - 1].Opcode_String, New_Opcode_String); - Opcodes[Number_Opcodes - 1].MNemonic = New_MNemonic; - Opcodes[Number_Opcodes - 1].Callback = Callback; + cx->dis_n_ops++; + cx->dis_op[cx->dis_n_ops - 1].Opcode_String = malloc(strlen(New_Opcode_String) + 1); + strcpy(cx->dis_op[cx->dis_n_ops - 1].Opcode_String, New_Opcode_String); + cx->dis_op[cx->dis_n_ops - 1].MNemonic = New_MNemonic; + cx->dis_op[cx->dis_n_ops - 1].Callback = Callback; } void Supersede_Opcode(void (*Callback)(const char *, int, int), int New_MNemonic) { int i; - for(i = 0; i < Number_Opcodes; i++) { - if(Opcodes[i].MNemonic == New_MNemonic) { + for(i = 0; i < cx->dis_n_ops; i++) { + if(cx->dis_op[i].MNemonic == New_MNemonic) { // Supersede callback - Opcodes[i].Callback = Callback; + cx->dis_op[i].Callback = Callback; return; } } @@ -124,7 +116,7 @@ void Clear_Registers() { int i; for(i = 0; i < 256; i++) - Registers[i] = 0; + cx->dis_regs[i] = 0; } char Get_From_Bitmask(const char *Bitmask, int Byte, int Bit) { @@ -201,10 +193,10 @@ int Match_Opcode(const char *Bitmask, const char *Bitstream) { } } else { // This Bit is a register Bit, set in appropriate place - Registers[(int) Mask_Val] <<= 1; - Registers[(int) Mask_Val] |= Stream_Val; + cx->dis_regs[(int) Mask_Val] <<= 1; + cx->dis_regs[(int) Mask_Val] |= Stream_Val; - // printf("-> %d Stored [%x]",Stream_Val,Registers[(int)Mask_Val]); + // printf("-> %d Stored [%x]", Stream_Val, cx->dis_regs[(int) Mask_Val]); } // printf("\n"); @@ -215,15 +207,15 @@ int Match_Opcode(const char *Bitmask, const char *Bitstream) { int Get_Next_Opcode(const char *Bitstream) { int i; - for(i = 0; i < Number_Opcodes; i++) { - if(Match_Opcode(Opcodes[i].Opcode_String, Bitstream) == 1) { + for(i = 0; i < cx->dis_n_ops; i++) { + if(Match_Opcode(cx->dis_op[i].Opcode_String, Bitstream) == 1) { return i; } } return -1; } -void Disassemble(const char *Bitstream, int Read) { +void Disassemble(const char *Bitstream, int Read, int addr) { int Pos; int Opcode; int i; @@ -231,15 +223,15 @@ void Disassemble(const char *Bitstream, int Read) { cx->dis_opts.Pass = 1; Pos = 0; - if((cx->dis_opts.Process_Labels == 1) || ((!cx->dis_opts.Show_PseudoCode) && (cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC))) { + if(cx->dis_opts.Process_Labels || (!cx->dis_opts.Show_PseudoCode && cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC)) { // Preprocess to gather jump labels or to gain knowledge about registers which are being used while(Pos < Read) { Opcode = Get_Next_Opcode(Bitstream + Pos); if(Opcode == -1) { Pos += 2; } else { - Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); - Pos += Get_Bitmask_Length(Opcodes[Opcode].Opcode_String) / 8; + cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].MNemonic); + Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; } } Enumerate_Labels(); @@ -263,10 +255,10 @@ void Disassemble(const char *Bitstream, int Read) { Opcode = Get_Next_Opcode(Bitstream + Pos); if(Opcode != -1) { - Code_Line[0] = 0; - Comment_Line[0] = 0; - After_Code_Line[0] = 0; - Opcodes[Opcode].Callback(Bitstream + Pos, Pos, Opcodes[Opcode].MNemonic); + cx->dis_code[0] = 0; + cx->dis_comment[0] = 0; + cx->dis_after_code[0] = 0; + cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].MNemonic); if(cx->dis_opts.Process_Labels) { Print_JumpCalls(Pos); @@ -275,7 +267,7 @@ void Disassemble(const char *Bitstream, int Read) { if(cx->dis_opts.Show_Addresses) printf("%4x: ", Pos); if(cx->dis_opts.Show_Cycles) { - const char *Cycle = Cycles[Opcodes[Opcode].MNemonic]; + const char *Cycle = Cycles[cx->dis_op[Opcode].MNemonic]; if(!Cycle) printf(" "); @@ -285,35 +277,35 @@ void Disassemble(const char *Bitstream, int Read) { if(cx->dis_opts.Show_Opcodes) { // Now display the Opcode - for(i = 0; i < (Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8; i++) { + for(i = 0; i < (Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8; i++) { printf("%02x ", (unsigned char) (Bitstream[Pos + i])); } printf(" "); // Missing spaces - for(i = 0; i < 5 - ((Get_Bitmask_Length(Opcodes[Opcode].Opcode_String)) / 8); i++) { + for(i = 0; i < 5 - ((Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8); i++) { printf(" "); } } - if(Code_Line[0] == 0) { + if(cx->dis_code[0] == 0) { // No code was generated? - printf("; - Not implemented opcode: %d -\n", Opcodes[Opcode].MNemonic); + printf("; - Not implemented opcode: %d -\n", cx->dis_op[Opcode].MNemonic); } else { - if((Comment_Line[0] == 0) || (!cx->dis_opts.Show_Comments)) { + if((cx->dis_comment[0] == 0) || (!cx->dis_opts.Show_Comments)) { // No comment - printf("%s\n", Code_Line); + printf("%s\n", cx->dis_code); } else { // Comment available if(!cx->dis_opts.Show_PseudoCode) { - printf("%-23s ; %s\n", Code_Line, Comment_Line); + printf("%-23s ; %s\n", cx->dis_code, cx->dis_comment); } else { - printf("%-35s ; %s\n", Code_Line, Comment_Line); + printf("%-35s ; %s\n", cx->dis_code, cx->dis_comment); } } } - printf("%s", After_Code_Line); + printf("%s", cx->dis_after_code); - Pos += Get_Bitmask_Length(Opcodes[Opcode].Opcode_String) / 8; + Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; } else { printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x (%d). Disassembler skipped two bytes.\n", ((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], Pos, Pos); @@ -330,10 +322,10 @@ void Disassemble(const char *Bitstream, int Read) { void Display_Opcodes() { unsigned int i; - printf("%d opcodes registered:\n", Number_Opcodes); - for(i = 0; i < Number_Opcodes; i++) { - // This invokes UB as a function pointer is converted to void* - beware - printf("%3d: '%-80s' -> %p\n", i, Opcodes[i].Opcode_String, (void *) Opcodes[i].Callback); + printf("%d opcodes registered:\n", cx->dis_n_ops); + for(i = 0; i < cx->dis_n_ops; i++) { + // This invokes UB as a function pointer is converted to void * - beware + printf("%3d: '%-80s' -> %p\n", i, cx->dis_op[i].Opcode_String, (void *) cx->dis_op[i].Callback); } } @@ -349,11 +341,11 @@ int Get_Specifity(const char *Opcode) { } int Comparison(const void *Element1, const void *Element2) { - struct Opcode *OC1, *OC2; + Disasm_opcode *OC1, *OC2; int SP1, SP2; - OC1 = (struct Opcode *) Element1; - OC2 = (struct Opcode *) Element2; + OC1 = (Disasm_opcode *) Element1; + OC2 = (Disasm_opcode *) Element2; SP1 = Get_Specifity(OC1->Opcode_String); SP2 = Get_Specifity(OC2->Opcode_String); if(SP1 < SP2) @@ -368,10 +360,8 @@ int disasm(const char *Bitstream, int Read, int addr) { if(!Read_Tagfile(cx->dis_opts.Tagfile)) return 0; - Number_Opcodes = 0; + cx->dis_n_ops = 0; - Activate_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &cx->dis_opts); - Activate_PC_Callbacks(Code_Line, Comment_Line, After_Code_Line, Registers, &cx->dis_opts); Register_Opcode(adc_Callback, "0001 11rd dddd rrrr", OPCODE_adc); Register_Opcode(add_Callback, "0000 11rd dddd rrrr", OPCODE_add); Register_Opcode(adiw_Callback, "1001 0110 KKdd KKKK", OPCODE_adiw); @@ -579,8 +569,8 @@ int disasm(const char *Bitstream, int Read, int addr) { Supersede_Opcode(st2_Callback_PC, OPCODE_st_2); } - qsort(Opcodes, Number_Opcodes, sizeof(struct Opcode), Comparison); + qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); - Disassemble(Bitstream, Read); + Disassemble(Bitstream, Read, addr); return 0; } diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 0b171e6f..c190c4dd 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -37,19 +37,6 @@ #include "disasm_ioregisters.h" #include "disasm_tagfile.h" -static char *Code_Line; -static char *Comment_Line; -static char *After_Code_Line; -static int *Registers; - -void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, - Disasm_options *New_Options) { - Code_Line = New_Code_Line; - Comment_Line = New_Comment_Line; - After_Code_Line = New_After_Code_Line; - Registers = New_Registers; -} - // Return the number of bits set in Number static unsigned BitCount(unsigned n) { unsigned ret; @@ -62,49 +49,49 @@ static unsigned BitCount(unsigned n) { } void Operation_Simple(int MNemonic_Int) { - snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); + snprintf(cx->dis_code, 255, "%s", MNemonic[MNemonic_Int]); } void Operation_Rd(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); } void Operation_Rd16(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); + snprintf(cx->dis_code, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); } void Operation_Rd_Rr(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); } void Operation_Rd16_Rr16(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); } void Operation_Rd16_K(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); + snprintf(cx->dis_comment, 255, "%d", RK); } void Operation_Rd_K(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(cx->dis_comment, 255, "%d", RK); } void Operation_RdW_K(int MNemonic_Int) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); } - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_comment, 255, "%d", RK); } void Operation_RdW_RrW(int MNemonic_Int) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); } else { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); } } @@ -121,14 +108,14 @@ void Operation_s_k(int MNemonic_Int, int Position) { Register_JumpCall(Position, Target, MNemonic_Int, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); + snprintf(cx->dis_code, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); } else { - snprintf(Code_Line, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); + snprintf(cx->dis_code, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); } - snprintf(Comment_Line, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); + snprintf(cx->dis_comment, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); } else { - snprintf(Code_Line, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); + snprintf(cx->dis_code, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); } } @@ -137,8 +124,8 @@ void Operation_r_b(int MNemonic_Int) { Register = Rr; Bit = Rb; - snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_code, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } void Operation_Rd_b(int MNemonic_Int) { @@ -146,8 +133,8 @@ void Operation_Rd_b(int MNemonic_Int) { Register = Rd; Bit = Rb; - snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_code, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } void Operation_A_b(int MNemonic_Int) { @@ -158,11 +145,11 @@ void Operation_A_b(int MNemonic_Int) { Bit = Rb; Register_Name = Resolve_IO_Register(Register); if(Register_Name == NULL) { - snprintf(Code_Line, 255, "%-7s 0x%02x, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_code, 255, "%-7s 0x%02x, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } else { - snprintf(Code_Line, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_code, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } } @@ -170,8 +157,8 @@ void Operation_s(int MNemonic_Int) { int Bit; Bit = Rs; - snprintf(Code_Line, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_code, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } void Operation_k(int MNemonic_Int, int Position, const char *Pseudocode) { @@ -186,13 +173,13 @@ void Operation_k(int MNemonic_Int, int Position, const char *Pseudocode) { Register_JumpCall(Position, Target, MNemonic_Int, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); } else { - snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); } - snprintf(Comment_Line, 255, "0x%02x", Target); + snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); + snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); } } @@ -216,11 +203,11 @@ CALLBACK(add_Callback) { CALLBACK(adiw_Callback) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); } - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_comment, 255, "%d", RK); } CALLBACK(and_Callback) { @@ -351,15 +338,15 @@ CALLBACK(call_Callback) { Pos = FixTargetAddress(2 * Rk); Register_JumpCall(Position, Pos, MNemonic_Int, 1); if(!cx->dis_opts.Process_Labels) { - snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); + snprintf(cx->dis_code, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); } else { char *LabelName; char *LabelComment = NULL; LabelName = Get_Label_Name(Pos, &LabelComment); - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); + snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); if(LabelComment != NULL) - snprintf(Comment_Line, 255, "%s", LabelComment); + snprintf(cx->dis_comment, 255, "%s", LabelComment); } } @@ -436,11 +423,11 @@ CALLBACK(elpm1_Callback) { } CALLBACK(elpm2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); } CALLBACK(elpm3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); } CALLBACK(eor_Callback) { @@ -478,10 +465,10 @@ CALLBACK(in_Callback) { Register_Number = RA; Register_Name = Resolve_IO_Register(Register_Number); if(Register_Name != NULL) { - snprintf(Code_Line, 255, "%-7s r%d, %s", MNemonic[MNemonic_Int], Rd, Register_Name); + snprintf(cx->dis_code, 255, "%-7s r%d, %s", MNemonic[MNemonic_Int], Rd, Register_Name); } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, Register_Number); - snprintf(Comment_Line, 255, "%d", RA); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, Register_Number); + snprintf(cx->dis_comment, 255, "%d", RA); } } @@ -494,55 +481,55 @@ CALLBACK(jmp_Callback) { Pos = FixTargetAddress(2 * Rk); if(!cx->dis_opts.Process_Labels) { - snprintf(Code_Line, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); + snprintf(cx->dis_code, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); } else { - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Pos, NULL)); + snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Pos, NULL)); } Register_JumpCall(Position, Pos, MNemonic_Int, 0); } CALLBACK(ld1_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, X", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, X", MNemonic[MNemonic_Int], Rd); } CALLBACK(ld2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, X+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, X+", MNemonic[MNemonic_Int], Rd); } CALLBACK(ld3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, -X", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, -X", MNemonic[MNemonic_Int], Rd); } CALLBACK(ldy1_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Y", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Y", MNemonic[MNemonic_Int], Rd); } CALLBACK(ldy2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Y+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Y+", MNemonic[MNemonic_Int], Rd); } CALLBACK(ldy3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, -Y", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, -Y", MNemonic[MNemonic_Int], Rd); } CALLBACK(ldy4_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Y+%d", MNemonic[MNemonic_Int], Rd, Rq); + snprintf(cx->dis_code, 255, "%-7s r%d, Y+%d", MNemonic[MNemonic_Int], Rd, Rq); } CALLBACK(ldz1_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); } CALLBACK(ldz2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); } CALLBACK(ldz3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, -Z", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, -Z", MNemonic[MNemonic_Int], Rd); } CALLBACK(ldz4_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z+%d", MNemonic[MNemonic_Int], Rd, Rq); + snprintf(cx->dis_code, 255, "%-7s r%d, Z+%d", MNemonic[MNemonic_Int], Rd, Rq); } CALLBACK(ldi_Callback) { @@ -552,11 +539,11 @@ CALLBACK(ldi_Callback) { CALLBACK(lds_Callback) { const char *MemAddress; - snprintf(Code_Line, 255, "%-7s r%d, 0x%04x", MNemonic[MNemonic_Int], Rd, Rk); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%04x", MNemonic[MNemonic_Int], Rd, Rk); MemAddress = Tagfile_Resolve_Mem_Address(Rk); - snprintf(Code_Line, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); + snprintf(cx->dis_code, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); if(MemAddress) { - snprintf(Comment_Line, 255, "%s", MemAddress); + snprintf(cx->dis_comment, 255, "%s", MemAddress); } } @@ -565,11 +552,11 @@ CALLBACK(lpm1_Callback) { } CALLBACK(lpm2_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); } CALLBACK(lpm3_Callback) { - snprintf(Code_Line, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); } CALLBACK(lsr_Callback) { @@ -619,10 +606,10 @@ CALLBACK(out_Callback) { Register_Number = RA; Register_Name = Resolve_IO_Register(Register_Number); if(Register_Name != NULL) { - snprintf(Code_Line, 255, "%-7s %s, r%d", MNemonic[MNemonic_Int], Register_Name, Rr); + snprintf(cx->dis_code, 255, "%-7s %s, r%d", MNemonic[MNemonic_Int], Register_Name, Rr); } else { - snprintf(Code_Line, 255, "%-7s 0x%02x, r%d", MNemonic[MNemonic_Int], Register_Number, Rr); - snprintf(Comment_Line, 255, "%d", RA); + snprintf(cx->dis_code, 255, "%-7s 0x%02x, r%d", MNemonic[MNemonic_Int], Register_Number, Rr); + snprintf(cx->dis_comment, 255, "%d", RA); } } @@ -646,25 +633,25 @@ CALLBACK(rcall_Callback) { Register_JumpCall(Position, Target, MNemonic_Int, 1); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); } else { - snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); } - snprintf(Comment_Line, 255, "0x%02x", Target); + snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { char *LabelName; char *LabelComment = NULL; LabelName = Get_Label_Name(Target, &LabelComment); - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); + snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); if(LabelComment != NULL) - snprintf(Comment_Line, 255, "%s", LabelComment); + snprintf(cx->dis_comment, 255, "%s", LabelComment); } } CALLBACK(ret_Callback) { Operation_Simple(MNemonic_Int); - snprintf(After_Code_Line, 255, "\n"); + snprintf(cx->dis_after_code, 255, "\n"); } CALLBACK(reti_Callback) { @@ -684,17 +671,17 @@ CALLBACK(rjmp_Callback) { if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(Code_Line, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); } else { - snprintf(Code_Line, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); } if(Target >= 0) { - snprintf(Comment_Line, 255, "0x%02x", Target); + snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { - snprintf(Comment_Line, 255, "-0x%02x - Illegal jump position -- specify flash size!", -Target); + snprintf(cx->dis_comment, 255, "-0x%02x - Illegal jump position -- specify flash size!", -Target); } } else { - snprintf(Code_Line, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); + snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); } } @@ -724,11 +711,11 @@ CALLBACK(sbis_Callback) { CALLBACK(sbiw_Callback) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); } - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_comment, 255, "%d", RK); } CALLBACK(sbr_Callback) { @@ -788,47 +775,47 @@ CALLBACK(spm_Callback) { } CALLBACK(st1_Callback) { - snprintf(Code_Line, 255, "%-7s X, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s X, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(st2_Callback) { - snprintf(Code_Line, 255, "%-7s X+, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s X+, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(st3_Callback) { - snprintf(Code_Line, 255, "%-7s -X, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s -X, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(sty1_Callback) { - snprintf(Code_Line, 255, "%-7s Y, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s Y, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(sty2_Callback) { - snprintf(Code_Line, 255, "%-7s Y+, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s Y+, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(sty3_Callback) { - snprintf(Code_Line, 255, "%-7s -Y, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s -Y, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(sty4_Callback) { - snprintf(Code_Line, 255, "%-7s Y+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); + snprintf(cx->dis_code, 255, "%-7s Y+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); } CALLBACK(stz1_Callback) { - snprintf(Code_Line, 255, "%-7s Z, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s Z, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(stz2_Callback) { - snprintf(Code_Line, 255, "%-7s Z+, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s Z+, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(stz3_Callback) { - snprintf(Code_Line, 255, "%-7s -Z, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s -Z, r%d", MNemonic[MNemonic_Int], Rr); } CALLBACK(stz4_Callback) { - snprintf(Code_Line, 255, "%-7s Z+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); + snprintf(cx->dis_code, 255, "%-7s Z+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); } CALLBACK(sts_Callback) { @@ -836,9 +823,9 @@ CALLBACK(sts_Callback) { const char *MemAddress; MemAddress = Tagfile_Resolve_Mem_Address(Rk); - snprintf(Code_Line, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); + snprintf(cx->dis_code, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); if(MemAddress) { - snprintf(Comment_Line, 255, "%s", MemAddress); + snprintf(cx->dis_comment, 255, "%s", MemAddress); } } diff --git a/src/disasm_callbacks_assembly.h b/src/disasm_callbacks_assembly.h index f58116aa..b97206d7 100644 --- a/src/disasm_callbacks_assembly.h +++ b/src/disasm_callbacks_assembly.h @@ -25,8 +25,6 @@ JohannesBauer@gmx.de */ -void Activate_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, - Disasm_options *New_Options); void Operation_Simple(int MNemonic_Int); void Operation_Rd(int MNemonic_Int); void Operation_Rd16(int MNemonic_Int); diff --git a/src/disasm_callbacks_pseudocode.c b/src/disasm_callbacks_pseudocode.c index 6da390fa..fa420871 100644 --- a/src/disasm_callbacks_pseudocode.c +++ b/src/disasm_callbacks_pseudocode.c @@ -37,168 +37,155 @@ #include "disasm_ioregisters.h" #include "disasm_tagfile.h" -static char *Code_Line; -static char *Comment_Line; -static char *After_Code_Line; -static int *Registers; - -void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, - Disasm_options *New_Options) { - Code_Line = New_Code_Line; - Comment_Line = New_Comment_Line; - After_Code_Line = New_After_Code_Line; - Registers = New_Registers; -} - void PC_Operation_Simple(int MNemonic_Int) { - snprintf(Code_Line, 255, "%s", MNemonic[MNemonic_Int]); + snprintf(cx->dis_code, 255, "%s", MNemonic[MNemonic_Int]); } void PC_Operation_Rd(int MNemonic_Int) { switch (MNemonic_Int) { case OPCODE_lsl: - snprintf(Code_Line, 255, "r%d <<= 1;", Rd); - snprintf(Comment_Line, 255, "_BV(0) = 0 (logical shift)"); + snprintf(cx->dis_code, 255, "r%d <<= 1;", Rd); + snprintf(cx->dis_comment, 255, "_BV(0) = 0 (logical shift)"); break; case OPCODE_lsr: - snprintf(Code_Line, 255, "r%d >>= 1;", Rd); - snprintf(Comment_Line, 255, "_BV(7) = 0, Carry = _BV(0) (logical shift)"); + snprintf(cx->dis_code, 255, "r%d >>= 1;", Rd); + snprintf(cx->dis_comment, 255, "_BV(7) = 0, Carry = _BV(0) (logical shift)"); break; case OPCODE_ror: - snprintf(Code_Line, 255, "r%d >>= 1;", Rd); - snprintf(Comment_Line, 255, "_BV(7) = Carry, Carry = _BV(0) (rotate right)"); + snprintf(cx->dis_code, 255, "r%d >>= 1;", Rd); + snprintf(cx->dis_comment, 255, "_BV(7) = Carry, Carry = _BV(0) (rotate right)"); break; case OPCODE_asr: - // snprintf(Code_Line, 255, "r%d >>= 1;", Rd); + // snprintf(cx->dis_code, 255, "r%d >>= 1;", Rd); - // snprintf(Comment_Line, 255, "_BV(7) = Sign (Arithmetic Shift)"); - snprintf(Code_Line, 255, "r%d /= 2;", Rd); - snprintf(Comment_Line, 255, "arithmetic shift right"); + // snprintf(cx->dis_comment, 255, "_BV(7) = Sign (Arithmetic Shift)"); + snprintf(cx->dis_code, 255, "r%d /= 2;", Rd); + snprintf(cx->dis_comment, 255, "arithmetic shift right"); break; case OPCODE_swap: - snprintf(Code_Line, 255, "r%d = ((r%d & 0xf0) >> 4) | ((r%d & 0x0f) << 4);", Rd, Rd, Rd); - snprintf(Comment_Line, 255, "swap nibbles"); + snprintf(cx->dis_code, 255, "r%d = ((r%d & 0xf0) >> 4) | ((r%d & 0x0f) << 4);", Rd, Rd, Rd); + snprintf(cx->dis_comment, 255, "swap nibbles"); break; case OPCODE_clr: - snprintf(Code_Line, 255, "r%d = 0x00;", Rd); - snprintf(Comment_Line, 255, "0"); + snprintf(cx->dis_code, 255, "r%d = 0x00;", Rd); + snprintf(cx->dis_comment, 255, "0"); break; default: - snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); } } void PC_Operation_Rd16(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); + snprintf(cx->dis_code, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); } void PC_Operation_Rd_Rr(int MNemonic_Int) { switch (MNemonic_Int) { case OPCODE_add: if(Rd != Rr) { - snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "No carry"); + snprintf(cx->dis_code, 255, "r%d += r%d;", Rd, Rr); + snprintf(cx->dis_comment, 255, "No carry"); } else { - snprintf(Code_Line, 255, "r%d *= 2;", Rd); + snprintf(cx->dis_code, 255, "r%d *= 2;", Rd); } break; case OPCODE_adc: - snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "With carry"); + snprintf(cx->dis_code, 255, "r%d += r%d;", Rd, Rr); + snprintf(cx->dis_comment, 255, "With carry"); break; case OPCODE_sub: - snprintf(Code_Line, 255, "r%d -= r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "No carry"); + snprintf(cx->dis_code, 255, "r%d -= r%d;", Rd, Rr); + snprintf(cx->dis_comment, 255, "No carry"); break; case OPCODE_sbc: - snprintf(Code_Line, 255, "r%d += r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "With carry"); + snprintf(cx->dis_code, 255, "r%d += r%d;", Rd, Rr); + snprintf(cx->dis_comment, 255, "With carry"); break; case OPCODE_mul: - snprintf(Code_Line, 255, "r1:r0 = r%d * r%d;", Rd, Rr); - snprintf(Comment_Line, 255, "Unsigned"); + snprintf(cx->dis_code, 255, "r1:r0 = r%d * r%d;", Rd, Rr); + snprintf(cx->dis_comment, 255, "Unsigned"); break; case OPCODE_mov: - snprintf(Code_Line, 255, "r%d = r%d;", Rd, Rr); + snprintf(cx->dis_code, 255, "r%d = r%d;", Rd, Rr); break; case OPCODE_eor: - snprintf(Code_Line, 255, "r%d ^= r%d;", Rd, Rr); + snprintf(cx->dis_code, 255, "r%d ^= r%d;", Rd, Rr); break; case OPCODE_and: if(Rd != Rr) { - snprintf(Code_Line, 255, "r%d &= r%d;", Rd, Rr); + snprintf(cx->dis_code, 255, "r%d &= r%d;", Rd, Rr); } else { - snprintf(Code_Line, 255, "(r%d == 0) || (r%d < 0);", Rd, Rd); - snprintf(Comment_Line, 255, "test r%d", Rd); + snprintf(cx->dis_code, 255, "(r%d == 0) || (r%d < 0);", Rd, Rd); + snprintf(cx->dis_comment, 255, "test r%d", Rd); } break; case OPCODE_or: - snprintf(Code_Line, 255, "r%d |= r%d;", Rd, Rr); + snprintf(cx->dis_code, 255, "r%d |= r%d;", Rd, Rr); break; case OPCODE_cp: - snprintf(Code_Line, 255, "cmp(r%d, r%d);", Rd, Rr); + snprintf(cx->dis_code, 255, "cmp(r%d, r%d);", Rd, Rr); break; case OPCODE_cpc: - snprintf(Code_Line, 255, "cmp(r%d, r%d);", Rd, Rr); - snprintf(Comment_Line, 255, "with carry"); + snprintf(cx->dis_code, 255, "cmp(r%d, r%d);", Rd, Rr); + snprintf(cx->dis_comment, 255, "with carry"); break; case OPCODE_cpse: - snprintf(Code_Line, 255, "skipif (r%d == r%d)", Rd, Rr); + snprintf(cx->dis_code, 255, "skipif (r%d == r%d)", Rd, Rr); break; default: - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); } } void PC_Operation_Rd16_Rr16(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); } void PC_Operation_Rd16_K(int MNemonic_Int) { switch (MNemonic_Int) { case OPCODE_andi: - snprintf(Code_Line, 255, "r%d &= %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x", RK); + snprintf(cx->dis_code, 255, "r%d &= %d;", Rd + 16, RK); + snprintf(cx->dis_comment, 255, "0x%02x", RK); break; case OPCODE_subi: - snprintf(Code_Line, 255, "r%d -= %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x, no carry", RK); + snprintf(cx->dis_code, 255, "r%d -= %d;", Rd + 16, RK); + snprintf(cx->dis_comment, 255, "0x%02x, no carry", RK); break; case OPCODE_sbci: - snprintf(Code_Line, 255, "r%d -= %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x, with carry", RK); + snprintf(cx->dis_code, 255, "r%d -= %d;", Rd + 16, RK); + snprintf(cx->dis_comment, 255, "0x%02x, with carry", RK); break; case OPCODE_sbr: case OPCODE_ori: - snprintf(Code_Line, 255, "r%d |= %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x", RK); + snprintf(cx->dis_code, 255, "r%d |= %d;", Rd + 16, RK); + snprintf(cx->dis_comment, 255, "0x%02x", RK); break; default: - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); + snprintf(cx->dis_comment, 255, "%d", RK); } } void PC_Operation_Rd_K(int MNemonic_Int) { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(cx->dis_comment, 255, "%d", RK); } void PC_Operation_RdW_K(int MNemonic_Int) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); } else { - snprintf(Code_Line, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); } - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_comment, 255, "%d", RK); } void PC_Operation_RdW_RrW(int MNemonic_Int) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(Code_Line, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); } else { - snprintf(Code_Line, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); } } @@ -215,14 +202,14 @@ void PC_Operation_s_k(int MNemonic_Int, int Position) { Register_JumpCall(Position, Target, MNemonic_Int, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(Code_Line, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); + snprintf(cx->dis_code, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); } else { - snprintf(Code_Line, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); + snprintf(cx->dis_code, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); } - snprintf(Comment_Line, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); + snprintf(cx->dis_comment, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); } else { - snprintf(Code_Line, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); + snprintf(cx->dis_code, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); } } @@ -231,8 +218,8 @@ void PC_Operation_r_b(int MNemonic_Int) { Register = Rr; Bit = Rb; - snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_code, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } void PC_Operation_Rd_b(int MNemonic_Int) { @@ -240,8 +227,8 @@ void PC_Operation_Rd_b(int MNemonic_Int) { Register = Rd; Bit = Rb; - snprintf(Code_Line, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_code, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } void PC_Operation_A_b(int MNemonic_Int) { @@ -258,29 +245,29 @@ void PC_Operation_A_b(int MNemonic_Int) { } switch (MNemonic_Int) { case OPCODE_cbi: - snprintf(Code_Line, 255, "IO[%s] &= ~(_BV(%d));", Register_Name, Bit); + snprintf(cx->dis_code, 255, "IO[%s] &= ~(_BV(%d));", Register_Name, Bit); break; case OPCODE_sbi: - snprintf(Code_Line, 255, "IO[%s] |= _BV(%d);", Register_Name, Bit); + snprintf(cx->dis_code, 255, "IO[%s] |= _BV(%d);", Register_Name, Bit); break; case OPCODE_sbis: - snprintf(Code_Line, 255, "skipif (IO[%s] & _BV(%d))", Register_Name, Bit); + snprintf(cx->dis_code, 255, "skipif (IO[%s] & _BV(%d))", Register_Name, Bit); break; case OPCODE_sbic: - snprintf(Code_Line, 255, "skipif (!(IO[%s] & _BV(%d)))", Register_Name, Bit); + snprintf(cx->dis_code, 255, "skipif (!(IO[%s] & _BV(%d)))", Register_Name, Bit); break; default: - snprintf(Code_Line, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); + snprintf(cx->dis_code, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); } - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } void PC_Operation_s(int MNemonic_Int) { int Bit; Bit = Rs; - snprintf(Code_Line, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); - snprintf(Comment_Line, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); + snprintf(cx->dis_code, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); + snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { @@ -295,13 +282,13 @@ void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { Register_JumpCall(Position, Target, MNemonic_Int, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(Code_Line, 255, "if (%s) goto .+%d;", Pseudocode, Offset); + snprintf(cx->dis_code, 255, "if (%s) goto .+%d;", Pseudocode, Offset); } else { - snprintf(Code_Line, 255, "if (%s) goto .%d", Pseudocode, Offset); + snprintf(cx->dis_code, 255, "if (%s) goto .%d", Pseudocode, Offset); } - snprintf(Comment_Line, 255, "0x%02x", Target); + snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { - snprintf(Code_Line, 255, "if (%s) goto %s;", Pseudocode, Get_Label_Name(Target, NULL)); + snprintf(cx->dis_code, 255, "if (%s) goto %s;", Pseudocode, Get_Label_Name(Target, NULL)); } } @@ -406,10 +393,10 @@ CALLBACK(out_Callback_PC) { Register_Number = RA; Register_Name = Resolve_IO_Register(Register_Number); if(Register_Name) { - snprintf(Code_Line, 255, "IO[%s] = r%d;", Register_Name, Rr); + snprintf(cx->dis_code, 255, "IO[%s] = r%d;", Register_Name, Rr); } else { - snprintf(Code_Line, 255, "IO[0x%02x] = r%d;", Register_Number, Rr); - snprintf(Comment_Line, 255, "%d", RA); + snprintf(cx->dis_code, 255, "IO[0x%02x] = r%d;", Register_Number, Rr); + snprintf(cx->dis_comment, 255, "%d", RA); } } @@ -420,29 +407,29 @@ CALLBACK(in_Callback_PC) { Register_Number = RA; Register_Name = Resolve_IO_Register(Register_Number); if(Register_Name) { - snprintf(Code_Line, 255, "r%d = IO[%s];", Rd, Register_Name); + snprintf(cx->dis_code, 255, "r%d = IO[%s];", Rd, Register_Name); } else { - snprintf(Code_Line, 255, "r%d = IO[0x%02x];", Rd, Register_Number); - snprintf(Comment_Line, 255, "%d", RA); + snprintf(cx->dis_code, 255, "r%d = IO[0x%02x];", Rd, Register_Number); + snprintf(cx->dis_comment, 255, "%d", RA); } } CALLBACK(cli_Callback_PC) { - snprintf(Code_Line, 255, "Disable_Interrupts();"); + snprintf(cx->dis_code, 255, "Disable_Interrupts();"); } CALLBACK(sei_Callback_PC) { - snprintf(Code_Line, 255, "Enable_Interrupts();"); + snprintf(cx->dis_code, 255, "Enable_Interrupts();"); } CALLBACK(ret_Callback_PC) { - snprintf(Code_Line, 255, "return;"); - snprintf(After_Code_Line, 255, "\n"); + snprintf(cx->dis_code, 255, "return;"); + snprintf(cx->dis_after_code, 255, "\n"); } CALLBACK(reti_Callback_PC) { - snprintf(Code_Line, 255, "ireturn;"); - snprintf(After_Code_Line, 255, "\n"); + snprintf(cx->dis_code, 255, "ireturn;"); + snprintf(cx->dis_after_code, 255, "\n"); } CALLBACK(andi_Callback_PC) { @@ -466,8 +453,8 @@ CALLBACK(ori_Callback_PC) { } CALLBACK(ldi_Callback_PC) { - snprintf(Code_Line, 255, "r%d = %d;", Rd + 16, RK); - snprintf(Comment_Line, 255, "0x%02x", RK); + snprintf(cx->dis_code, 255, "r%d = %d;", Rd + 16, RK); + snprintf(cx->dis_comment, 255, "0x%02x", RK); } CALLBACK(lds_Callback_PC) { @@ -475,11 +462,11 @@ CALLBACK(lds_Callback_PC) { MemAddress = Tagfile_Resolve_Mem_Address(Rk); if(!MemAddress) { - snprintf(Code_Line, 255, "r%d = Memory[0x%04x];", Rd, Rk); - snprintf(Comment_Line, 255, "%d", Rk); + snprintf(cx->dis_code, 255, "r%d = Memory[0x%04x];", Rd, Rk); + snprintf(cx->dis_comment, 255, "%d", Rk); } else { - snprintf(Code_Line, 255, "r%d = %s;", Rd, MemAddress); - snprintf(Comment_Line, 255, "0x%04x", Rk); + snprintf(cx->dis_code, 255, "r%d = %s;", Rd, MemAddress); + snprintf(cx->dis_comment, 255, "0x%04x", Rk); } } @@ -488,11 +475,11 @@ CALLBACK(sts_Callback_PC) { MemAddress = Tagfile_Resolve_Mem_Address(Rk); if(!MemAddress) { - snprintf(Code_Line, 255, "Memory[0x%04x] = r%d;", Rk, Rd); - snprintf(Comment_Line, 255, "%d", Rk); + snprintf(cx->dis_code, 255, "Memory[0x%04x] = r%d;", Rk, Rd); + snprintf(cx->dis_comment, 255, "%d", Rk); } else { - snprintf(Code_Line, 255, "%s = r%d;", MemAddress, Rd); - snprintf(Comment_Line, 255, "0x%04x", Rk); + snprintf(cx->dis_code, 255, "%s = r%d;", MemAddress, Rd); + snprintf(cx->dis_comment, 255, "0x%04x", Rk); } } @@ -502,15 +489,15 @@ CALLBACK(call_Callback_PC) { Pos = FixTargetAddress(2 * Rk); Register_JumpCall(Position, Pos, MNemonic_Int, 1); if(cx->dis_opts.Process_Labels == 0) { - snprintf(Code_Line, 255, "0x%02x();", Pos); + snprintf(cx->dis_code, 255, "0x%02x();", Pos); } else { char *LabelName; char *LabelComment = NULL; LabelName = Get_Label_Name(Pos, &LabelComment); - snprintf(Code_Line, 255, "%s();", LabelName); + snprintf(cx->dis_code, 255, "%s();", LabelName); if(LabelComment != NULL) { - snprintf(Comment_Line, 255, "%s", LabelComment); + snprintf(cx->dis_comment, 255, "%s", LabelComment); } } } @@ -526,15 +513,15 @@ CALLBACK(rcall_Callback_PC) { Register_JumpCall(Position, Target, MNemonic_Int, 1); if(!cx->dis_opts.Process_Labels) { - snprintf(Comment_Line, 255, "0x%02x();", Target); + snprintf(cx->dis_comment, 255, "0x%02x();", Target); } else { char *LabelName; char *LabelComment = NULL; LabelName = Get_Label_Name(Target, &LabelComment); - snprintf(Code_Line, 255, "%s();", LabelName); + snprintf(cx->dis_code, 255, "%s();", LabelName); if(LabelComment != NULL) { - snprintf(Comment_Line, 255, "%s", LabelComment); + snprintf(cx->dis_comment, 255, "%s", LabelComment); } } } @@ -564,9 +551,9 @@ CALLBACK(jmp_Callback_PC) { Pos = FixTargetAddress(2 * Rk); if(cx->dis_opts.Process_Labels == 0) { - snprintf(Code_Line, 255, "goto 0x%02x;", Pos); + snprintf(cx->dis_code, 255, "goto 0x%02x;", Pos); } else { - snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Pos, NULL)); + snprintf(cx->dis_code, 255, "goto %s;", Get_Label_Name(Pos, NULL)); } Register_JumpCall(Position, Pos, MNemonic_Int, 0); } @@ -584,26 +571,26 @@ CALLBACK(rjmp_Callback_PC) { if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(Code_Line, 255, "goto .+%d;", Offset); + snprintf(cx->dis_code, 255, "goto .+%d;", Offset); } else { - snprintf(Code_Line, 255, "goto .%d", Offset); + snprintf(cx->dis_code, 255, "goto .%d", Offset); } if(Target >= 0) { - snprintf(Comment_Line, 255, "0x%02x", Target); + snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { - snprintf(Comment_Line, 255, "-0x%02x - Illegal jump position -- specify flash size!", -(Target)); + snprintf(cx->dis_comment, 255, "-0x%02x - Illegal jump position -- specify flash size!", -(Target)); } } else { - snprintf(Code_Line, 255, "goto %s;", Get_Label_Name(Position + Offset + 2, NULL)); + snprintf(cx->dis_code, 255, "goto %s;", Get_Label_Name(Position + Offset + 2, NULL)); } } CALLBACK(cpi_Callback_PC) { if(RK == 0) { - snprintf(Code_Line, 255, "cmp(r%d, 0);", Rd + 16); + snprintf(cx->dis_code, 255, "cmp(r%d, 0);", Rd + 16); } else { - snprintf(Code_Line, 255, "cmp(r%d, 0x%02x);", Rd + 16, RK); - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_code, 255, "cmp(r%d, 0x%02x);", Rd + 16, RK); + snprintf(cx->dis_comment, 255, "%d", RK); } } @@ -612,11 +599,11 @@ CALLBACK(asr_Callback_PC) { } CALLBACK(dec_Callback_PC) { - snprintf(Code_Line, 255, "r%d--;", Rd); + snprintf(cx->dis_code, 255, "r%d--;", Rd); } CALLBACK(inc_Callback_PC) { - snprintf(Code_Line, 255, "r%d++;", Rd); + snprintf(cx->dis_code, 255, "r%d++;", Rd); } CALLBACK(cp_Callback_PC) { @@ -660,27 +647,27 @@ CALLBACK(cbi_Callback_PC) { } CALLBACK(ser_Callback_PC) { - snprintf(Code_Line, 255, "r%d = 0xff;", Rd + 16); - snprintf(Comment_Line, 255, "255"); + snprintf(cx->dis_code, 255, "r%d = 0xff;", Rd + 16); + snprintf(cx->dis_comment, 255, "255"); } CALLBACK(adiw_Callback_PC) { if(RK != 1) { - snprintf(Code_Line, 255, "[r%d:r%d] += 0x%02x;", 2 * Rd + 25, 2 * Rd + 24, RK); - snprintf(Comment_Line, 255, "%d", RK); + snprintf(cx->dis_code, 255, "[r%d:r%d] += 0x%02x;", 2 * Rd + 25, 2 * Rd + 24, RK); + snprintf(cx->dis_comment, 255, "%d", RK); } else { - snprintf(Code_Line, 255, "[r%d:r%d]++;", 2 * Rd + 25, 2 * Rd + 24); + snprintf(cx->dis_code, 255, "[r%d:r%d]++;", 2 * Rd + 25, 2 * Rd + 24); } } CALLBACK(movw_Callback_PC) { - snprintf(Code_Line, 255, "[r%d:r%d] = [r%d:r%d];", (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); + snprintf(cx->dis_code, 255, "[r%d:r%d] = [r%d:r%d];", (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); } CALLBACK(lpm1_Callback_PC) { - snprintf(Code_Line, 255, "r0 = Flash[r30:r31];"); + snprintf(cx->dis_code, 255, "r0 = Flash[r30:r31];"); } CALLBACK(st2_Callback_PC) { - snprintf(Code_Line, 255, "Flash[[r26:r27]++] = r%d;", Rr); + snprintf(cx->dis_code, 255, "Flash[[r26:r27]++] = r%d;", Rr); } diff --git a/src/disasm_callbacks_pseudocode.h b/src/disasm_callbacks_pseudocode.h index c98978f9..36bf2f01 100644 --- a/src/disasm_callbacks_pseudocode.h +++ b/src/disasm_callbacks_pseudocode.h @@ -25,8 +25,6 @@ JohannesBauer@gmx.de */ -void Activate_PC_Callbacks(char *New_Code_Line, char *New_Comment_Line, char *New_After_Code_Line, int *New_Registers, - Disasm_options *New_Options); void PC_Operation_Simple(int MNemonic_Int); void PC_Operation_Rd(int MNemonic_Int); void PC_Operation_Rd16(int MNemonic_Int); diff --git a/src/disasm_globals.h b/src/disasm_globals.h index 143f235b..0c9016ab 100644 --- a/src/disasm_globals.h +++ b/src/disasm_globals.h @@ -25,23 +25,17 @@ JohannesBauer@gmx.de */ -#define Rd (Registers[(int)'d']) -#define Rr (Registers[(int)'r']) -#define Rk (Registers[(int)'k']) -#define RK (Registers[(int)'K']) -#define Rs (Registers[(int)'s']) -#define RA (Registers[(int)'A']) -#define Rb (Registers[(int)'b']) -#define Rq (Registers[(int)'q']) +#define Rd (cx->dis_regs['d']) +#define Rr (cx->dis_regs['r']) +#define Rk (cx->dis_regs['k']) +#define RK (cx->dis_regs['K']) +#define Rs (cx->dis_regs['s']) +#define RA (cx->dis_regs['A']) +#define Rb (cx->dis_regs['b']) +#define Rq (cx->dis_regs['q']) #define CALLBACK(name) void name(const char *Bitstream, int Position, int MNemonic_Int) -struct Opcode { - char *Opcode_String; - void (*Callback)(const char *, int, int); - int MNemonic; -}; - struct JumpCall { int From; int To; diff --git a/src/libavrdude.h b/src/libavrdude.h index 4d4e4c29..f3b07c4b 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1460,6 +1460,12 @@ typedef struct { int FlashSize; } Disasm_options; +typedef struct { + char *Opcode_String; + void (*Callback)(const char *, int, int); + int MNemonic; +} Disasm_opcode; + #define CODESTYLE_AVR_INSTRUCTION_SET 0 #define CODESTYLE_AVRGCC 1 @@ -1657,8 +1663,12 @@ typedef struct { int reccount; // Static variables from disasm*.c - Disasm_options dis_opts; int dis_initopts; + Disasm_options dis_opts; + int dis_n_ops; + Disasm_opcode dis_op[256]; // Must be 256 + int dis_regs[256]; // Must be 256 + char dis_code[256], dis_comment[256], dis_after_code[256]; // Must be 256 // Static variables from usb_libusb.c #include "usbdevs.h" From 6d62c8312a2b3b144ed0d35eaa8e89a008a3078c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 20:44:20 +0100 Subject: [PATCH 280/422] Enum opcodes instead of #define --- src/disasm_globals.h | 274 ++++++++++++++++++++++--------------------- 1 file changed, 138 insertions(+), 136 deletions(-) diff --git a/src/disasm_globals.h b/src/disasm_globals.h index 0c9016ab..be61bddb 100644 --- a/src/disasm_globals.h +++ b/src/disasm_globals.h @@ -50,139 +50,141 @@ struct IO_Register { unsigned char Used; }; -#define OPCODE_adc 0 -#define OPCODE_add 1 -#define OPCODE_adiw 2 -#define OPCODE_and 3 -#define OPCODE_andi 4 -#define OPCODE_asr 5 -#define OPCODE_bclr 6 -#define OPCODE_bld 7 -#define OPCODE_brbc 8 -#define OPCODE_brbs 9 -#define OPCODE_brcc 10 -#define OPCODE_brcs 11 -#define OPCODE_break 12 -#define OPCODE_breq 13 -#define OPCODE_brge 14 -#define OPCODE_brhc 15 -#define OPCODE_brhs 16 -#define OPCODE_brid 17 -#define OPCODE_brie 18 -#define OPCODE_brlo 19 -#define OPCODE_brlt 20 -#define OPCODE_brmi 21 -#define OPCODE_brne 22 -#define OPCODE_brpl 23 -#define OPCODE_brsh 24 -#define OPCODE_brtc 25 -#define OPCODE_brts 26 -#define OPCODE_brvc 27 -#define OPCODE_brvs 28 -#define OPCODE_bset 29 -#define OPCODE_bst 30 -#define OPCODE_call 31 -#define OPCODE_cbi 32 -#define OPCODE_cbr 33 -#define OPCODE_clc 34 -#define OPCODE_clh 35 -#define OPCODE_cli 36 -#define OPCODE_cln 37 -#define OPCODE_clr 38 -#define OPCODE_cls 39 -#define OPCODE_clt 40 -#define OPCODE_clv 41 -#define OPCODE_clz 42 -#define OPCODE_com 43 -#define OPCODE_cp 44 -#define OPCODE_cpc 45 -#define OPCODE_cpi 46 -#define OPCODE_cpse 47 -#define OPCODE_dec 48 -#define OPCODE_eicall 49 -#define OPCODE_eijmp 50 -#define OPCODE_elpm_1 51 -#define OPCODE_elpm_2 52 -#define OPCODE_elpm_3 53 -#define OPCODE_eor 54 -#define OPCODE_fmul 55 -#define OPCODE_fmuls 56 -#define OPCODE_fmulsu 57 -#define OPCODE_icall 58 -#define OPCODE_ijmp 59 -#define OPCODE_in 60 -#define OPCODE_inc 61 -#define OPCODE_jmp 62 -#define OPCODE_ld_1 63 -#define OPCODE_ld_2 64 -#define OPCODE_ld_3 65 -#define OPCODE_ld_4 66 -#define OPCODE_ld_5 67 -#define OPCODE_ld_6 68 -#define OPCODE_ldd_1 69 -#define OPCODE_ld_7 70 -#define OPCODE_ld_8 71 -#define OPCODE_ld_9 72 -#define OPCODE_ldd_2 73 -#define OPCODE_ldi 74 -#define OPCODE_lds 75 -#define OPCODE_lpm_1 76 -#define OPCODE_lpm_2 77 -#define OPCODE_lpm_3 78 -#define OPCODE_lsl 79 -#define OPCODE_lsr 80 -#define OPCODE_mov 81 -#define OPCODE_movw 82 -#define OPCODE_mul 83 -#define OPCODE_muls 84 -#define OPCODE_mulsu 85 -#define OPCODE_neg 86 -#define OPCODE_nop 87 -#define OPCODE_or 88 -#define OPCODE_ori 89 -#define OPCODE_out 90 -#define OPCODE_pop 91 -#define OPCODE_push 92 -#define OPCODE_rcall 93 -#define OPCODE_ret 94 -#define OPCODE_reti 95 -#define OPCODE_rjmp 96 -#define OPCODE_rol 97 -#define OPCODE_ror 98 -#define OPCODE_sbc 99 -#define OPCODE_sbci 100 -#define OPCODE_sbi 101 -#define OPCODE_sbic 102 -#define OPCODE_sbis 103 -#define OPCODE_sbiw 104 -#define OPCODE_sbr 105 -#define OPCODE_sbrc 106 -#define OPCODE_sbrs 107 -#define OPCODE_sec 108 -#define OPCODE_seh 109 -#define OPCODE_sei 110 -#define OPCODE_sen 111 -#define OPCODE_ser 112 -#define OPCODE_ses 113 -#define OPCODE_set 114 -#define OPCODE_sev 115 -#define OPCODE_sez 116 -#define OPCODE_sleep 117 -#define OPCODE_spm 118 -#define OPCODE_st_1 119 -#define OPCODE_st_2 120 -#define OPCODE_st_3 121 -#define OPCODE_st_4 122 -#define OPCODE_st_5 123 -#define OPCODE_st_6 124 -#define OPCODE_std_1 125 -#define OPCODE_st_7 126 -#define OPCODE_st_8 127 -#define OPCODE_st_9 128 -#define OPCODE_std_2 129 -#define OPCODE_sts 130 -#define OPCODE_sub 131 -#define OPCODE_subi 132 -#define OPCODE_swap 133 -#define OPCODE_tst 134 -#define OPCODE_wdr 135 +enum { + OPCODE_adc, + OPCODE_add, + OPCODE_adiw, + OPCODE_and, + OPCODE_andi, + OPCODE_asr, + OPCODE_bclr, + OPCODE_bld, + OPCODE_brbc, + OPCODE_brbs, + OPCODE_brcc, + OPCODE_brcs, + OPCODE_break, + OPCODE_breq, + OPCODE_brge, + OPCODE_brhc, + OPCODE_brhs, + OPCODE_brid, + OPCODE_brie, + OPCODE_brlo, + OPCODE_brlt, + OPCODE_brmi, + OPCODE_brne, + OPCODE_brpl, + OPCODE_brsh, + OPCODE_brtc, + OPCODE_brts, + OPCODE_brvc, + OPCODE_brvs, + OPCODE_bset, + OPCODE_bst, + OPCODE_call, + OPCODE_cbi, + OPCODE_cbr, + OPCODE_clc, + OPCODE_clh, + OPCODE_cli, + OPCODE_cln, + OPCODE_clr, + OPCODE_cls, + OPCODE_clt, + OPCODE_clv, + OPCODE_clz, + OPCODE_com, + OPCODE_cp, + OPCODE_cpc, + OPCODE_cpi, + OPCODE_cpse, + OPCODE_dec, + OPCODE_eicall, + OPCODE_eijmp, + OPCODE_elpm_1, + OPCODE_elpm_2, + OPCODE_elpm_3, + OPCODE_eor, + OPCODE_fmul, + OPCODE_fmuls, + OPCODE_fmulsu, + OPCODE_icall, + OPCODE_ijmp, + OPCODE_in, + OPCODE_inc, + OPCODE_jmp, + OPCODE_ld_1, + OPCODE_ld_2, + OPCODE_ld_3, + OPCODE_ld_4, + OPCODE_ld_5, + OPCODE_ld_6, + OPCODE_ldd_1, + OPCODE_ld_7, + OPCODE_ld_8, + OPCODE_ld_9, + OPCODE_ldd_2, + OPCODE_ldi, + OPCODE_lds, + OPCODE_lpm_1, + OPCODE_lpm_2, + OPCODE_lpm_3, + OPCODE_lsl, + OPCODE_lsr, + OPCODE_mov, + OPCODE_movw, + OPCODE_mul, + OPCODE_muls, + OPCODE_mulsu, + OPCODE_neg, + OPCODE_nop, + OPCODE_or, + OPCODE_ori, + OPCODE_out, + OPCODE_pop, + OPCODE_push, + OPCODE_rcall, + OPCODE_ret, + OPCODE_reti, + OPCODE_rjmp, + OPCODE_rol, + OPCODE_ror, + OPCODE_sbc, + OPCODE_sbci, + OPCODE_sbi, + OPCODE_sbic, + OPCODE_sbis, + OPCODE_sbiw, + OPCODE_sbr, + OPCODE_sbrc, + OPCODE_sbrs, + OPCODE_sec, + OPCODE_seh, + OPCODE_sei, + OPCODE_sen, + OPCODE_ser, + OPCODE_ses, + OPCODE_set, + OPCODE_sev, + OPCODE_sez, + OPCODE_sleep, + OPCODE_spm, + OPCODE_st_1, + OPCODE_st_2, + OPCODE_st_3, + OPCODE_st_4, + OPCODE_st_5, + OPCODE_st_6, + OPCODE_std_1, + OPCODE_st_7, + OPCODE_st_8, + OPCODE_st_9, + OPCODE_std_2, + OPCODE_sts, + OPCODE_sub, + OPCODE_subi, + OPCODE_swap, + OPCODE_tst, + OPCODE_wdr, +}; From baab44f9f58315c1d365bce9933e221331380816 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 22:21:26 +0100 Subject: [PATCH 281/422] Provide avr_opcodes[] table --- src/CMakeLists.txt | 3 +- src/Makefile.am | 3 +- src/avr_opcodes.c | 199 +++++++++++++ src/disasm.c | 74 +++-- src/disasm_callbacks_assembly.c | 371 +++++++++++++------------ src/disasm_callbacks_assembly.h | 292 +++++++++---------- src/disasm_callbacks_pseudocode.c | 173 ++++++------ src/disasm_callbacks_pseudocode.h | 158 +++++------ src/disasm_globals.h | 140 +--------- src/disasm_jumpcall.c | 5 +- src/disasm_mnemonics.c | 447 ------------------------------ src/disasm_mnemonics.h | 29 -- src/libavrdude.h | 69 ++++- 13 files changed, 819 insertions(+), 1144 deletions(-) create mode 100644 src/avr_opcodes.c delete mode 100644 src/disasm_mnemonics.c delete mode 100644 src/disasm_mnemonics.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index abab7c60..287bd927 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -166,6 +166,7 @@ add_library(libavrdude avrftdi_tpi.h avrintel.c libavrdude-avrintel.h + avr_opcodes.c avrpart.c bitbang.c bitbang.h @@ -190,8 +191,6 @@ add_library(libavrdude disasm_ioregisters.h disasm_jumpcall.c disasm_jumpcall.h - disasm_mnemonics.c - disasm_mnemonics.h disasm_tagfile.c disasm_tagfile.h dfu.c diff --git a/src/Makefile.am b/src/Makefile.am index f0b76811..a7fb916b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,6 +105,7 @@ libavrdude_a_SOURCES = \ avrintel.c \ libavrdude-avrintel.h \ avrpart.c \ + avr_opcodes.c \ bitbang.c \ bitbang.h \ buspirate.c \ @@ -128,8 +129,6 @@ libavrdude_a_SOURCES = \ disasm_ioregisters.h \ disasm_jumpcall.c \ disasm_jumpcall.h \ - disasm_mnemonics.c \ - disasm_mnemonics.h \ disasm_tagfile.c \ disasm_tagfile.h \ dfu.c \ diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c new file mode 100644 index 00000000..07089cce --- /dev/null +++ b/src/avr_opcodes.c @@ -0,0 +1,199 @@ +/* + * AVRDUDE - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2024 Stefan Rueger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include "libavrdude.h" + +const AVR_opcode_data avr_opcodes[164] = { + // Arithmetic and Logic Instructions + {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OPCODE_add, "ADD", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OPCODE_adc, "ADC", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OPCODE_adiw, "ADIW", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", "2", "2", "2", "n/a", "(1)", "d in {24, 26, 28, 30}"}, + {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OPCODE_sub, "SUB", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OPCODE_subi, "SUBI", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OPCODE_sbc, "SBC", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OPCODE_sbci, "SBCI", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", "d=16..31"}, + {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OPCODE_sbiw, "SBIW", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", "2", "2", "2", "n/a", "(1)", "d in {24, 26, 28, 30}"}, + {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OPCODE_and, "AND", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OPCODE_andi, "ANDI", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", "1", "1", "1", "1", "", "d = 16..31"}, + {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OPCODE_or, "OR", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OPCODE_ori, "ORI", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OPCODE_eor, "EOR", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OPCODE_com, "COM", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OPCODE_neg, "NEG", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OPCODE_sbr, "SBR", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", "1", "1", "1", "1", "", "alias for ORI Rd, K"}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OPCODE_cbr, "CBR", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", "1", "1", "1", "1", "", "alias for ANDI Rd, (0xFF - K)"}, + {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OPCODE_inc, "INC", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OPCODE_dec, "DEC", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OPCODE_tst, "TST", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", "1", "1", "1", "1", "", "alias for AND Rd, Rd"}, + {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OPCODE_clr, "CLR", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", "1", "1", "1", "1", "", "alias for EOR Rd, Rd"}, + {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OPCODE_ser, "SER", "Rd", "Set Register", "Rd <-- $FF", "None", "1", "1", "1", "1", "", "alias for LDI Rd, 0xFF"}, + {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OPCODE_mul, "MUL", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", "2", "2", "2", "n/a", "(1)", ""}, + {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OPCODE_muls, "MULS", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", "2", "2", "2", "n/a", "(1)", "d, r=16..31"}, + {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OPCODE_mulsu, "MULSU", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", "2", "2", "2", "n/a", "(1)", "d, r=16..23"}, + {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OPCODE_fmul, "FMUL", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, + {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OPCODE_fmuls, "FMULS", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, + {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OPCODE_fmulsu, "FMULSU", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, + {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OPCODE_des, "DES", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", "n/a", "1/2", "n/a", "n/a", "", ""}, + + // Branch Instructions + {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OPCODE_rjmp, "RJMP", "k", "Relative Jump", "PC <-- PC+k+1", "None", "2", "2", "2", "2", "", ""}, + {0xffff, 0x9409, 1, "1001 0100 0000 1001", OPCODE_ijmp, "IJMP", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "2", "2", "2", "2", "(1)", ""}, + {0xffff, 0x9419, 1, "1001 0100 0001 1001", OPCODE_eijmp, "EIJMP", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "2", "2", "2", "n/a", "(1)", ""}, + {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp, "JMP", "k", "Jump", "PC <-- k", "None", "3", "3", "3", "n/a", "(1)", ""}, + {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OPCODE_rcall, "RCALL", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", "3/4", "2/3", "2/3", "3", "", ""}, + {0xffff, 0x9509, 1, "1001 0101 0000 1001", OPCODE_icall, "ICALL", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "3/4", "2/3", "2/3", "3", "(1)", ""}, + {0xffff, 0x9519, 1, "1001 0101 0001 1001", OPCODE_eicall, "EICALL", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "4", "3", "3", "n/a", "(1)", ""}, + {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call, "CALL", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", "4/5", "3/4", "3/4", "n/a", "(1)", ""}, + {0xffff, 0x9508, 1, "1001 0101 0000 1000", OPCODE_ret, "RET", "-", "Subroutine Return", "PC <-- STACK", "None", "4/5", "4/5", "4/5", "6", "", ""}, + {0xffff, 0x9518, 1, "1001 0101 0001 1000", OPCODE_reti, "RETI", "-", "Interrupt Return", "PC <-- STACK", "I", "4/5", "4/5", "4/5", "6", "", ""}, + {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OPCODE_cpse, "CPSE", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, + {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OPCODE_cp, "CP", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OPCODE_cpc, "CPC", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OPCODE_cpi, "CPI", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", "1", "1", "1", "1", "", "d = 16..31"}, + {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OPCODE_sbrc, "SBRC", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, + {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OPCODE_sbrs, "SBRS", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, + {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OPCODE_sbic, "SBIC", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", "", ""}, + {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OPCODE_sbis, "SBIS", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", "", ""}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OPCODE_brcs, "BRCS", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OPCODE_brlo, "BRLO", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OPCODE_breq, "BREQ", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 1, k (Z Zero)"}, + {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OPCODE_brmi, "BRMI", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 2, k (N Negative)"}, + {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OPCODE_brvs, "BRVS", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OPCODE_brlt, "BRLT", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 4, k (S Sign)"}, + {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OPCODE_brhs, "BRHS", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 5, k (H Half carry)"}, + {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OPCODE_brts, "BRTS", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 6, k (T Transfer bit)"}, + {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OPCODE_brie, "BRIE", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 7, k (I Interrupt enable)"}, + {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OPCODE_brbs, "BRBS", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", ""}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OPCODE_brcc, "BRCC", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OPCODE_brsh, "BRSH", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OPCODE_brne, "BRNE", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 1, k (Z Zero)"}, + {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OPCODE_brpl, "BRPL", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 2, k (N Negative)"}, + {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OPCODE_brvc, "BRVC", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OPCODE_brge, "BRGE", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 4, k (S Sign)"}, + {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OPCODE_brhc, "BRHC", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 5, k (H Half carry)"}, + {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OPCODE_brtc, "BRTC", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 6, k (T Transfer bit)"}, + {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OPCODE_brid, "BRID", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 7, k (I Interrupt enable)"}, + {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OPCODE_brbc, "BRBC", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", ""}, + + // Data Transfer Instructions + {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OPCODE_mov, "MOV", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", "1", "1", "1", "1", "", ""}, + {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OPCODE_movw, "MOVW", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", "1", "1", "1", "n/a", "(1)", ""}, + {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OPCODE_ldi, "LDI", "Rd, K", "Load Immediate", "Rd <-- K", "None", "1", "1", "1", "1", "", "d=16..31"}, + {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds, "LDS", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "2", "3", "3", "2", "(1)", ""}, + {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OPCODE_lds_rc, "LDS", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "n/a", "n/a", "n/a", "2", "(1)", "attiny only"}, + {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OPCODE_ld_1, "LD", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", "2", "2", "2", "1/2", "(2)", ""}, + {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OPCODE_ld_2, "LD", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", "2", "2", "2", "2/3", "(2)", ""}, + {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OPCODE_ld_3, "LD", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", "2", "3", "2", "2/3", "(2)", ""}, + {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OPCODE_ld_4, "LD", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", "2", "2", "2", "1/2", "(2)", "alias for LDD Rd, Y+0"}, + {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OPCODE_ld_5, "LD", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", "2", "2", "2", "2/3", "(2)", ""}, + {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OPCODE_ld_6, "LD", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", "2", "3", "2", "2/3", "(2)", ""}, + {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OPCODE_ldd_1, "LDD", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", "2", "3", "2", "n/a", "(1)", ""}, + {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OPCODE_ld_7, "LD", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", "2", "2", "2", "1/2", "(2)", "alias for LDD Rd,Z+0"}, + {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OPCODE_ld_8, "LD", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", "2", "2", "2", "2/3", "(2)", ""}, + {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OPCODE_ld_9, "LD", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", "2", "3", "2", "2/3", "(2)", ""}, + {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2, "LDD", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", "2", "3", "2", "n/a", "(1)", ""}, + {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts, "STS", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "2", "2", "2", "1", "(1)", ""}, + {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OPCODE_sts_rc, "STS", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "n/a", "n/a", "n/a", "1", "(1)", "attiny only"}, + {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OPCODE_st_1, "ST", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", "2", "1", "1", "1", "(2)", ""}, + {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OPCODE_st_2, "ST", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", "2", "1", "1", "1", "(2)", ""}, + {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OPCODE_st_3, "ST", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", "2", "2", "1", "1", "(2)", ""}, + {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OPCODE_st_4, "ST", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", "2", "1", "1", "1", "(2)", "alias for STD Y+0, Rr"}, + {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OPCODE_st_5, "ST", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", "2", "1", "1", "1", "(2)", ""}, + {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OPCODE_st_6, "ST", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", "2", "2", "1", "1", "(2)", ""}, + {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OPCODE_std_1, "STD", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", "2", "2", "1", "n/a", "(1)", ""}, + {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OPCODE_st_7, "ST", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", "2", "1", "1", "1", "(2)", "alias for STD Z+0, Rr"}, + {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OPCODE_st_8, "ST", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", "2", "1", "1", "1", "(2)", ""}, + {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OPCODE_st_9, "ST", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", "2", "2", "1", "1", "(2)", ""}, + {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OPCODE_std_2, "STD", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", "2", "2", "1", "n/a", "(1)", ""}, + {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OPCODE_lpm_1, "LPM", "-", "Load Program Memory", "R0 <-- (Z)", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, + {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OPCODE_lpm_2, "LPM", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, + {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OPCODE_lpm_3, "LPM", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, + {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OPCODE_elpm_1, "ELPM", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", "(1)", ""}, + {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OPCODE_elpm_2, "ELPM", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", "(1)", ""}, + {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OPCODE_elpm_3, "ELPM", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", "(1)", ""}, + {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OPCODE_spm, "SPM", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", "-", "-", "-", "-", "(1)", ""}, + {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OPCODE_spm_zz, "SPM", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", "n/a", "-", "-", "n/a", "(1)", ""}, + {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OPCODE_in, "IN", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", "1", "1", "1", "1", "", ""}, + {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OPCODE_out, "OUT", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OPCODE_push, "PUSH", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", "2", "1", "1", "1", "(1)", ""}, + {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OPCODE_pop, "POP", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", "2", "2", "2", "3", "(1)", ""}, + {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OPCODE_xch, "XCH", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OPCODE_las, "LAS", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OPCODE_lac, "LAC", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OPCODE_lat, "LAT", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + + // Bit and Bit-test Instructions + {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OPCODE_lsl, "LSL", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", "1", "1", "1", "1", "", "alias for ADD Rd, Rd"}, + {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OPCODE_lsr, "LSR", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OPCODE_rol, "ROL", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", "1", "1", "1", "1", "", "alias for ADC Rd, Rd"}, + {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OPCODE_ror, "ROR", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OPCODE_asr, "ASR", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OPCODE_swap, "SWAP", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", "1", "1", "1", "1", "", ""}, + {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OPCODE_bset, "BSET", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", "1", "1", "1", "1", "", ""}, + {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OPCODE_bclr, "BCLR", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", "1", "1", "1", "1", "", "s = 0-7 = C,Z,N,V,S,H,T,I"}, + {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OPCODE_sbi, "SBI", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", "2", "1", "1", "1", "", ""}, + {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OPCODE_cbi, "CBI", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", "2", "1", "1", "1", "", ""}, + {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OPCODE_bst, "BST", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", "1", "1", "1", "1", "", ""}, + {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OPCODE_bld, "BLD", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", "1", "1", "1", "1", "", ""}, + {0xffff, 0x9408, 1, "1001 0100 0000 1000", OPCODE_sec, "SEC", "-", "Set Carry", "C <-- 1", "C", "1", "1", "1", "1", "", "alias for BSET 0"}, + {0xffff, 0x9488, 1, "1001 0100 1000 1000", OPCODE_clc, "CLC", "-", "Clear Carry", "C <-- 0", "C", "1", "1", "1", "1", "", "alias for BCLR 0"}, + {0xffff, 0x9428, 1, "1001 0100 0010 1000", OPCODE_sen, "SEN", "-", "Set Negative Flag", "N <-- 1", "N", "1", "1", "1", "1", "", "alias for BSET 2"}, + {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OPCODE_cln, "CLN", "-", "Clear Negative Flag", "N <-- 0", "N", "1", "1", "1", "1", "", "alias for BCLR 2"}, + {0xffff, 0x9418, 1, "1001 0100 0001 1000", OPCODE_sez, "SEZ", "-", "Set Zero Flag", "Z <-- 1", "Z", "1", "1", "1", "1", "", "alias for BSET 1"}, + {0xffff, 0x9498, 1, "1001 0100 1001 1000", OPCODE_clz, "CLZ", "-", "Clear Zero Flag", "Z <-- 0", "Z", "1", "1", "1", "1", "", "alias for BCLR 1"}, + {0xffff, 0x9478, 1, "1001 0100 0111 1000", OPCODE_sei, "SEI", "-", "Global Interrupt Enable", "I <-- 1", "I", "1", "1", "1", "1", "", "alias for BSET 7"}, + {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OPCODE_cli, "CLI", "-", "Global Interrupt Disable", "I <-- 0", "I", "1", "1", "1", "1", "", "alias for BCLR 7"}, + {0xffff, 0x9448, 1, "1001 0100 0100 1000", OPCODE_ses, "SES", "-", "Set Signed Test Flag", "S <-- 1", "S", "1", "1", "1", "1", "", "alias for BSET 4"}, + {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OPCODE_cls, "CLS", "-", "Clear Signed Test Flag", "S <-- 0", "S", "1", "1", "1", "1", "", "alias for BCLR 4"}, + {0xffff, 0x9438, 1, "1001 0100 0011 1000", OPCODE_sev, "SEV", "-", "Set Two's Complement Overflow", "V <-- 1", "V", "1", "1", "1", "1", "", "alias for BSET 3"}, + {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OPCODE_clv, "CLV", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", "1", "1", "1", "1", "", "alias for BCLR 3"}, + {0xffff, 0x9468, 1, "1001 0100 0110 1000", OPCODE_set, "SET", "-", "Set T in SREG", "T <-- 1", "T", "1", "1", "1", "1", "", "alias for BSET 6"}, + {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OPCODE_clt, "CLT", "-", "Clear T in SREG", "T <-- 0", "T", "1", "1", "1", "1", "", "alias for BCLR 6"}, + {0xffff, 0x9458, 1, "1001 0100 0101 1000", OPCODE_seh, "SEH", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", "1", "1", "1", "1", "", "alias for BSET 5"}, + {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OPCODE_clh, "CLH", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", "1", "1", "1", "1", "", "alias for BCLR 5"}, + + // MCU Control Instructions + {0xffff, 0x9598, 1, "1001 0101 1001 1000", OPCODE_break, "BREAK", "-", "Break", "(cf documentation)", "None", "-", "-", "-", "-", "(1)", ""}, + {0xffff, 0x0000, 1, "0000 0000 0000 0000", OPCODE_nop, "NOP", "-", "No Operation", "-", "None", "1", "1", "1", "1", "", ""}, + {0xffff, 0x9588, 1, "1001 0101 1000 1000", OPCODE_sleep, "SLEEP", "-", "Sleep", "(cf documentation)", "None", "-", "-", "-", "-", "", ""}, + {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OPCODE_wdr, "WDR", "-", "Watchdog Reset", "(cf documentation)", "None", "1", "1", "1", "1", "", ""}, + + // Unallocated codes + {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OPCODE_x_nop_1, "NOP", "", "", "", "", "", "", "", "", "", "xxxx xxxx != 0000 0000"}, + {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OPCODE_x_nop_2, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OPCODE_x_nop_3, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OPCODE_x_nop_4, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OPCODE_x_nop_5, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OPCODE_x_nop_6, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OPCODE_x_nop_7, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OPCODE_x_icall, "ICALL", "", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OPCODE_x_eicall, "EICALL", "", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OPCODE_x_ret, "RET", "", "", "", "", "", "", "", "", "", "xx != 00"}, + {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OPCODE_x_reti, "RETI", "", "", "", "", "", "", "", "", "", "xx != 00"}, + {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OPCODE_x_nop_8, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OPCODE_x_nop_9, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OPCODE_x_nop_a, "NOP", "", "", "", "", "", "", "", "", "", ""}, + {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OPCODE_x_ijmp, "IJMP", "", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OPCODE_x_eijmp, "EIJMP", "", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xfe08, 0xf808, 1, "1111 100x xxxx 1xxx", OPCODE_x_bld, "BLD", "Rd, b", "", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfa08, 1, "1111 101x xxxx 1xxx", OPCODE_x_bst, "BST", "Rd, b", "", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfc08, 1, "1111 110x xxxx 1xxx", OPCODE_x_sbrc, "SBRC", "Rr, b", "", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfe08, 1, "1111 111x xxxx 1xxx", OPCODE_x_sbrs, "SBRS", "Rr, b", "", "", "", "", "", "", "", "", ""}, +}; diff --git a/src/disasm.c b/src/disasm.c index 885c3b94..42cfd8b1 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -33,6 +33,7 @@ #include #include +#include "avrdude.h" #include "libavrdude.h" #include "disasm_globals.h" @@ -40,7 +41,6 @@ #include "disasm_callbacks_pseudocode.h" #include "disasm_jumpcall.h" #include "disasm_ioregisters.h" -#include "disasm_mnemonics.h" #include "disasm_tagfile.h" void Display_Registers() { @@ -80,25 +80,24 @@ int Compare_Opcode(const char *Bitstream, const char *Bitmask) { return 1; // Match } -void Register_Opcode(void (*Callback)(const char *, int, int), const char *New_Opcode_String, int New_MNemonic) { +void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char *New_Opcode_String, AVR_opcode mnemo) { cx->dis_n_ops++; cx->dis_op[cx->dis_n_ops - 1].Opcode_String = malloc(strlen(New_Opcode_String) + 1); strcpy(cx->dis_op[cx->dis_n_ops - 1].Opcode_String, New_Opcode_String); - cx->dis_op[cx->dis_n_ops - 1].MNemonic = New_MNemonic; + cx->dis_op[cx->dis_n_ops - 1].mnemo = mnemo; cx->dis_op[cx->dis_n_ops - 1].Callback = Callback; } -void Supersede_Opcode(void (*Callback)(const char *, int, int), int New_MNemonic) { +void Supersede_Opcode(void (*Callback)(const char *, int, AVR_opcode), AVR_opcode mnemo) { int i; for(i = 0; i < cx->dis_n_ops; i++) { - if(cx->dis_op[i].MNemonic == New_MNemonic) { - // Supersede callback + if(cx->dis_op[i].mnemo == mnemo) { cx->dis_op[i].Callback = Callback; return; } } - fprintf(stderr, "Error: No callback to supersede opcode %d found (%s).\n", New_MNemonic, MNemonic[New_MNemonic]); + fprintf(stderr, "Error: No callback fund to supersede opcode %d (%s).\n", mnemo, avr_opcodes[mnemo].opcode); } int Get_Bitmask_Length(const char *Bitmask) { @@ -230,7 +229,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) { if(Opcode == -1) { Pos += 2; } else { - cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].MNemonic); + cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].mnemo); Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; } } @@ -258,7 +257,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) { cx->dis_code[0] = 0; cx->dis_comment[0] = 0; cx->dis_after_code[0] = 0; - cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].MNemonic); + cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].mnemo); if(cx->dis_opts.Process_Labels) { Print_JumpCalls(Pos); @@ -266,14 +265,8 @@ void Disassemble(const char *Bitstream, int Read, int addr) { if(cx->dis_opts.Show_Addresses) printf("%4x: ", Pos); - if(cx->dis_opts.Show_Cycles) { - const char *Cycle = Cycles[cx->dis_op[Opcode].MNemonic]; - - if(!Cycle) - printf(" "); - else - printf("[%-3s] ", Cycle); - } + if(cx->dis_opts.Show_Cycles) // @@@ select correct clocks_xx + printf("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clocks_e); if(cx->dis_opts.Show_Opcodes) { // Now display the Opcode @@ -289,7 +282,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) { if(cx->dis_code[0] == 0) { // No code was generated? - printf("; - Not implemented opcode: %d -\n", cx->dis_op[Opcode].MNemonic); + printf("; - Not implemented opcode: %d -\n", cx->dis_op[Opcode].mnemo); } else { if((cx->dis_comment[0] == 0) || (!cx->dis_opts.Show_Comments)) { // No comment @@ -360,6 +353,41 @@ int disasm(const char *Bitstream, int Read, int addr) { if(!Read_Tagfile(cx->dis_opts.Tagfile)) return 0; + /* + * 8 untreated opcodes and 20 "unofficial" ones + * + * OPCODE_des + * OPCODE_xch + * OPCODE_lac + * OPCODE_las + * OPCODE_lat + * + * OPCODE_lds_rc + * OPCODE_spm_zz + * OPCODE_sts_rc + * + * OPCODE_x_bld + * OPCODE_x_bst + * OPCODE_x_eicall + * OPCODE_x_eijmp + * OPCODE_x_icall + * OPCODE_x_ijmp + * OPCODE_x_nop_1 + * OPCODE_x_nop_2 + * OPCODE_x_nop_3 + * OPCODE_x_nop_4 + * OPCODE_x_nop_5 + * OPCODE_x_nop_6 + * OPCODE_x_nop_7 + * OPCODE_x_nop_8 + * OPCODE_x_nop_9 + * OPCODE_x_nop_a + * OPCODE_x_ret + * OPCODE_x_reti + * OPCODE_x_sbrc + * OPCODE_x_sbrs + */ + cx->dis_n_ops = 0; Register_Opcode(adc_Callback, "0001 11rd dddd rrrr", OPCODE_adc); @@ -399,7 +427,6 @@ int disasm(const char *Bitstream, int Read, int addr) { Register_Opcode(clh_Callback, "1001 0100 1101 1000", OPCODE_clh); Register_Opcode(cli_Callback, "1001 0100 1111 1000", OPCODE_cli); Register_Opcode(cln_Callback, "1001 0100 1010 1000", OPCODE_cln); - // Register_Opcode(clr_Callback, "0010 01dd dddd dddd", OPCODE_clr); // Implied by eor Register_Opcode(cls_Callback, "1001 0100 1100 1000", OPCODE_cls); Register_Opcode(clt_Callback, "1001 0100 1110 1000", OPCODE_clt); @@ -441,7 +468,6 @@ int disasm(const char *Bitstream, int Read, int addr) { Register_Opcode(lpm1_Callback, "1001 0101 1100 1000", OPCODE_lpm_1); Register_Opcode(lpm2_Callback, "1001 000d dddd 0100", OPCODE_lpm_2); Register_Opcode(lpm3_Callback, "1001 000d dddd 0101", OPCODE_lpm_3); - // Register_Opcode(lsl_Callback, "0000 11dd dddd dddd", OPCODE_lsl); // Implied by add Register_Opcode(lsr_Callback, "1001 010d dddd 0110", OPCODE_lsr); Register_Opcode(mov_Callback, "0010 11rd dddd rrrr", OPCODE_mov); @@ -460,7 +486,6 @@ int disasm(const char *Bitstream, int Read, int addr) { Register_Opcode(ret_Callback, "1001 0101 0000 1000", OPCODE_ret); Register_Opcode(reti_Callback, "1001 0101 0001 1000", OPCODE_reti); Register_Opcode(rjmp_Callback, "1100 kkkk kkkk kkkk", OPCODE_rjmp); - // Register_Opcode(rol_Callback, "0001 11dd dddd dddd", OPCODE_rol); // Implied by adc Register_Opcode(ror_Callback, "1001 010d dddd 0111", OPCODE_ror); Register_Opcode(sbc_Callback, "0000 10rd dddd rrrr", OPCODE_sbc); @@ -498,7 +523,6 @@ int disasm(const char *Bitstream, int Read, int addr) { Register_Opcode(sub_Callback, "0001 10rd dddd rrrr", OPCODE_sub); Register_Opcode(subi_Callback, "0101 KKKK dddd KKKK", OPCODE_subi); Register_Opcode(swap_Callback, "1001 010d dddd 0010", OPCODE_swap); - // Register_Opcode(tst_Callback, "0010 00dd dddd dddd", OPCODE_tst); // Implied by and Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); @@ -571,6 +595,12 @@ int disasm(const char *Bitstream, int Read, int addr) { qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); + for(size_t i = 0; i < sizeof avr_opcodes/sizeof*avr_opcodes; i++) + if(avr_opcodes[i].mnemo != i) { + msg_error("avr_opcodes[] table broken (this should never happen)\n"); + return -1; + } + Disassemble(Bitstream, Read, addr); return 0; } diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index c190c4dd..b00ef89b 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -30,7 +30,6 @@ #include "libavrdude.h" -#include "disasm_mnemonics.h" #include "disasm_globals.h" #include "disasm_callbacks_assembly.h" #include "disasm_jumpcall.h" @@ -48,54 +47,54 @@ static unsigned BitCount(unsigned n) { return ret; } -void Operation_Simple(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%s", MNemonic[MNemonic_Int]); +void Operation_Simple(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%s", avr_opcodes[mnemo].opcode); } -void Operation_Rd(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); +void Operation_Rd(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd); } -void Operation_Rd16(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); +void Operation_Rd16(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd + 16); } -void Operation_Rd_Rr(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); +void Operation_Rd_Rr(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd, Rr); } -void Operation_Rd16_Rr16(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); +void Operation_Rd16_Rr16(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd + 16, Rr + 16); } -void Operation_Rd16_K(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); +void Operation_Rd16_K(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 16, RK); snprintf(cx->dis_comment, 255, "%d", RK); } -void Operation_Rd_K(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); +void Operation_Rd_K(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); snprintf(cx->dis_comment, 255, "%d", RK); } -void Operation_RdW_K(int MNemonic_Int) { +void Operation_RdW_K(AVR_opcode mnemo) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 1, Rd, RK); } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); } snprintf(cx->dis_comment, 255, "%d", RK); } -void Operation_RdW_RrW(int MNemonic_Int) { +void Operation_RdW_RrW(AVR_opcode mnemo) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", avr_opcodes[mnemo].opcode, (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); } else { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, 2 * Rd, 2 * Rr); } } -void Operation_s_k(int MNemonic_Int, int Position) { +void Operation_s_k(AVR_opcode mnemo, int Position) { int Bits, Offset; int Target; @@ -105,39 +104,39 @@ void Operation_s_k(int MNemonic_Int, int Position) { Offset -= 256; Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); + Register_JumpCall(Position, Target, mnemo, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); + snprintf(cx->dis_code, 255, "%-7s %d, .+%d", avr_opcodes[mnemo].opcode, Bits, Offset); } else { - snprintf(cx->dis_code, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); + snprintf(cx->dis_code, 255, "%-7s %d, .%d", avr_opcodes[mnemo].opcode, Bits, Offset); } snprintf(cx->dis_comment, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); } else { - snprintf(cx->dis_code, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); + snprintf(cx->dis_code, 255, "%-7s %d, %s", avr_opcodes[mnemo].opcode, Bits, Get_Label_Name(Target, NULL)); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); } } -void Operation_r_b(int MNemonic_Int) { +void Operation_r_b(AVR_opcode mnemo) { int Register, Bit; Register = Rr; Bit = Rb; - snprintf(cx->dis_code, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_code, 255, "%-7s r%d, %d", avr_opcodes[mnemo].opcode, Register, Bit); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void Operation_Rd_b(int MNemonic_Int) { +void Operation_Rd_b(AVR_opcode mnemo) { int Register, Bit; Register = Rd; Bit = Rb; - snprintf(cx->dis_code, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_code, 255, "%-7s r%d, %d", avr_opcodes[mnemo].opcode, Register, Bit); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void Operation_A_b(int MNemonic_Int) { +void Operation_A_b(AVR_opcode mnemo) { int Register, Bit; const char *Register_Name; @@ -145,23 +144,23 @@ void Operation_A_b(int MNemonic_Int) { Bit = Rb; Register_Name = Resolve_IO_Register(Register); if(Register_Name == NULL) { - snprintf(cx->dis_code, 255, "%-7s 0x%02x, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_code, 255, "%-7s 0x%02x, %d", avr_opcodes[mnemo].opcode, Register, Bit); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } else { - snprintf(cx->dis_code, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); + snprintf(cx->dis_code, 255, "%-7s %s, %d", avr_opcodes[mnemo].opcode, Register_Name, Bit); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } } -void Operation_s(int MNemonic_Int) { +void Operation_s(AVR_opcode mnemo) { int Bit; Bit = Rs; - snprintf(cx->dis_code, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); + snprintf(cx->dis_code, 255, "%-7s %d", avr_opcodes[mnemo].opcode, Bit); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void Operation_k(int MNemonic_Int, int Position, const char *Pseudocode) { +void Operation_k(AVR_opcode mnemo, int Position, const char *Pseudocode) { int Offset; int Target; @@ -170,16 +169,16 @@ void Operation_k(int MNemonic_Int, int Position, const char *Pseudocode) { Offset -= 256; Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); + Register_JumpCall(Position, Target, mnemo, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .+%d", avr_opcodes[mnemo].opcode, Offset); } else { - snprintf(cx->dis_code, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .%d", avr_opcodes[mnemo].opcode, Offset); } snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { - snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); + snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, Get_Label_Name(Target, NULL)); } } @@ -189,7 +188,7 @@ CALLBACK(adc_Callback) { if(Rd == Rr) { Operation_Rd(OPCODE_rol); } else { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } } @@ -197,15 +196,15 @@ CALLBACK(add_Callback) { if(Rd == Rr) { Operation_Rd(OPCODE_lsl); } else { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } } CALLBACK(adiw_Callback) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, 2 * Rd + 25, 2 * Rd + 24, RK); } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, 2 * Rd + 24, RK); } snprintf(cx->dis_comment, 255, "%d", RK); } @@ -214,13 +213,13 @@ CALLBACK(and_Callback) { if(Rd == Rr) { Operation_Rd(OPCODE_tst); } else { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } } CALLBACK(andi_Callback) { if(BitCount(RK) < 4) { - Operation_Rd16_K(MNemonic_Int); + Operation_Rd16_K(mnemo); } else { RK = ~RK; RK &= 0xff; @@ -229,233 +228,233 @@ CALLBACK(andi_Callback) { } CALLBACK(asr_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(bclr_Callback) { - Operation_s(MNemonic_Int); + Operation_s(mnemo); } CALLBACK(bld_Callback) { - Operation_Rd_b(MNemonic_Int); + Operation_Rd_b(mnemo); } CALLBACK(brbc_Callback) { - Operation_s_k(MNemonic_Int, Position); + Operation_s_k(mnemo, Position); } CALLBACK(brbs_Callback) { - Operation_s_k(MNemonic_Int, Position); + Operation_s_k(mnemo, Position); } CALLBACK(brcc_Callback) { - Operation_k(MNemonic_Int, Position, "Carry == 0"); + Operation_k(mnemo, Position, "Carry == 0"); } CALLBACK(brcs_Callback) { - Operation_k(MNemonic_Int, Position, "Carry == 1"); + Operation_k(mnemo, Position, "Carry == 1"); } CALLBACK(break_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(breq_Callback) { - Operation_k(MNemonic_Int, Position, "c1 == c2"); + Operation_k(mnemo, Position, "c1 == c2"); } CALLBACK(brge_Callback) { - Operation_k(MNemonic_Int, Position, "c1 (signed)>= c2"); + Operation_k(mnemo, Position, "c1 (signed)>= c2"); } CALLBACK(brhc_Callback) { - Operation_k(MNemonic_Int, Position, "HalfCarry == 0"); + Operation_k(mnemo, Position, "HalfCarry == 0"); } CALLBACK(brhs_Callback) { - Operation_k(MNemonic_Int, Position, "HalfCarry == 1"); + Operation_k(mnemo, Position, "HalfCarry == 1"); } CALLBACK(brid_Callback) { - Operation_k(MNemonic_Int, Position, "Global_Interrupts_Disabled()"); + Operation_k(mnemo, Position, "Global_Interrupts_Disabled()"); } CALLBACK(brie_Callback) { - Operation_k(MNemonic_Int, Position, "Global_Interrupts_Enabled()"); + Operation_k(mnemo, Position, "Global_Interrupts_Enabled()"); } CALLBACK(brlo_Callback) { - Operation_k(MNemonic_Int, Position, "c1 (unsigned)< c2"); + Operation_k(mnemo, Position, "c1 (unsigned)< c2"); } CALLBACK(brlt_Callback) { - Operation_k(MNemonic_Int, Position, "c1 (signed)< c2"); + Operation_k(mnemo, Position, "c1 (signed)< c2"); } CALLBACK(brmi_Callback) { - Operation_k(MNemonic_Int, Position, "< 0"); + Operation_k(mnemo, Position, "< 0"); } CALLBACK(brne_Callback) { - Operation_k(MNemonic_Int, Position, "c1 != c2"); + Operation_k(mnemo, Position, "c1 != c2"); } CALLBACK(brpl_Callback) { - Operation_k(MNemonic_Int, Position, "> 0"); + Operation_k(mnemo, Position, "> 0"); } CALLBACK(brsh_Callback) { - Operation_k(MNemonic_Int, Position, "c1 (unsigned)>= c2"); + Operation_k(mnemo, Position, "c1 (unsigned)>= c2"); } CALLBACK(brtc_Callback) { - Operation_k(MNemonic_Int, Position, "T == 0"); + Operation_k(mnemo, Position, "T == 0"); } CALLBACK(brts_Callback) { - Operation_k(MNemonic_Int, Position, "T == 1"); + Operation_k(mnemo, Position, "T == 1"); } CALLBACK(brvc_Callback) { - Operation_k(MNemonic_Int, Position, "Overflow == 0"); + Operation_k(mnemo, Position, "Overflow == 0"); } CALLBACK(brvs_Callback) { - Operation_k(MNemonic_Int, Position, "Overflow == 1"); + Operation_k(mnemo, Position, "Overflow == 1"); } CALLBACK(bset_Callback) { - Operation_s(MNemonic_Int); + Operation_s(mnemo); } CALLBACK(bst_Callback) { - Operation_Rd_b(MNemonic_Int); + Operation_Rd_b(mnemo); } CALLBACK(call_Callback) { int Pos; Pos = FixTargetAddress(2 * Rk); - Register_JumpCall(Position, Pos, MNemonic_Int, 1); + Register_JumpCall(Position, Pos, mnemo, 1); if(!cx->dis_opts.Process_Labels) { - snprintf(cx->dis_code, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); + snprintf(cx->dis_code, 255, "%-7s 0x%02x", avr_opcodes[mnemo].opcode, Pos); } else { char *LabelName; char *LabelComment = NULL; LabelName = Get_Label_Name(Pos, &LabelComment); - snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); + snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, LabelName); if(LabelComment != NULL) snprintf(cx->dis_comment, 255, "%s", LabelComment); } } CALLBACK(cbi_Callback) { - Operation_A_b(MNemonic_Int); + Operation_A_b(mnemo); } CALLBACK(clc_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(clh_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(cli_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(cln_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(cls_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(clt_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(clv_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(clz_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(com_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(cp_Callback) { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } CALLBACK(cpc_Callback) { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } CALLBACK(cpi_Callback) { - Operation_Rd16_K(MNemonic_Int); + Operation_Rd16_K(mnemo); } CALLBACK(cpse_Callback) { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } CALLBACK(dec_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(eicall_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(eijmp_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(elpm1_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(elpm2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(elpm3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z+", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(eor_Callback) { if(Rd == Rr) { Operation_Rd(OPCODE_clr); } else { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } } CALLBACK(fmul_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); + Operation_Rd16_Rr16(mnemo); } CALLBACK(fmuls_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); + Operation_Rd16_Rr16(mnemo); } CALLBACK(fmulsu_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); + Operation_Rd16_Rr16(mnemo); } CALLBACK(icall_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(ijmp_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(in_Callback) { @@ -465,15 +464,15 @@ CALLBACK(in_Callback) { Register_Number = RA; Register_Name = Resolve_IO_Register(Register_Number); if(Register_Name != NULL) { - snprintf(cx->dis_code, 255, "%-7s r%d, %s", MNemonic[MNemonic_Int], Rd, Register_Name); + snprintf(cx->dis_code, 255, "%-7s r%d, %s", avr_opcodes[mnemo].opcode, Rd, Register_Name); } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, Register_Number); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, Register_Number); snprintf(cx->dis_comment, 255, "%d", RA); } } CALLBACK(inc_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(jmp_Callback) { @@ -481,122 +480,122 @@ CALLBACK(jmp_Callback) { Pos = FixTargetAddress(2 * Rk); if(!cx->dis_opts.Process_Labels) { - snprintf(cx->dis_code, 255, "%-7s 0x%02x", MNemonic[MNemonic_Int], Pos); + snprintf(cx->dis_code, 255, "%-7s 0x%02x", avr_opcodes[mnemo].opcode, Pos); } else { - snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Pos, NULL)); + snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, Get_Label_Name(Pos, NULL)); } - Register_JumpCall(Position, Pos, MNemonic_Int, 0); + Register_JumpCall(Position, Pos, mnemo, 0); } CALLBACK(ld1_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, X", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, X", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ld2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, X+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, X+", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ld3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, -X", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, -X", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ldy1_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Y", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Y", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ldy2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Y+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Y+", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ldy3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, -Y", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, -Y", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ldy4_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Y+%d", MNemonic[MNemonic_Int], Rd, Rq); + snprintf(cx->dis_code, 255, "%-7s r%d, Y+%d", avr_opcodes[mnemo].opcode, Rd, Rq); } CALLBACK(ldz1_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ldz2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z+", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ldz3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, -Z", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, -Z", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(ldz4_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z+%d", MNemonic[MNemonic_Int], Rd, Rq); + snprintf(cx->dis_code, 255, "%-7s r%d, Z+%d", avr_opcodes[mnemo].opcode, Rd, Rq); } CALLBACK(ldi_Callback) { - Operation_Rd16_K(MNemonic_Int); + Operation_Rd16_K(mnemo); } CALLBACK(lds_Callback) { const char *MemAddress; - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%04x", MNemonic[MNemonic_Int], Rd, Rk); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%04x", avr_opcodes[mnemo].opcode, Rd, Rk); MemAddress = Tagfile_Resolve_Mem_Address(Rk); - snprintf(cx->dis_code, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); + snprintf(cx->dis_code, 255, "%-7s 0x%04x, r%d", avr_opcodes[mnemo].opcode, Rk, Rd); if(MemAddress) { snprintf(cx->dis_comment, 255, "%s", MemAddress); } } CALLBACK(lpm1_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(lpm2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(lpm3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z+", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d, Z+", avr_opcodes[mnemo].opcode, Rd); } CALLBACK(lsr_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(mov_Callback) { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } CALLBACK(movw_Callback) { - Operation_RdW_RrW(MNemonic_Int); + Operation_RdW_RrW(mnemo); } CALLBACK(mul_Callback) { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } CALLBACK(muls_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); + Operation_Rd16_Rr16(mnemo); } CALLBACK(mulsu_Callback) { - Operation_Rd16_Rr16(MNemonic_Int); + Operation_Rd16_Rr16(mnemo); } CALLBACK(neg_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(nop_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(or_Callback) { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } CALLBACK(ori_Callback) { - Operation_Rd16_K(MNemonic_Int); + Operation_Rd16_K(mnemo); } CALLBACK(out_Callback) { @@ -606,19 +605,19 @@ CALLBACK(out_Callback) { Register_Number = RA; Register_Name = Resolve_IO_Register(Register_Number); if(Register_Name != NULL) { - snprintf(cx->dis_code, 255, "%-7s %s, r%d", MNemonic[MNemonic_Int], Register_Name, Rr); + snprintf(cx->dis_code, 255, "%-7s %s, r%d", avr_opcodes[mnemo].opcode, Register_Name, Rr); } else { - snprintf(cx->dis_code, 255, "%-7s 0x%02x, r%d", MNemonic[MNemonic_Int], Register_Number, Rr); + snprintf(cx->dis_code, 255, "%-7s 0x%02x, r%d", avr_opcodes[mnemo].opcode, Register_Number, Rr); snprintf(cx->dis_comment, 255, "%d", RA); } } CALLBACK(pop_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(push_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(rcall_Callback) { @@ -630,12 +629,12 @@ CALLBACK(rcall_Callback) { Offset -= 8192; Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 1); + Register_JumpCall(Position, Target, mnemo, 1); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .+%d", avr_opcodes[mnemo].opcode, Offset); } else { - snprintf(cx->dis_code, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .%d", avr_opcodes[mnemo].opcode, Offset); } snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { @@ -643,19 +642,19 @@ CALLBACK(rcall_Callback) { char *LabelComment = NULL; LabelName = Get_Label_Name(Target, &LabelComment); - snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], LabelName); + snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, LabelName); if(LabelComment != NULL) snprintf(cx->dis_comment, 255, "%s", LabelComment); } } CALLBACK(ret_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); snprintf(cx->dis_after_code, 255, "\n"); } CALLBACK(reti_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(rjmp_Callback) { @@ -667,13 +666,13 @@ CALLBACK(rjmp_Callback) { Offset -= 8192; Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); + Register_JumpCall(Position, Target, mnemo, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s .+%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .+%d", avr_opcodes[mnemo].opcode, Offset); } else { - snprintf(cx->dis_code, 255, "%-7s .%d", MNemonic[MNemonic_Int], Offset); + snprintf(cx->dis_code, 255, "%-7s .%d", avr_opcodes[mnemo].opcode, Offset); } if(Target >= 0) { snprintf(cx->dis_comment, 255, "0x%02x", Target); @@ -681,141 +680,141 @@ CALLBACK(rjmp_Callback) { snprintf(cx->dis_comment, 255, "-0x%02x - Illegal jump position -- specify flash size!", -Target); } } else { - snprintf(cx->dis_code, 255, "%-7s %s", MNemonic[MNemonic_Int], Get_Label_Name(Target, NULL)); + snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, Get_Label_Name(Target, NULL)); } } CALLBACK(ror_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(sbc_Callback) { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } CALLBACK(sbci_Callback) { - Operation_Rd16_K(MNemonic_Int); + Operation_Rd16_K(mnemo); } CALLBACK(sbi_Callback) { - Operation_A_b(MNemonic_Int); + Operation_A_b(mnemo); } CALLBACK(sbic_Callback) { - Operation_A_b(MNemonic_Int); + Operation_A_b(mnemo); } CALLBACK(sbis_Callback) { - Operation_A_b(MNemonic_Int); + Operation_A_b(mnemo); } CALLBACK(sbiw_Callback) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 25, 2 * Rd + 24, RK); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, 2 * Rd + 25, 2 * Rd + 24, RK); } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], 2 * Rd + 24, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, 2 * Rd + 24, RK); } snprintf(cx->dis_comment, 255, "%d", RK); } CALLBACK(sbr_Callback) { - Operation_Rd16_K(MNemonic_Int); + Operation_Rd16_K(mnemo); } CALLBACK(sbrc_Callback) { - Operation_r_b(MNemonic_Int); + Operation_r_b(mnemo); } CALLBACK(sbrs_Callback) { - Operation_r_b(MNemonic_Int); + Operation_r_b(mnemo); } CALLBACK(sec_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(seh_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(sei_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(sen_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(ser_Callback) { - Operation_Rd16(MNemonic_Int); + Operation_Rd16(mnemo); } CALLBACK(ses_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(set_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(sev_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(sez_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(sleep_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(spm_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } CALLBACK(st1_Callback) { - snprintf(cx->dis_code, 255, "%-7s X, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s X, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(st2_Callback) { - snprintf(cx->dis_code, 255, "%-7s X+, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s X+, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(st3_Callback) { - snprintf(cx->dis_code, 255, "%-7s -X, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s -X, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(sty1_Callback) { - snprintf(cx->dis_code, 255, "%-7s Y, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s Y, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(sty2_Callback) { - snprintf(cx->dis_code, 255, "%-7s Y+, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s Y+, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(sty3_Callback) { - snprintf(cx->dis_code, 255, "%-7s -Y, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s -Y, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(sty4_Callback) { - snprintf(cx->dis_code, 255, "%-7s Y+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); + snprintf(cx->dis_code, 255, "%-7s Y+%d, r%d", avr_opcodes[mnemo].opcode, Rq, Rr); } CALLBACK(stz1_Callback) { - snprintf(cx->dis_code, 255, "%-7s Z, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s Z, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(stz2_Callback) { - snprintf(cx->dis_code, 255, "%-7s Z+, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s Z+, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(stz3_Callback) { - snprintf(cx->dis_code, 255, "%-7s -Z, r%d", MNemonic[MNemonic_Int], Rr); + snprintf(cx->dis_code, 255, "%-7s -Z, r%d", avr_opcodes[mnemo].opcode, Rr); } CALLBACK(stz4_Callback) { - snprintf(cx->dis_code, 255, "%-7s Z+%d, r%d", MNemonic[MNemonic_Int], Rq, Rr); + snprintf(cx->dis_code, 255, "%-7s Z+%d, r%d", avr_opcodes[mnemo].opcode, Rq, Rr); } CALLBACK(sts_Callback) { @@ -823,24 +822,24 @@ CALLBACK(sts_Callback) { const char *MemAddress; MemAddress = Tagfile_Resolve_Mem_Address(Rk); - snprintf(cx->dis_code, 255, "%-7s 0x%04x, r%d", MNemonic[MNemonic_Int], Rk, Rd); + snprintf(cx->dis_code, 255, "%-7s 0x%04x, r%d", avr_opcodes[mnemo].opcode, Rk, Rd); if(MemAddress) { snprintf(cx->dis_comment, 255, "%s", MemAddress); } } CALLBACK(sub_Callback) { - Operation_Rd_Rr(MNemonic_Int); + Operation_Rd_Rr(mnemo); } CALLBACK(subi_Callback) { - Operation_Rd16_K(MNemonic_Int); + Operation_Rd16_K(mnemo); } CALLBACK(swap_Callback) { - Operation_Rd(MNemonic_Int); + Operation_Rd(mnemo); } CALLBACK(wdr_Callback) { - Operation_Simple(MNemonic_Int); + Operation_Simple(mnemo); } diff --git a/src/disasm_callbacks_assembly.h b/src/disasm_callbacks_assembly.h index b97206d7..a9923f33 100644 --- a/src/disasm_callbacks_assembly.h +++ b/src/disasm_callbacks_assembly.h @@ -25,149 +25,149 @@ JohannesBauer@gmx.de */ -void Operation_Simple(int MNemonic_Int); -void Operation_Rd(int MNemonic_Int); -void Operation_Rd16(int MNemonic_Int); -void Operation_Rd_Rr(int MNemonic_Int); -void Operation_Rd16_Rr16(int MNemonic_Int); -void Operation_Rd16_K(int MNemonic_Int); -void Operation_Rd_K(int MNemonic_Int); -void Operation_RdW_K(int MNemonic_Int); -void Operation_RdW_RrW(int MNemonic_Int); -void Operation_s_k(int MNemonic_Int, int Position); -void Operation_r_b(int MNemonic_Int); -void Operation_Rd_b(int MNemonic_Int); -void Operation_A_b(int MNemonic_Int); -void Operation_s(int MNemonic_Int); -void Operation_k(int MNemonic_Int, int Position, const char *Pseudocode); -void adc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void add_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void adiw_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void and_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void andi_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void asr_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void bclr_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void bld_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brbc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brbs_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brcc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brcs_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void break_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void breq_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brge_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brhc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brhs_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brid_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brie_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brlo_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brlt_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brmi_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brne_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brpl_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brsh_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brtc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brts_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brvc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void brvs_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void bset_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void bst_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void call_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void cbi_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void clc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void clh_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void cli_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void cln_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void cls_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void clt_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void clv_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void clz_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void com_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void cp_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void cpc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void cpi_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void cpse_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void dec_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void eicall_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void eijmp_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void elpm1_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void elpm2_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void elpm3_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void eor_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void fmul_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void fmuls_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void fmulsu_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void icall_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ijmp_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void in_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void inc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void jmp_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ld1_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ld2_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ld3_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldy1_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldy2_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldy3_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldy4_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldz1_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldz2_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldz3_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldz4_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ldi_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void lds_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void lpm1_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void lpm2_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void lpm3_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void lsr_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void mov_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void movw_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void mul_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void muls_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void mulsu_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void neg_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void nop_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void or_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ori_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void out_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void pop_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void push_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void rcall_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ret_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void reti_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void rjmp_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ror_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbci_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbi_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbic_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbis_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbiw_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbr_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbrc_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sbrs_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sec_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void seh_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sei_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sen_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ser_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void ses_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void set_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sev_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sez_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sleep_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void spm_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void st1_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void st2_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void st3_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sty1_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sty2_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sty3_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sty4_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void stz1_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void stz2_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void stz3_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void stz4_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sts_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void sub_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void subi_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void swap_Callback(const char *Bitstream, int Position, int MNemonic_Int); -void wdr_Callback(const char *Bitstream, int Position, int MNemonic_Int); +void Operation_Simple(AVR_opcode mnemo); +void Operation_Rd(AVR_opcode mnemo); +void Operation_Rd16(AVR_opcode mnemo); +void Operation_Rd_Rr(AVR_opcode mnemo); +void Operation_Rd16_Rr16(AVR_opcode mnemo); +void Operation_Rd16_K(AVR_opcode mnemo); +void Operation_Rd_K(AVR_opcode mnemo); +void Operation_RdW_K(AVR_opcode mnemo); +void Operation_RdW_RrW(AVR_opcode mnemo); +void Operation_s_k(AVR_opcode mnemo, int Position); +void Operation_r_b(AVR_opcode mnemo); +void Operation_Rd_b(AVR_opcode mnemo); +void Operation_A_b(AVR_opcode mnemo); +void Operation_s(AVR_opcode mnemo); +void Operation_k(AVR_opcode mnemo, int Position, const char *Pseudocode); +void adc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void add_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void adiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void and_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void andi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void asr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void bclr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void bld_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brbc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brbs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brcc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brcs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void break_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void breq_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brge_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brhc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brhs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brid_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brie_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brlo_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brlt_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brmi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brne_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brpl_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brsh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brtc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brvc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brvs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void bset_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void bst_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void call_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cli_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cln_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clt_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clv_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clz_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void com_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpse_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void dec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void eicall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void eijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void elpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void elpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void elpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void eor_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void fmul_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void fmuls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void fmulsu_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void icall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void in_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void inc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void jmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ld1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ld2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ld3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldy1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldy2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldy3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldy4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldz1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lds_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lsr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void mov_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void movw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void mul_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void muls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void mulsu_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void neg_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void nop_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void or_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ori_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void out_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void pop_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void push_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void rcall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ret_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void reti_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void rjmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ror_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbci_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbic_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbis_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbrc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbrs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void seh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sei_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sen_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ser_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ses_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void set_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sev_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sez_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sleep_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void spm_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void st1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void st2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void st3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sty1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sty2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sty3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sty4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stz1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sub_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void subi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void swap_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void wdr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); diff --git a/src/disasm_callbacks_pseudocode.c b/src/disasm_callbacks_pseudocode.c index fa420871..a7842113 100644 --- a/src/disasm_callbacks_pseudocode.c +++ b/src/disasm_callbacks_pseudocode.c @@ -30,19 +30,18 @@ #include "libavrdude.h" -#include "disasm_mnemonics.h" #include "disasm_globals.h" #include "disasm_callbacks_pseudocode.h" #include "disasm_jumpcall.h" #include "disasm_ioregisters.h" #include "disasm_tagfile.h" -void PC_Operation_Simple(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%s", MNemonic[MNemonic_Int]); +void PC_Operation_Simple(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%s", avr_opcodes[mnemo].opcode); } -void PC_Operation_Rd(int MNemonic_Int) { - switch (MNemonic_Int) { +void PC_Operation_Rd(AVR_opcode mnemo) { + switch (mnemo) { case OPCODE_lsl: snprintf(cx->dis_code, 255, "r%d <<= 1;", Rd); snprintf(cx->dis_comment, 255, "_BV(0) = 0 (logical shift)"); @@ -72,16 +71,16 @@ void PC_Operation_Rd(int MNemonic_Int) { snprintf(cx->dis_comment, 255, "0"); break; default: - snprintf(cx->dis_code, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd); + snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd); } } -void PC_Operation_Rd16(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d", MNemonic[MNemonic_Int], Rd + 16); +void PC_Operation_Rd16(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd + 16); } -void PC_Operation_Rd_Rr(int MNemonic_Int) { - switch (MNemonic_Int) { +void PC_Operation_Rd_Rr(AVR_opcode mnemo) { + switch (mnemo) { case OPCODE_add: if(Rd != Rr) { snprintf(cx->dis_code, 255, "r%d += r%d;", Rd, Rr); @@ -134,16 +133,16 @@ void PC_Operation_Rd_Rr(int MNemonic_Int) { snprintf(cx->dis_code, 255, "skipif (r%d == r%d)", Rd, Rr); break; default: - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd, Rr); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd, Rr); } } -void PC_Operation_Rd16_Rr16(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], Rd + 16, Rr + 16); +void PC_Operation_Rd16_Rr16(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd + 16, Rr + 16); } -void PC_Operation_Rd16_K(int MNemonic_Int) { - switch (MNemonic_Int) { +void PC_Operation_Rd16_K(AVR_opcode mnemo) { + switch (mnemo) { case OPCODE_andi: snprintf(cx->dis_code, 255, "r%d &= %d;", Rd + 16, RK); snprintf(cx->dis_comment, 255, "0x%02x", RK); @@ -162,34 +161,34 @@ void PC_Operation_Rd16_K(int MNemonic_Int) { snprintf(cx->dis_comment, 255, "0x%02x", RK); break; default: - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 16, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 16, RK); snprintf(cx->dis_comment, 255, "%d", RK); } } -void PC_Operation_Rd_K(int MNemonic_Int) { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); +void PC_Operation_Rd_K(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); snprintf(cx->dis_comment, 255, "%d", RK); } -void PC_Operation_RdW_K(int MNemonic_Int) { +void PC_Operation_RdW_K(AVR_opcode mnemo) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", MNemonic[MNemonic_Int], Rd + 1, Rd, RK); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 1, Rd, RK); } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", MNemonic[MNemonic_Int], Rd, RK); + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); } snprintf(cx->dis_comment, 255, "%d", RK); } -void PC_Operation_RdW_RrW(int MNemonic_Int) { +void PC_Operation_RdW_RrW(AVR_opcode mnemo) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", MNemonic[MNemonic_Int], (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); + snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", avr_opcodes[mnemo].opcode, (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); } else { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", MNemonic[MNemonic_Int], 2 * Rd, 2 * Rr); + snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, 2 * Rd, 2 * Rr); } } -void PC_Operation_s_k(int MNemonic_Int, int Position) { +void PC_Operation_s_k(AVR_opcode mnemo, int Position) { int Bits, Offset; Bits = Rs; @@ -199,39 +198,39 @@ void PC_Operation_s_k(int MNemonic_Int, int Position) { int Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); + Register_JumpCall(Position, Target, mnemo, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s %d, .+%d", MNemonic[MNemonic_Int], Bits, Offset); + snprintf(cx->dis_code, 255, "%-7s %d, .+%d", avr_opcodes[mnemo].opcode, Bits, Offset); } else { - snprintf(cx->dis_code, 255, "%-7s %d, .%d", MNemonic[MNemonic_Int], Bits, Offset); + snprintf(cx->dis_code, 255, "%-7s %d, .%d", avr_opcodes[mnemo].opcode, Bits, Offset); } snprintf(cx->dis_comment, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); } else { - snprintf(cx->dis_code, 255, "%-7s %d, %s", MNemonic[MNemonic_Int], Bits, Get_Label_Name(Target, NULL)); + snprintf(cx->dis_code, 255, "%-7s %d, %s", avr_opcodes[mnemo].opcode, Bits, Get_Label_Name(Target, NULL)); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); } } -void PC_Operation_r_b(int MNemonic_Int) { +void PC_Operation_r_b(AVR_opcode mnemo) { int Register, Bit; Register = Rr; Bit = Rb; - snprintf(cx->dis_code, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_code, 255, "%-7s r%d, %d", avr_opcodes[mnemo].opcode, Register, Bit); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void PC_Operation_Rd_b(int MNemonic_Int) { +void PC_Operation_Rd_b(AVR_opcode mnemo) { int Register, Bit; Register = Rd; Bit = Rb; - snprintf(cx->dis_code, 255, "%-7s r%d, %d", MNemonic[MNemonic_Int], Register, Bit); + snprintf(cx->dis_code, 255, "%-7s r%d, %d", avr_opcodes[mnemo].opcode, Register, Bit); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void PC_Operation_A_b(int MNemonic_Int) { +void PC_Operation_A_b(AVR_opcode mnemo) { int Register, Bit; const char *Register_Name; char Register_Value[5]; @@ -243,7 +242,7 @@ void PC_Operation_A_b(int MNemonic_Int) { snprintf(Register_Value, sizeof(Register_Value), "0x%02x", Register); Register_Name = Register_Value; } - switch (MNemonic_Int) { + switch (mnemo) { case OPCODE_cbi: snprintf(cx->dis_code, 255, "IO[%s] &= ~(_BV(%d));", Register_Name, Bit); break; @@ -257,20 +256,20 @@ void PC_Operation_A_b(int MNemonic_Int) { snprintf(cx->dis_code, 255, "skipif (!(IO[%s] & _BV(%d)))", Register_Name, Bit); break; default: - snprintf(cx->dis_code, 255, "%-7s %s, %d", MNemonic[MNemonic_Int], Register_Name, Bit); + snprintf(cx->dis_code, 255, "%-7s %s, %d", avr_opcodes[mnemo].opcode, Register_Name, Bit); } snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void PC_Operation_s(int MNemonic_Int) { +void PC_Operation_s(AVR_opcode mnemo) { int Bit; Bit = Rs; - snprintf(cx->dis_code, 255, "%-7s %d", MNemonic[MNemonic_Int], Bit); + snprintf(cx->dis_code, 255, "%-7s %d", avr_opcodes[mnemo].opcode, Bit); snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { +void PC_Operation_k(AVR_opcode mnemo, int Position, char *Pseudocode) { int Offset; Offset = (2 * Rk); @@ -279,7 +278,7 @@ void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { int Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); + Register_JumpCall(Position, Target, mnemo, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(cx->dis_code, 255, "if (%s) goto .+%d;", Pseudocode, Offset); @@ -295,95 +294,95 @@ void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode) { /************* Now to the callback functions *************/ CALLBACK(adc_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(add_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(sub_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(sbc_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(mov_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(brcc_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "!Carry"); + PC_Operation_k(mnemo, Position, "!Carry"); } CALLBACK(brcs_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Carry"); + PC_Operation_k(mnemo, Position, "Carry"); } CALLBACK(breq_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 == c2"); + PC_Operation_k(mnemo, Position, "c1 == c2"); } CALLBACK(brge_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 (signed)>= c2"); + PC_Operation_k(mnemo, Position, "c1 (signed)>= c2"); } CALLBACK(brhc_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "!HalfCarry"); + PC_Operation_k(mnemo, Position, "!HalfCarry"); } CALLBACK(brhs_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "HalfCarry"); + PC_Operation_k(mnemo, Position, "HalfCarry"); } CALLBACK(brid_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Global_Interrupts_Disabled()"); + PC_Operation_k(mnemo, Position, "Global_Interrupts_Disabled()"); } CALLBACK(brie_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Global_Interrupts_Enabled()"); + PC_Operation_k(mnemo, Position, "Global_Interrupts_Enabled()"); } CALLBACK(brlo_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 (unsigned)< c2"); + PC_Operation_k(mnemo, Position, "c1 (unsigned)< c2"); } CALLBACK(brlt_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 (signed)< c2"); + PC_Operation_k(mnemo, Position, "c1 (signed)< c2"); } CALLBACK(brmi_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "< 0"); + PC_Operation_k(mnemo, Position, "< 0"); } CALLBACK(brne_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 != c2"); + PC_Operation_k(mnemo, Position, "c1 != c2"); } CALLBACK(brpl_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "> 0"); + PC_Operation_k(mnemo, Position, "> 0"); } CALLBACK(brsh_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "c1 (unsigned)>= c2"); + PC_Operation_k(mnemo, Position, "c1 (unsigned)>= c2"); } CALLBACK(brtc_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "T == 0"); + PC_Operation_k(mnemo, Position, "T == 0"); } CALLBACK(brts_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "T == 1"); + PC_Operation_k(mnemo, Position, "T == 1"); } CALLBACK(brvc_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Overflow == 0"); + PC_Operation_k(mnemo, Position, "Overflow == 0"); } CALLBACK(brvs_Callback_PC) { - PC_Operation_k(MNemonic_Int, Position, "Overflow == 1"); + PC_Operation_k(mnemo, Position, "Overflow == 1"); } CALLBACK(out_Callback_PC) { @@ -433,23 +432,23 @@ CALLBACK(reti_Callback_PC) { } CALLBACK(andi_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); + PC_Operation_Rd16_K(mnemo); } CALLBACK(subi_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); + PC_Operation_Rd16_K(mnemo); } CALLBACK(sbci_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); + PC_Operation_Rd16_K(mnemo); } CALLBACK(sbr_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); + PC_Operation_Rd16_K(mnemo); } CALLBACK(ori_Callback_PC) { - PC_Operation_Rd16_K(MNemonic_Int); + PC_Operation_Rd16_K(mnemo); } CALLBACK(ldi_Callback_PC) { @@ -487,7 +486,7 @@ CALLBACK(call_Callback_PC) { int Pos; Pos = FixTargetAddress(2 * Rk); - Register_JumpCall(Position, Pos, MNemonic_Int, 1); + Register_JumpCall(Position, Pos, mnemo, 1); if(cx->dis_opts.Process_Labels == 0) { snprintf(cx->dis_code, 255, "0x%02x();", Pos); } else { @@ -511,7 +510,7 @@ CALLBACK(rcall_Callback_PC) { int Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 1); + Register_JumpCall(Position, Target, mnemo, 1); if(!cx->dis_opts.Process_Labels) { snprintf(cx->dis_comment, 255, "0x%02x();", Target); } else { @@ -527,22 +526,22 @@ CALLBACK(rcall_Callback_PC) { } CALLBACK(ror_Callback_PC) { - PC_Operation_Rd(MNemonic_Int); + PC_Operation_Rd(mnemo); } CALLBACK(lsr_Callback_PC) { - PC_Operation_Rd(MNemonic_Int); + PC_Operation_Rd(mnemo); } CALLBACK(swap_Callback_PC) { - PC_Operation_Rd(MNemonic_Int); + PC_Operation_Rd(mnemo); } CALLBACK(eor_Callback_PC) { if(Rd == Rr) { PC_Operation_Rd(OPCODE_clr); } else { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } } @@ -555,7 +554,7 @@ CALLBACK(jmp_Callback_PC) { } else { snprintf(cx->dis_code, 255, "goto %s;", Get_Label_Name(Pos, NULL)); } - Register_JumpCall(Position, Pos, MNemonic_Int, 0); + Register_JumpCall(Position, Pos, mnemo, 0); } CALLBACK(rjmp_Callback_PC) { @@ -567,7 +566,7 @@ CALLBACK(rjmp_Callback_PC) { int Target = FixTargetAddress(Position + Offset + 2); - Register_JumpCall(Position, Target, MNemonic_Int, 0); + Register_JumpCall(Position, Target, mnemo, 0); if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { @@ -595,7 +594,7 @@ CALLBACK(cpi_Callback_PC) { } CALLBACK(asr_Callback_PC) { - PC_Operation_Rd(MNemonic_Int); + PC_Operation_Rd(mnemo); } CALLBACK(dec_Callback_PC) { @@ -607,43 +606,43 @@ CALLBACK(inc_Callback_PC) { } CALLBACK(cp_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(cpc_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(cpse_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(and_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(or_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(mul_Callback_PC) { - PC_Operation_Rd_Rr(MNemonic_Int); + PC_Operation_Rd_Rr(mnemo); } CALLBACK(sbi_Callback_PC) { - PC_Operation_A_b(MNemonic_Int); + PC_Operation_A_b(mnemo); } CALLBACK(sbic_Callback_PC) { - PC_Operation_A_b(MNemonic_Int); + PC_Operation_A_b(mnemo); } CALLBACK(sbis_Callback_PC) { - PC_Operation_A_b(MNemonic_Int); + PC_Operation_A_b(mnemo); } CALLBACK(cbi_Callback_PC) { - PC_Operation_A_b(MNemonic_Int); + PC_Operation_A_b(mnemo); } CALLBACK(ser_Callback_PC) { diff --git a/src/disasm_callbacks_pseudocode.h b/src/disasm_callbacks_pseudocode.h index 36bf2f01..0d3fc92d 100644 --- a/src/disasm_callbacks_pseudocode.h +++ b/src/disasm_callbacks_pseudocode.h @@ -25,82 +25,82 @@ JohannesBauer@gmx.de */ -void PC_Operation_Simple(int MNemonic_Int); -void PC_Operation_Rd(int MNemonic_Int); -void PC_Operation_Rd16(int MNemonic_Int); -void PC_Operation_Rd_Rr(int MNemonic_Int); -void PC_Operation_Rd16_Rr16(int MNemonic_Int); -void PC_Operation_Rd16_K(int MNemonic_Int); -void PC_Operation_Rd_K(int MNemonic_Int); -void PC_Operation_RdW_K(int MNemonic_Int); -void PC_Operation_RdW_RrW(int MNemonic_Int); -void PC_Operation_s_k(int MNemonic_Int, int Position); -void PC_Operation_r_b(int MNemonic_Int); -void PC_Operation_Rd_b(int MNemonic_Int); -void PC_Operation_A_b(int MNemonic_Int); -void PC_Operation_s(int MNemonic_Int); -void PC_Operation_k(int MNemonic_Int, int Position, char *Pseudocode); -void adc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void add_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sub_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sbc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void mov_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brcc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brcs_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void breq_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brge_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brhc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brhs_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brid_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brie_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brlo_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brlt_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brmi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brne_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brpl_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brsh_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brtc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brts_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brvc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void brvs_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void out_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void in_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void cli_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sei_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void ret_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void reti_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void andi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void subi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sbci_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sbr_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void ori_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void ldi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void lds_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sts_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void call_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void rcall_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void ror_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void lsr_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void swap_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void eor_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void jmp_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void rjmp_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void cpi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void asr_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void dec_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void inc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void cp_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void cpc_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void cpse_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void and_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void or_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void mul_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sbi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sbic_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void sbis_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void cbi_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void ser_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void adiw_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void movw_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void lpm1_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); -void st2_Callback_PC(const char *Bitstream, int Position, int MNemonic_Int); +void PC_Operation_Simple(AVR_opcode mnemo); +void PC_Operation_Rd(AVR_opcode mnemo); +void PC_Operation_Rd16(AVR_opcode mnemo); +void PC_Operation_Rd_Rr(AVR_opcode mnemo); +void PC_Operation_Rd16_Rr16(AVR_opcode mnemo); +void PC_Operation_Rd16_K(AVR_opcode mnemo); +void PC_Operation_Rd_K(AVR_opcode mnemo); +void PC_Operation_RdW_K(AVR_opcode mnemo); +void PC_Operation_RdW_RrW(AVR_opcode mnemo); +void PC_Operation_s_k(AVR_opcode mnemo, int Position); +void PC_Operation_r_b(AVR_opcode mnemo); +void PC_Operation_Rd_b(AVR_opcode mnemo); +void PC_Operation_A_b(AVR_opcode mnemo); +void PC_Operation_s(AVR_opcode mnemo); +void PC_Operation_k(AVR_opcode mnemo, int Position, char *Pseudocode); +void adc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void add_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sub_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void mov_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brcc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brcs_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void breq_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brge_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brhc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brhs_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brid_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brie_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brlo_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brlt_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brmi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brne_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brpl_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brsh_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brtc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brts_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brvc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void brvs_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void out_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void in_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void cli_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sei_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void ret_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void reti_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void andi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void subi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbci_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbr_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void ori_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void lds_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sts_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void call_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void rcall_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void ror_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void lsr_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void swap_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void eor_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void jmp_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void rjmp_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void asr_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void dec_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void inc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void cp_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpse_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void and_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void or_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void mul_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbic_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbis_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void cbi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void ser_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void adiw_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void movw_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void lpm1_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void st2_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); diff --git a/src/disasm_globals.h b/src/disasm_globals.h index be61bddb..8aa8ba9a 100644 --- a/src/disasm_globals.h +++ b/src/disasm_globals.h @@ -34,7 +34,7 @@ #define Rb (cx->dis_regs['b']) #define Rq (cx->dis_regs['q']) -#define CALLBACK(name) void name(const char *Bitstream, int Position, int MNemonic_Int) +#define CALLBACK(name) void name(const char *Bitstream, int Position, AVR_opcode mnemo) struct JumpCall { int From; @@ -50,141 +50,3 @@ struct IO_Register { unsigned char Used; }; -enum { - OPCODE_adc, - OPCODE_add, - OPCODE_adiw, - OPCODE_and, - OPCODE_andi, - OPCODE_asr, - OPCODE_bclr, - OPCODE_bld, - OPCODE_brbc, - OPCODE_brbs, - OPCODE_brcc, - OPCODE_brcs, - OPCODE_break, - OPCODE_breq, - OPCODE_brge, - OPCODE_brhc, - OPCODE_brhs, - OPCODE_brid, - OPCODE_brie, - OPCODE_brlo, - OPCODE_brlt, - OPCODE_brmi, - OPCODE_brne, - OPCODE_brpl, - OPCODE_brsh, - OPCODE_brtc, - OPCODE_brts, - OPCODE_brvc, - OPCODE_brvs, - OPCODE_bset, - OPCODE_bst, - OPCODE_call, - OPCODE_cbi, - OPCODE_cbr, - OPCODE_clc, - OPCODE_clh, - OPCODE_cli, - OPCODE_cln, - OPCODE_clr, - OPCODE_cls, - OPCODE_clt, - OPCODE_clv, - OPCODE_clz, - OPCODE_com, - OPCODE_cp, - OPCODE_cpc, - OPCODE_cpi, - OPCODE_cpse, - OPCODE_dec, - OPCODE_eicall, - OPCODE_eijmp, - OPCODE_elpm_1, - OPCODE_elpm_2, - OPCODE_elpm_3, - OPCODE_eor, - OPCODE_fmul, - OPCODE_fmuls, - OPCODE_fmulsu, - OPCODE_icall, - OPCODE_ijmp, - OPCODE_in, - OPCODE_inc, - OPCODE_jmp, - OPCODE_ld_1, - OPCODE_ld_2, - OPCODE_ld_3, - OPCODE_ld_4, - OPCODE_ld_5, - OPCODE_ld_6, - OPCODE_ldd_1, - OPCODE_ld_7, - OPCODE_ld_8, - OPCODE_ld_9, - OPCODE_ldd_2, - OPCODE_ldi, - OPCODE_lds, - OPCODE_lpm_1, - OPCODE_lpm_2, - OPCODE_lpm_3, - OPCODE_lsl, - OPCODE_lsr, - OPCODE_mov, - OPCODE_movw, - OPCODE_mul, - OPCODE_muls, - OPCODE_mulsu, - OPCODE_neg, - OPCODE_nop, - OPCODE_or, - OPCODE_ori, - OPCODE_out, - OPCODE_pop, - OPCODE_push, - OPCODE_rcall, - OPCODE_ret, - OPCODE_reti, - OPCODE_rjmp, - OPCODE_rol, - OPCODE_ror, - OPCODE_sbc, - OPCODE_sbci, - OPCODE_sbi, - OPCODE_sbic, - OPCODE_sbis, - OPCODE_sbiw, - OPCODE_sbr, - OPCODE_sbrc, - OPCODE_sbrs, - OPCODE_sec, - OPCODE_seh, - OPCODE_sei, - OPCODE_sen, - OPCODE_ser, - OPCODE_ses, - OPCODE_set, - OPCODE_sev, - OPCODE_sez, - OPCODE_sleep, - OPCODE_spm, - OPCODE_st_1, - OPCODE_st_2, - OPCODE_st_3, - OPCODE_st_4, - OPCODE_st_5, - OPCODE_st_6, - OPCODE_std_1, - OPCODE_st_7, - OPCODE_st_8, - OPCODE_st_9, - OPCODE_std_2, - OPCODE_sts, - OPCODE_sub, - OPCODE_subi, - OPCODE_swap, - OPCODE_tst, - OPCODE_wdr, -}; diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 80355032..116076ed 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -32,7 +32,6 @@ #include "libavrdude.h" #include "disasm_globals.h" -#include "disasm_mnemonics.h" #include "disasm_tagfile.h" #include "disasm_jumpcall.h" @@ -45,7 +44,7 @@ void Display_JumpCalls() { printf("%d jumps/calls found:\n", JumpCall_Count); for(i = 0; i < JumpCall_Count; i++) { printf("%3d: 0x%-4x -> 0x%-4x %s (%d)\n", i, (unsigned int) JumpCalls[i].From, (unsigned int) JumpCalls[i].To, - MNemonic[JumpCalls[i].Type], JumpCalls[i].FunctionCall); + avr_opcodes[JumpCalls[i].Type].opcode, JumpCalls[i].FunctionCall); } } @@ -180,7 +179,7 @@ void Print_JumpCalls(int Position) { printf("\n"); Match = 1; } - printf("; Referenced from offset 0x%02x by %s\n", JumpCalls[i].From, MNemonic[JumpCalls[i].Type]); + printf("; Referenced from offset 0x%02x by %s\n", JumpCalls[i].From, avr_opcodes[JumpCalls[i].Type].opcode); } } if(Match == 1) { diff --git a/src/disasm_mnemonics.c b/src/disasm_mnemonics.c deleted file mode 100644 index c660f7e9..00000000 --- a/src/disasm_mnemonics.c +++ /dev/null @@ -1,447 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include - -#include "libavrdude.h" - -const char *MNemonic[] = { - "adc", - "add", - "adiw", - "and", - "andi", - "asr", - "bclr", - "bld", - "brbc", - "brbs", - "brcc", - "brcs", - "break", - "breq", - "brge", - "brhc", - "brhs", - "brid", - "brie", - "brlo", - "brlt", - "brmi", - "brne", - "brpl", - "brsh", - "brtc", - "brts", - "brvc", - "brvs", - "bset", - "bst", - "call", - "cbi", - "cbr", - "clc", - "clh", - "cli", - "cln", - "clr", - "cls", - "clt", - "clv", - "clz", - "com", - "cp", - "cpc", - "cpi", - "cpse", - "dec", - "eicall", - "eijmp", - "elpm", - "elpm", - "elpm", - "eor", - "fmul", - "fmuls", - "fmulsu", - "icall", - "ijmp", - "in", - "inc", - "jmp", - "ld", - "ld", - "ld", - "ld", - "ld", - "ld", - "ldd", - "ld", - "ld", - "ld", - "ldd", - "ldi", - "lds", - "lpm", - "lpm", - "lpm", - "lsl", - "lsr", - "mov", - "movw", - "mul", - "muls", - "mulsu", - "neg", - "nop", - "or", - "ori", - "out", - "pop", - "push", - "rcall", - "ret", - "reti", - "rjmp", - "rol", - "ror", - "sbc", - "sbci", - "sbi", - "sbic", - "sbis", - "sbiw", - "sbr", - "sbrc", - "sbrs", - "sec", - "seh", - "sei", - "sen", - "ser", - "ses", - "set", - "sev", - "sez", - "sleep", - "spm", - "st", - "st", - "st", - "st", - "st", - "st", - "std", - "st", - "st", - "st", - "std", - "sts", - "sub", - "subi", - "swap", - "tst", - "wdr" -}; - -const char *Cycles[] = { - "1", // adc - "1", // add - "2", // adiw - "1", // and - "1", // andi - "1", // asr - "1", // bclr - "1", // bld - "1/2", // brbc - "1/2", // brbs - "1/2", // brcc - "1/2", // brcs - "N/A", // break - "1/2", // breq - "1/2", // brge - "1/2", // brhc - "1/2", // brhs - "1/2", // brid - "1/2", // brie - "1/2", // brlo - "1/2", // brlt - "1/2", // brmi - "1/2", // brne - "1/2", // brpl - "1/2", // brsh - "1/2", // brtc - "1/2", // brts - "1/2", // brvc - "1/2", // brvs - "1", // bset - "1", // bst - "4", // call - "2", // cbi - "1", // cbr - "1", // clc - "", // clh - "1", // cli - "1", // cln - "1", // clr - "1", // cls - "1", // clt - "1", // clv - "1", // clz - "1", // com - "1", // cp - "1", // cpc - "1", // cpi - "1-3", // cpse - "1", // dec - NULL, - NULL, - NULL, - NULL, - NULL, - "1", // eor - "2", // fmul - "2", // fmuls - "2", // fmulsu - "3", // icall - "2", // ijmp - "1", // in - "1", // inc - "3", // jmp - "2", // ld - "2", // ld - "2", // ld - "2", // ld - "2", // ld - "2", // ld - "2", // ldd - "2", // ld - "2", // ld - "2", // ld - "2", // ldd - "1", // ldi - "2", // lds - "3", // lpm - "3", // lpm - "3", // lpm - "1", // lsl - "1", // lsr - "1", // mov - "1", // movw - "2", // mul - "2", // muls - "2", // mulsu - "1", // neg - "1", // nop - "1", // or - "1", // ori - "1", // out - "2", // pop - "2", // push - "3", // rcall - "4", // ret - "4", // reti - "2", // rjmp - "1", // rol - "1", // ror - "1", // sbc - "1", // sbci - "2", // sbi - "1-3", // sbic - "1-3", // sbis - "2", // sbiw - "1", // sbr - "1-3", // sbrc - "1-3", // sbrs - "1", // sec - "1", // seh - "1", // sei - "1", // sen - "1", // ser - "1", // ses - "1", // set - "1", // sev - "1", // sez - "1", // sleep - "-", // spm - "2", // st - "2", // st - "2", // st - "2", // st - "2", // st - "2", // st - "2", // std - "2", // st - "2", // st - "2", // st - "2", // std - "2", // sts - "1", // sub - "1", // subi - "1", // swap - "1", // tst - "1" // wdr -}; - -/* -adc -add -adiw -and -andi -asr -bclr -bld -brbc -brbs -brcc -brcs -break -breq -brge -brhc -brhs -brid -brie -brlo -brlt -brmi -brne -brpl -brsh -brtc -brts -brvc -brvs -bset -bst -call -cbi -cbr -clc -clh -cli -cln -clr -cls -clt -clv -clz -com -cp -cpc -cpi -cpse -dec -eicall -eijmp -elpm -elpm -elpm -eor -fmul -fmuls -fmulsu -icall -ijmp -in -inc -jmp -ld -ld -ld -ld -ld -ld -ldd -ld -ld -ld -ldd -ldi -lds -lpm -lpm -lpm -lsl -lsr -mov -movw -mul -muls -mulsu -neg -nop -or -ori -out -pop -push -rcall -ret -reti -rjmp -rol -ror -sbc -sbci -sbi -sbic -sbis -sbiw -sbr -sbrc -sbrs -sec -seh -sei -sen -ser -ses -set -sev -sez -sleep -spm -st -st -st -st -st -st -std -st -st -st -std -sts -sub -subi -swap -tst -wdr -*/ diff --git a/src/disasm_mnemonics.h b/src/disasm_mnemonics.h deleted file mode 100644 index 516fd4a4..00000000 --- a/src/disasm_mnemonics.h +++ /dev/null @@ -1,29 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -extern const char *MNemonic[]; -extern const char *Cycles[]; diff --git a/src/libavrdude.h b/src/libavrdude.h index f3b07c4b..707b6eb5 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1460,12 +1460,77 @@ typedef struct { int FlashSize; } Disasm_options; +typedef enum { + OPCODE_add, OPCODE_adc, OPCODE_adiw, OPCODE_sub, + OPCODE_subi, OPCODE_sbc, OPCODE_sbci, OPCODE_sbiw, + OPCODE_and, OPCODE_andi, OPCODE_or, OPCODE_ori, + OPCODE_eor, OPCODE_com, OPCODE_neg, OPCODE_sbr, + OPCODE_cbr, OPCODE_inc, OPCODE_dec, OPCODE_tst, + OPCODE_clr, OPCODE_ser, OPCODE_mul, OPCODE_muls, + OPCODE_mulsu, OPCODE_fmul, OPCODE_fmuls, OPCODE_fmulsu, + OPCODE_des, OPCODE_rjmp, OPCODE_ijmp, OPCODE_eijmp, + OPCODE_jmp, OPCODE_rcall, OPCODE_icall, OPCODE_eicall, + OPCODE_call, OPCODE_ret, OPCODE_reti, OPCODE_cpse, + OPCODE_cp, OPCODE_cpc, OPCODE_cpi, OPCODE_sbrc, + OPCODE_sbrs, OPCODE_sbic, OPCODE_sbis, OPCODE_brcs, + OPCODE_brlo, OPCODE_breq, OPCODE_brmi, OPCODE_brvs, + OPCODE_brlt, OPCODE_brhs, OPCODE_brts, OPCODE_brie, + OPCODE_brbs, OPCODE_brcc, OPCODE_brsh, OPCODE_brne, + OPCODE_brpl, OPCODE_brvc, OPCODE_brge, OPCODE_brhc, + OPCODE_brtc, OPCODE_brid, OPCODE_brbc, OPCODE_mov, + OPCODE_movw, OPCODE_ldi, OPCODE_lds, OPCODE_lds_rc, + OPCODE_ld_1, OPCODE_ld_2, OPCODE_ld_3, OPCODE_ld_4, + OPCODE_ld_5, OPCODE_ld_6, OPCODE_ldd_1, OPCODE_ld_7, + OPCODE_ld_8, OPCODE_ld_9, OPCODE_ldd_2, OPCODE_sts, + OPCODE_sts_rc, OPCODE_st_1, OPCODE_st_2, OPCODE_st_3, + OPCODE_st_4, OPCODE_st_5, OPCODE_st_6, OPCODE_std_1, + OPCODE_st_7, OPCODE_st_8, OPCODE_st_9, OPCODE_std_2, + OPCODE_lpm_1, OPCODE_lpm_2, OPCODE_lpm_3, OPCODE_elpm_1, + OPCODE_elpm_2, OPCODE_elpm_3, OPCODE_spm, OPCODE_spm_zz, + OPCODE_in, OPCODE_out, OPCODE_push, OPCODE_pop, + OPCODE_xch, OPCODE_las, OPCODE_lac, OPCODE_lat, + OPCODE_lsl, OPCODE_lsr, OPCODE_rol, OPCODE_ror, + OPCODE_asr, OPCODE_swap, OPCODE_bset, OPCODE_bclr, + OPCODE_sbi, OPCODE_cbi, OPCODE_bst, OPCODE_bld, + OPCODE_sec, OPCODE_clc, OPCODE_sen, OPCODE_cln, + OPCODE_sez, OPCODE_clz, OPCODE_sei, OPCODE_cli, + OPCODE_ses, OPCODE_cls, OPCODE_sev, OPCODE_clv, + OPCODE_set, OPCODE_clt, OPCODE_seh, OPCODE_clh, + OPCODE_break, OPCODE_nop, OPCODE_sleep, OPCODE_wdr, + OPCODE_x_nop_1, OPCODE_x_nop_2, OPCODE_x_nop_3, OPCODE_x_nop_4, + OPCODE_x_nop_5, OPCODE_x_nop_6, OPCODE_x_nop_7, OPCODE_x_icall, + OPCODE_x_eicall, OPCODE_x_ret, OPCODE_x_reti, OPCODE_x_nop_8, + OPCODE_x_nop_9, OPCODE_x_nop_a, OPCODE_x_ijmp, OPCODE_x_eijmp, + OPCODE_x_bld, OPCODE_x_bst, OPCODE_x_sbrc, OPCODE_x_sbrs, +} AVR_opcode; + typedef struct { char *Opcode_String; - void (*Callback)(const char *, int, int); - int MNemonic; + void (*Callback)(const char *, int, AVR_opcode); + AVR_opcode mnemo; } Disasm_opcode; + + +typedef struct { + int mask, value, nwords; + const char *opcode_bits; // Eg, "0000 11rd dddd rrrr" + AVR_opcode mnemo; // OPCODE_add, ... + const char + *opcode, // "add" + *operands, // "Rd, Rr" + *description, // "Add without Carry" + *operation, // "Rd ← Rd+Rr" + *flags, // "Z,C,N,V,S,H" + *clocks_e, // Timing for AVRe (extended AVR opcode set) + *clocks_xm, // Timing for AVRxm (XMEGA) + *clocks_xt, // Timing for AVRxt (modern UPDI) + *clocks_rc, // Timing for AVRrc (reduced core) + *note, *remarks; +} AVR_opcode_data; + +extern const AVR_opcode_data avr_opcodes[164]; + #define CODESTYLE_AVR_INSTRUCTION_SET 0 #define CODESTYLE_AVRGCC 1 From 8e864afcf0f7292ffb0a004d2db9360a9ff32f36 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 16 Jul 2024 22:27:07 +0100 Subject: [PATCH 282/422] Lowercase opcode mnemonics --- src/avr_opcodes.c | 328 +++++++++++++++++++++++----------------------- 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 07089cce..dc5591ab 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -22,178 +22,178 @@ const AVR_opcode_data avr_opcodes[164] = { // Arithmetic and Logic Instructions - {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OPCODE_add, "ADD", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OPCODE_adc, "ADC", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OPCODE_adiw, "ADIW", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", "2", "2", "2", "n/a", "(1)", "d in {24, 26, 28, 30}"}, - {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OPCODE_sub, "SUB", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OPCODE_subi, "SUBI", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OPCODE_sbc, "SBC", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OPCODE_sbci, "SBCI", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", "d=16..31"}, - {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OPCODE_sbiw, "SBIW", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", "2", "2", "2", "n/a", "(1)", "d in {24, 26, 28, 30}"}, - {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OPCODE_and, "AND", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OPCODE_andi, "ANDI", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", "1", "1", "1", "1", "", "d = 16..31"}, - {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OPCODE_or, "OR", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OPCODE_ori, "ORI", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OPCODE_eor, "EOR", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OPCODE_com, "COM", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OPCODE_neg, "NEG", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OPCODE_sbr, "SBR", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", "1", "1", "1", "1", "", "alias for ORI Rd, K"}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OPCODE_cbr, "CBR", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", "1", "1", "1", "1", "", "alias for ANDI Rd, (0xFF - K)"}, - {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OPCODE_inc, "INC", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OPCODE_dec, "DEC", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OPCODE_tst, "TST", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", "1", "1", "1", "1", "", "alias for AND Rd, Rd"}, - {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OPCODE_clr, "CLR", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", "1", "1", "1", "1", "", "alias for EOR Rd, Rd"}, - {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OPCODE_ser, "SER", "Rd", "Set Register", "Rd <-- $FF", "None", "1", "1", "1", "1", "", "alias for LDI Rd, 0xFF"}, - {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OPCODE_mul, "MUL", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", "2", "2", "2", "n/a", "(1)", ""}, - {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OPCODE_muls, "MULS", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", "2", "2", "2", "n/a", "(1)", "d, r=16..31"}, - {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OPCODE_mulsu, "MULSU", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", "2", "2", "2", "n/a", "(1)", "d, r=16..23"}, - {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OPCODE_fmul, "FMUL", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, - {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OPCODE_fmuls, "FMULS", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, - {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OPCODE_fmulsu, "FMULSU", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, - {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OPCODE_des, "DES", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", "n/a", "1/2", "n/a", "n/a", "", ""}, + {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OPCODE_add, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", "2", "2", "2", "n/a", "(1)", "d in {24, 26, 28, 30}"}, + {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", "d=16..31"}, + {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", "2", "2", "2", "n/a", "(1)", "d in {24, 26, 28, 30}"}, + {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", "1", "1", "1", "1", "", "d = 16..31"}, + {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", "1", "1", "1", "1", "", "alias for ORI Rd, K"}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", "1", "1", "1", "1", "", "alias for ANDI Rd, (0xFF - K)"}, + {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", "1", "1", "1", "1", "", "alias for AND Rd, Rd"}, + {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", "1", "1", "1", "1", "", "alias for EOR Rd, Rd"}, + {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", "1", "1", "1", "1", "", "alias for LDI Rd, 0xFF"}, + {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", "2", "2", "2", "n/a", "(1)", ""}, + {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", "2", "2", "2", "n/a", "(1)", "d, r=16..31"}, + {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", "2", "2", "2", "n/a", "(1)", "d, r=16..23"}, + {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, + {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, + {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, + {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", "n/a", "1/2", "n/a", "n/a", "", ""}, // Branch Instructions - {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OPCODE_rjmp, "RJMP", "k", "Relative Jump", "PC <-- PC+k+1", "None", "2", "2", "2", "2", "", ""}, - {0xffff, 0x9409, 1, "1001 0100 0000 1001", OPCODE_ijmp, "IJMP", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "2", "2", "2", "2", "(1)", ""}, - {0xffff, 0x9419, 1, "1001 0100 0001 1001", OPCODE_eijmp, "EIJMP", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "2", "2", "2", "n/a", "(1)", ""}, - {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp, "JMP", "k", "Jump", "PC <-- k", "None", "3", "3", "3", "n/a", "(1)", ""}, - {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OPCODE_rcall, "RCALL", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", "3/4", "2/3", "2/3", "3", "", ""}, - {0xffff, 0x9509, 1, "1001 0101 0000 1001", OPCODE_icall, "ICALL", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "3/4", "2/3", "2/3", "3", "(1)", ""}, - {0xffff, 0x9519, 1, "1001 0101 0001 1001", OPCODE_eicall, "EICALL", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "4", "3", "3", "n/a", "(1)", ""}, - {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call, "CALL", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", "4/5", "3/4", "3/4", "n/a", "(1)", ""}, - {0xffff, 0x9508, 1, "1001 0101 0000 1000", OPCODE_ret, "RET", "-", "Subroutine Return", "PC <-- STACK", "None", "4/5", "4/5", "4/5", "6", "", ""}, - {0xffff, 0x9518, 1, "1001 0101 0001 1000", OPCODE_reti, "RETI", "-", "Interrupt Return", "PC <-- STACK", "I", "4/5", "4/5", "4/5", "6", "", ""}, - {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OPCODE_cpse, "CPSE", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, - {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OPCODE_cp, "CP", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OPCODE_cpc, "CPC", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OPCODE_cpi, "CPI", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", "1", "1", "1", "1", "", "d = 16..31"}, - {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OPCODE_sbrc, "SBRC", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, - {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OPCODE_sbrs, "SBRS", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, - {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OPCODE_sbic, "SBIC", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", "", ""}, - {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OPCODE_sbis, "SBIS", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", "", ""}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OPCODE_brcs, "BRCS", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OPCODE_brlo, "BRLO", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OPCODE_breq, "BREQ", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 1, k (Z Zero)"}, - {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OPCODE_brmi, "BRMI", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 2, k (N Negative)"}, - {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OPCODE_brvs, "BRVS", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OPCODE_brlt, "BRLT", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 4, k (S Sign)"}, - {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OPCODE_brhs, "BRHS", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 5, k (H Half carry)"}, - {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OPCODE_brts, "BRTS", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 6, k (T Transfer bit)"}, - {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OPCODE_brie, "BRIE", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 7, k (I Interrupt enable)"}, - {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OPCODE_brbs, "BRBS", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", ""}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OPCODE_brcc, "BRCC", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OPCODE_brsh, "BRSH", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OPCODE_brne, "BRNE", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 1, k (Z Zero)"}, - {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OPCODE_brpl, "BRPL", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 2, k (N Negative)"}, - {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OPCODE_brvc, "BRVC", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OPCODE_brge, "BRGE", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 4, k (S Sign)"}, - {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OPCODE_brhc, "BRHC", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 5, k (H Half carry)"}, - {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OPCODE_brtc, "BRTC", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 6, k (T Transfer bit)"}, - {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OPCODE_brid, "BRID", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 7, k (I Interrupt enable)"}, - {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OPCODE_brbc, "BRBC", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", ""}, + {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", "2", "2", "2", "2", "", ""}, + {0xffff, 0x9409, 1, "1001 0100 0000 1001", OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "2", "2", "2", "2", "(1)", ""}, + {0xffff, 0x9419, 1, "1001 0100 0001 1001", OPCODE_eijmp, "eijmp", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "2", "2", "2", "n/a", "(1)", ""}, + {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", "3", "3", "3", "n/a", "(1)", ""}, + {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", "3/4", "2/3", "2/3", "3", "", ""}, + {0xffff, 0x9509, 1, "1001 0101 0000 1001", OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "3/4", "2/3", "2/3", "3", "(1)", ""}, + {0xffff, 0x9519, 1, "1001 0101 0001 1001", OPCODE_eicall, "eicall", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "4", "3", "3", "n/a", "(1)", ""}, + {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", "4/5", "3/4", "3/4", "n/a", "(1)", ""}, + {0xffff, 0x9508, 1, "1001 0101 0000 1000", OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", "4/5", "4/5", "4/5", "6", "", ""}, + {0xffff, 0x9518, 1, "1001 0101 0001 1000", OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", "4/5", "4/5", "4/5", "6", "", ""}, + {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OPCODE_cpse, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, + {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OPCODE_cp, "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OPCODE_cpc, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, + {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OPCODE_cpi, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", "1", "1", "1", "1", "", "d = 16..31"}, + {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OPCODE_sbrc, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, + {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, + {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", "", ""}, + {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", "", ""}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 1, k (Z Zero)"}, + {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 2, k (N Negative)"}, + {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 4, k (S Sign)"}, + {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 5, k (H Half carry)"}, + {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 6, k (T Transfer bit)"}, + {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 7, k (I Interrupt enable)"}, + {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", ""}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 1, k (Z Zero)"}, + {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 2, k (N Negative)"}, + {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 4, k (S Sign)"}, + {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 5, k (H Half carry)"}, + {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 6, k (T Transfer bit)"}, + {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 7, k (I Interrupt enable)"}, + {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", ""}, // Data Transfer Instructions - {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OPCODE_mov, "MOV", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", "1", "1", "1", "1", "", ""}, - {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OPCODE_movw, "MOVW", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", "1", "1", "1", "n/a", "(1)", ""}, - {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OPCODE_ldi, "LDI", "Rd, K", "Load Immediate", "Rd <-- K", "None", "1", "1", "1", "1", "", "d=16..31"}, - {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds, "LDS", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "2", "3", "3", "2", "(1)", ""}, - {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OPCODE_lds_rc, "LDS", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "n/a", "n/a", "n/a", "2", "(1)", "attiny only"}, - {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OPCODE_ld_1, "LD", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", "2", "2", "2", "1/2", "(2)", ""}, - {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OPCODE_ld_2, "LD", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", "2", "2", "2", "2/3", "(2)", ""}, - {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OPCODE_ld_3, "LD", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", "2", "3", "2", "2/3", "(2)", ""}, - {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OPCODE_ld_4, "LD", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", "2", "2", "2", "1/2", "(2)", "alias for LDD Rd, Y+0"}, - {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OPCODE_ld_5, "LD", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", "2", "2", "2", "2/3", "(2)", ""}, - {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OPCODE_ld_6, "LD", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", "2", "3", "2", "2/3", "(2)", ""}, - {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OPCODE_ldd_1, "LDD", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", "2", "3", "2", "n/a", "(1)", ""}, - {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OPCODE_ld_7, "LD", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", "2", "2", "2", "1/2", "(2)", "alias for LDD Rd,Z+0"}, - {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OPCODE_ld_8, "LD", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", "2", "2", "2", "2/3", "(2)", ""}, - {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OPCODE_ld_9, "LD", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", "2", "3", "2", "2/3", "(2)", ""}, - {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2, "LDD", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", "2", "3", "2", "n/a", "(1)", ""}, - {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts, "STS", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "2", "2", "2", "1", "(1)", ""}, - {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OPCODE_sts_rc, "STS", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "n/a", "n/a", "n/a", "1", "(1)", "attiny only"}, - {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OPCODE_st_1, "ST", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", "2", "1", "1", "1", "(2)", ""}, - {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OPCODE_st_2, "ST", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", "2", "1", "1", "1", "(2)", ""}, - {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OPCODE_st_3, "ST", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", "2", "2", "1", "1", "(2)", ""}, - {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OPCODE_st_4, "ST", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", "2", "1", "1", "1", "(2)", "alias for STD Y+0, Rr"}, - {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OPCODE_st_5, "ST", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", "2", "1", "1", "1", "(2)", ""}, - {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OPCODE_st_6, "ST", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", "2", "2", "1", "1", "(2)", ""}, - {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OPCODE_std_1, "STD", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", "2", "2", "1", "n/a", "(1)", ""}, - {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OPCODE_st_7, "ST", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", "2", "1", "1", "1", "(2)", "alias for STD Z+0, Rr"}, - {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OPCODE_st_8, "ST", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", "2", "1", "1", "1", "(2)", ""}, - {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OPCODE_st_9, "ST", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", "2", "2", "1", "1", "(2)", ""}, - {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OPCODE_std_2, "STD", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", "2", "2", "1", "n/a", "(1)", ""}, - {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OPCODE_lpm_1, "LPM", "-", "Load Program Memory", "R0 <-- (Z)", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, - {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OPCODE_lpm_2, "LPM", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, - {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OPCODE_lpm_3, "LPM", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, - {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OPCODE_elpm_1, "ELPM", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", "(1)", ""}, - {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OPCODE_elpm_2, "ELPM", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", "(1)", ""}, - {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OPCODE_elpm_3, "ELPM", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", "(1)", ""}, - {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OPCODE_spm, "SPM", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", "-", "-", "-", "-", "(1)", ""}, - {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OPCODE_spm_zz, "SPM", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", "n/a", "-", "-", "n/a", "(1)", ""}, - {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OPCODE_in, "IN", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", "1", "1", "1", "1", "", ""}, - {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OPCODE_out, "OUT", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OPCODE_push, "PUSH", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", "2", "1", "1", "1", "(1)", ""}, - {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OPCODE_pop, "POP", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", "2", "2", "2", "3", "(1)", ""}, - {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OPCODE_xch, "XCH", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, - {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OPCODE_las, "LAS", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, - {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OPCODE_lac, "LAC", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, - {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OPCODE_lat, "LAT", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", "1", "1", "1", "1", "", ""}, + {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", "1", "1", "1", "n/a", "(1)", ""}, + {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", "1", "1", "1", "1", "", "d=16..31"}, + {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "2", "3", "3", "2", "(1)", ""}, + {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "n/a", "n/a", "n/a", "2", "(1)", "attiny only"}, + {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", "2", "2", "2", "1/2", "(2)", ""}, + {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", "2", "2", "2", "2/3", "(2)", ""}, + {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", "2", "3", "2", "2/3", "(2)", ""}, + {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", "2", "2", "2", "1/2", "(2)", "alias for LDD Rd, Y+0"}, + {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", "2", "2", "2", "2/3", "(2)", ""}, + {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", "2", "3", "2", "2/3", "(2)", ""}, + {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", "2", "3", "2", "n/a", "(1)", ""}, + {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", "2", "2", "2", "1/2", "(2)", "alias for LDD Rd,Z+0"}, + {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", "2", "2", "2", "2/3", "(2)", ""}, + {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", "2", "3", "2", "2/3", "(2)", ""}, + {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", "2", "3", "2", "n/a", "(1)", ""}, + {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "2", "2", "2", "1", "(1)", ""}, + {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "n/a", "n/a", "n/a", "1", "(1)", "attiny only"}, + {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", "2", "1", "1", "1", "(2)", ""}, + {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", "2", "1", "1", "1", "(2)", ""}, + {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", "2", "2", "1", "1", "(2)", ""}, + {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", "2", "1", "1", "1", "(2)", "alias for STD Y+0, Rr"}, + {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", "2", "1", "1", "1", "(2)", ""}, + {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", "2", "2", "1", "1", "(2)", ""}, + {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", "2", "2", "1", "n/a", "(1)", ""}, + {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", "2", "1", "1", "1", "(2)", "alias for STD Z+0, Rr"}, + {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", "2", "1", "1", "1", "(2)", ""}, + {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", "2", "2", "1", "1", "(2)", ""}, + {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", "2", "2", "1", "n/a", "(1)", ""}, + {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OPCODE_lpm_1, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, + {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OPCODE_lpm_2, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, + {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OPCODE_lpm_3, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, + {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OPCODE_elpm_1, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", "(1)", ""}, + {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OPCODE_elpm_2, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", "(1)", ""}, + {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", "(1)", ""}, + {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", "-", "-", "-", "-", "(1)", ""}, + {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", "n/a", "-", "-", "n/a", "(1)", ""}, + {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OPCODE_in, "in", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", "1", "1", "1", "1", "", ""}, + {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", "2", "1", "1", "1", "(1)", ""}, + {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", "2", "2", "2", "3", "(1)", ""}, + {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, // Bit and Bit-test Instructions - {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OPCODE_lsl, "LSL", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", "1", "1", "1", "1", "", "alias for ADD Rd, Rd"}, - {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OPCODE_lsr, "LSR", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OPCODE_rol, "ROL", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", "1", "1", "1", "1", "", "alias for ADC Rd, Rd"}, - {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OPCODE_ror, "ROR", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OPCODE_asr, "ASR", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OPCODE_swap, "SWAP", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", "1", "1", "1", "1", "", ""}, - {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OPCODE_bset, "BSET", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", "1", "1", "1", "1", "", ""}, - {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OPCODE_bclr, "BCLR", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", "1", "1", "1", "1", "", "s = 0-7 = C,Z,N,V,S,H,T,I"}, - {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OPCODE_sbi, "SBI", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", "2", "1", "1", "1", "", ""}, - {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OPCODE_cbi, "CBI", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", "2", "1", "1", "1", "", ""}, - {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OPCODE_bst, "BST", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", "1", "1", "1", "1", "", ""}, - {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OPCODE_bld, "BLD", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", "1", "1", "1", "1", "", ""}, - {0xffff, 0x9408, 1, "1001 0100 0000 1000", OPCODE_sec, "SEC", "-", "Set Carry", "C <-- 1", "C", "1", "1", "1", "1", "", "alias for BSET 0"}, - {0xffff, 0x9488, 1, "1001 0100 1000 1000", OPCODE_clc, "CLC", "-", "Clear Carry", "C <-- 0", "C", "1", "1", "1", "1", "", "alias for BCLR 0"}, - {0xffff, 0x9428, 1, "1001 0100 0010 1000", OPCODE_sen, "SEN", "-", "Set Negative Flag", "N <-- 1", "N", "1", "1", "1", "1", "", "alias for BSET 2"}, - {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OPCODE_cln, "CLN", "-", "Clear Negative Flag", "N <-- 0", "N", "1", "1", "1", "1", "", "alias for BCLR 2"}, - {0xffff, 0x9418, 1, "1001 0100 0001 1000", OPCODE_sez, "SEZ", "-", "Set Zero Flag", "Z <-- 1", "Z", "1", "1", "1", "1", "", "alias for BSET 1"}, - {0xffff, 0x9498, 1, "1001 0100 1001 1000", OPCODE_clz, "CLZ", "-", "Clear Zero Flag", "Z <-- 0", "Z", "1", "1", "1", "1", "", "alias for BCLR 1"}, - {0xffff, 0x9478, 1, "1001 0100 0111 1000", OPCODE_sei, "SEI", "-", "Global Interrupt Enable", "I <-- 1", "I", "1", "1", "1", "1", "", "alias for BSET 7"}, - {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OPCODE_cli, "CLI", "-", "Global Interrupt Disable", "I <-- 0", "I", "1", "1", "1", "1", "", "alias for BCLR 7"}, - {0xffff, 0x9448, 1, "1001 0100 0100 1000", OPCODE_ses, "SES", "-", "Set Signed Test Flag", "S <-- 1", "S", "1", "1", "1", "1", "", "alias for BSET 4"}, - {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OPCODE_cls, "CLS", "-", "Clear Signed Test Flag", "S <-- 0", "S", "1", "1", "1", "1", "", "alias for BCLR 4"}, - {0xffff, 0x9438, 1, "1001 0100 0011 1000", OPCODE_sev, "SEV", "-", "Set Two's Complement Overflow", "V <-- 1", "V", "1", "1", "1", "1", "", "alias for BSET 3"}, - {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OPCODE_clv, "CLV", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", "1", "1", "1", "1", "", "alias for BCLR 3"}, - {0xffff, 0x9468, 1, "1001 0100 0110 1000", OPCODE_set, "SET", "-", "Set T in SREG", "T <-- 1", "T", "1", "1", "1", "1", "", "alias for BSET 6"}, - {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OPCODE_clt, "CLT", "-", "Clear T in SREG", "T <-- 0", "T", "1", "1", "1", "1", "", "alias for BCLR 6"}, - {0xffff, 0x9458, 1, "1001 0100 0101 1000", OPCODE_seh, "SEH", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", "1", "1", "1", "1", "", "alias for BSET 5"}, - {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OPCODE_clh, "CLH", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", "1", "1", "1", "1", "", "alias for BCLR 5"}, + {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", "1", "1", "1", "1", "", "alias for ADD Rd, Rd"}, + {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, + {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", "1", "1", "1", "1", "", "alias for ADC Rd, Rd"}, + {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, + {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", "1", "1", "1", "1", "", ""}, + {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OPCODE_bset, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", "1", "1", "1", "1", "", ""}, + {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", "1", "1", "1", "1", "", "s = 0-7 = C,Z,N,V,S,H,T,I"}, + {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", "2", "1", "1", "1", "", ""}, + {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", "2", "1", "1", "1", "", ""}, + {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OPCODE_bst, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", "1", "1", "1", "1", "", ""}, + {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", "1", "1", "1", "1", "", ""}, + {0xffff, 0x9408, 1, "1001 0100 0000 1000", OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", "1", "1", "1", "1", "", "alias for BSET 0"}, + {0xffff, 0x9488, 1, "1001 0100 1000 1000", OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", "1", "1", "1", "1", "", "alias for BCLR 0"}, + {0xffff, 0x9428, 1, "1001 0100 0010 1000", OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", "1", "1", "1", "1", "", "alias for BSET 2"}, + {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", "1", "1", "1", "1", "", "alias for BCLR 2"}, + {0xffff, 0x9418, 1, "1001 0100 0001 1000", OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", "1", "1", "1", "1", "", "alias for BSET 1"}, + {0xffff, 0x9498, 1, "1001 0100 1001 1000", OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", "1", "1", "1", "1", "", "alias for BCLR 1"}, + {0xffff, 0x9478, 1, "1001 0100 0111 1000", OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", "1", "1", "1", "1", "", "alias for BSET 7"}, + {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", "1", "1", "1", "1", "", "alias for BCLR 7"}, + {0xffff, 0x9448, 1, "1001 0100 0100 1000", OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", "1", "1", "1", "1", "", "alias for BSET 4"}, + {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", "1", "1", "1", "1", "", "alias for BCLR 4"}, + {0xffff, 0x9438, 1, "1001 0100 0011 1000", OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", "1", "1", "1", "1", "", "alias for BSET 3"}, + {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", "1", "1", "1", "1", "", "alias for BCLR 3"}, + {0xffff, 0x9468, 1, "1001 0100 0110 1000", OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", "1", "1", "1", "1", "", "alias for BSET 6"}, + {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", "1", "1", "1", "1", "", "alias for BCLR 6"}, + {0xffff, 0x9458, 1, "1001 0100 0101 1000", OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", "1", "1", "1", "1", "", "alias for BSET 5"}, + {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", "1", "1", "1", "1", "", "alias for BCLR 5"}, // MCU Control Instructions - {0xffff, 0x9598, 1, "1001 0101 1001 1000", OPCODE_break, "BREAK", "-", "Break", "(cf documentation)", "None", "-", "-", "-", "-", "(1)", ""}, - {0xffff, 0x0000, 1, "0000 0000 0000 0000", OPCODE_nop, "NOP", "-", "No Operation", "-", "None", "1", "1", "1", "1", "", ""}, - {0xffff, 0x9588, 1, "1001 0101 1000 1000", OPCODE_sleep, "SLEEP", "-", "Sleep", "(cf documentation)", "None", "-", "-", "-", "-", "", ""}, - {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OPCODE_wdr, "WDR", "-", "Watchdog Reset", "(cf documentation)", "None", "1", "1", "1", "1", "", ""}, + {0xffff, 0x9598, 1, "1001 0101 1001 1000", OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", "-", "-", "-", "-", "(1)", ""}, + {0xffff, 0x0000, 1, "0000 0000 0000 0000", OPCODE_nop, "nop", "-", "No Operation", "-", "None", "1", "1", "1", "1", "", ""}, + {0xffff, 0x9588, 1, "1001 0101 1000 1000", OPCODE_sleep, "sleep", "-", "Sleep", "(cf documentation)", "None", "-", "-", "-", "-", "", ""}, + {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", "1", "1", "1", "1", "", ""}, // Unallocated codes - {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OPCODE_x_nop_1, "NOP", "", "", "", "", "", "", "", "", "", "xxxx xxxx != 0000 0000"}, - {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OPCODE_x_nop_2, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OPCODE_x_nop_3, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OPCODE_x_nop_4, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OPCODE_x_nop_5, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OPCODE_x_nop_6, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OPCODE_x_nop_7, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OPCODE_x_icall, "ICALL", "", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OPCODE_x_eicall, "EICALL", "", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OPCODE_x_ret, "RET", "", "", "", "", "", "", "", "", "", "xx != 00"}, - {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OPCODE_x_reti, "RETI", "", "", "", "", "", "", "", "", "", "xx != 00"}, - {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OPCODE_x_nop_8, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OPCODE_x_nop_9, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OPCODE_x_nop_a, "NOP", "", "", "", "", "", "", "", "", "", ""}, - {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OPCODE_x_ijmp, "IJMP", "", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OPCODE_x_eijmp, "EIJMP", "", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xfe08, 0xf808, 1, "1111 100x xxxx 1xxx", OPCODE_x_bld, "BLD", "Rd, b", "", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfa08, 1, "1111 101x xxxx 1xxx", OPCODE_x_bst, "BST", "Rd, b", "", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfc08, 1, "1111 110x xxxx 1xxx", OPCODE_x_sbrc, "SBRC", "Rr, b", "", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfe08, 1, "1111 111x xxxx 1xxx", OPCODE_x_sbrs, "SBRS", "Rr, b", "", "", "", "", "", "", "", "", ""}, + {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OPCODE_x_nop_1, "nop", "", "", "", "", "", "", "", "", "", "xxxx xxxx != 0000 0000"}, + {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OPCODE_x_nop_2, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OPCODE_x_nop_3, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OPCODE_x_nop_4, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OPCODE_x_nop_5, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OPCODE_x_nop_6, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OPCODE_x_nop_7, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OPCODE_x_icall, "icall", "", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OPCODE_x_eicall, "eicall", "", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OPCODE_x_ret, "ret", "", "", "", "", "", "", "", "", "", "xx != 00"}, + {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OPCODE_x_reti, "reti", "", "", "", "", "", "", "", "", "", "xx != 00"}, + {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OPCODE_x_nop_8, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OPCODE_x_nop_9, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OPCODE_x_nop_a, "nop", "", "", "", "", "", "", "", "", "", ""}, + {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OPCODE_x_ijmp, "ijmp", "", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OPCODE_x_eijmp, "eijmp", "", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xfe08, 0xf808, 1, "1111 100x xxxx 1xxx", OPCODE_x_bld, "bld", "Rd, b", "", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfa08, 1, "1111 101x xxxx 1xxx", OPCODE_x_bst, "bst", "Rd, b", "", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfc08, 1, "1111 110x xxxx 1xxx", OPCODE_x_sbrc, "sbrc", "Rr, b", "", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfe08, 1, "1111 111x xxxx 1xxx", OPCODE_x_sbrs, "sbrs", "Rr, b", "", "", "", "", "", "", "", "", ""}, }; From 483cc07d9d5361e2a1b123b1f836c3d1cc6d9228 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 01:35:49 +0100 Subject: [PATCH 283/422] Rename _ld[1-3]/_st[1-3] to _ldx[1-3]/_stx[1-3] --- src/disasm.c | 14 +++++++------- src/disasm_callbacks_assembly.c | 12 ++++++------ src/disasm_callbacks_assembly.h | 12 ++++++------ src/disasm_callbacks_pseudocode.c | 2 +- src/disasm_callbacks_pseudocode.h | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 42cfd8b1..0fa47056 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -452,9 +452,9 @@ int disasm(const char *Bitstream, int Read, int addr) { Register_Opcode(in_Callback, "1011 0AAd dddd AAAA", OPCODE_in); Register_Opcode(inc_Callback, "1001 010d dddd 0011", OPCODE_inc); Register_Opcode(jmp_Callback, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp); - Register_Opcode(ld1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); - Register_Opcode(ld2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); - Register_Opcode(ld3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); + Register_Opcode(ldx1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); + Register_Opcode(ldx2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); + Register_Opcode(ldx3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); Register_Opcode(ldy1_Callback, "1000 000d dddd 1000", OPCODE_ld_4); Register_Opcode(ldy2_Callback, "1001 000d dddd 1001", OPCODE_ld_5); Register_Opcode(ldy3_Callback, "1001 000d dddd 1010", OPCODE_ld_6); @@ -508,9 +508,9 @@ int disasm(const char *Bitstream, int Read, int addr) { Register_Opcode(sez_Callback, "1001 0100 0001 1000", OPCODE_sez); Register_Opcode(sleep_Callback, "1001 0101 1000 1000", OPCODE_sleep); Register_Opcode(spm_Callback, "1001 0101 1110 1000", OPCODE_spm); - Register_Opcode(st1_Callback, "1001 001r rrrr 1100", OPCODE_st_1); - Register_Opcode(st2_Callback, "1001 001r rrrr 1101", OPCODE_st_2); - Register_Opcode(st3_Callback, "1001 001r rrrr 1110", OPCODE_st_3); + Register_Opcode(stx1_Callback, "1001 001r rrrr 1100", OPCODE_st_1); + Register_Opcode(stx2_Callback, "1001 001r rrrr 1101", OPCODE_st_2); + Register_Opcode(stx3_Callback, "1001 001r rrrr 1110", OPCODE_st_3); Register_Opcode(sty1_Callback, "1000 001r rrrr 1000", OPCODE_st_4); Register_Opcode(sty2_Callback, "1001 001r rrrr 1001", OPCODE_st_5); Register_Opcode(sty3_Callback, "1001 001r rrrr 1010", OPCODE_st_6); @@ -590,7 +590,7 @@ int disasm(const char *Bitstream, int Read, int addr) { Supersede_Opcode(movw_Callback_PC, OPCODE_movw); Supersede_Opcode(adiw_Callback_PC, OPCODE_adiw); Supersede_Opcode(lpm1_Callback_PC, OPCODE_lpm_1); - Supersede_Opcode(st2_Callback_PC, OPCODE_st_2); + Supersede_Opcode(stx2_Callback_PC, OPCODE_st_2); } qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index b00ef89b..80c78aa9 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -487,15 +487,15 @@ CALLBACK(jmp_Callback) { Register_JumpCall(Position, Pos, mnemo, 0); } -CALLBACK(ld1_Callback) { +CALLBACK(ldx1_Callback) { snprintf(cx->dis_code, 255, "%-7s r%d, X", avr_opcodes[mnemo].opcode, Rd); } -CALLBACK(ld2_Callback) { +CALLBACK(ldx2_Callback) { snprintf(cx->dis_code, 255, "%-7s r%d, X+", avr_opcodes[mnemo].opcode, Rd); } -CALLBACK(ld3_Callback) { +CALLBACK(ldx3_Callback) { snprintf(cx->dis_code, 255, "%-7s r%d, -X", avr_opcodes[mnemo].opcode, Rd); } @@ -773,15 +773,15 @@ CALLBACK(spm_Callback) { Operation_Simple(mnemo); } -CALLBACK(st1_Callback) { +CALLBACK(stx1_Callback) { snprintf(cx->dis_code, 255, "%-7s X, r%d", avr_opcodes[mnemo].opcode, Rr); } -CALLBACK(st2_Callback) { +CALLBACK(stx2_Callback) { snprintf(cx->dis_code, 255, "%-7s X+, r%d", avr_opcodes[mnemo].opcode, Rr); } -CALLBACK(st3_Callback) { +CALLBACK(stx3_Callback) { snprintf(cx->dis_code, 255, "%-7s -X, r%d", avr_opcodes[mnemo].opcode, Rr); } diff --git a/src/disasm_callbacks_assembly.h b/src/disasm_callbacks_assembly.h index a9923f33..2ef9a5d8 100644 --- a/src/disasm_callbacks_assembly.h +++ b/src/disasm_callbacks_assembly.h @@ -101,9 +101,9 @@ void ijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void in_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void inc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void jmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ld1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ld2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ld3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldy1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldy2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldy3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); @@ -155,9 +155,9 @@ void sev_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sez_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sleep_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void spm_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void st1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void st2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void st3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sty1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sty2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sty3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); diff --git a/src/disasm_callbacks_pseudocode.c b/src/disasm_callbacks_pseudocode.c index a7842113..11dce0c7 100644 --- a/src/disasm_callbacks_pseudocode.c +++ b/src/disasm_callbacks_pseudocode.c @@ -667,6 +667,6 @@ CALLBACK(lpm1_Callback_PC) { snprintf(cx->dis_code, 255, "r0 = Flash[r30:r31];"); } -CALLBACK(st2_Callback_PC) { +CALLBACK(stx2_Callback_PC) { snprintf(cx->dis_code, 255, "Flash[[r26:r27]++] = r%d;", Rr); } diff --git a/src/disasm_callbacks_pseudocode.h b/src/disasm_callbacks_pseudocode.h index 0d3fc92d..6acf2ada 100644 --- a/src/disasm_callbacks_pseudocode.h +++ b/src/disasm_callbacks_pseudocode.h @@ -103,4 +103,4 @@ void ser_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); void adiw_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); void movw_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); void lpm1_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void st2_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); +void stx2_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); From 3bc3c0f4d921b16786711915ffe6de3bd1dc8c77 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 01:39:18 +0100 Subject: [PATCH 284/422] Utilize flash size for disasm --- src/disasm_jumpcall.c | 12 +++++++----- src/term.c | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 116076ed..074381e5 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -49,11 +49,13 @@ void Display_JumpCalls() { } int FixTargetAddress(int Address) { - if(cx->dis_opts.FlashSize) { - Address %= cx->dis_opts.FlashSize; - if(Address < 0) { - Address += cx->dis_opts.FlashSize; - } + int flashsz = cx->dis_opts.FlashSize; + + // Flash size is a power of two: flash wraps round + if(flashsz > 0 && !(flashsz & (flashsz - 1))) { + Address %= flashsz; + if(Address < 0) + Address += flashsz; } return Address; } diff --git a/src/term.c b/src/term.c index 8999548b..59899502 100644 --- a/src/term.c +++ b/src/term.c @@ -422,6 +422,8 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_initopts++; } cx->dis_opts.Pass = 1; + if((mem = avr_locate_flash(p))) + cx->dis_opts.FlashSize = mem->size; for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; From f78b40735848404c2f4bab5a3c036881be26e153 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 15:18:49 +0100 Subject: [PATCH 285/422] Model availability of opcodes for parts --- src/avr_opcodes.c | 328 +++++++++++++++++++++++----------------------- src/libavrdude.h | 39 +++++- 2 files changed, 202 insertions(+), 165 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index dc5591ab..f5e19e7f 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -22,178 +22,178 @@ const AVR_opcode_data avr_opcodes[164] = { // Arithmetic and Logic Instructions - {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OPCODE_add, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", "2", "2", "2", "n/a", "(1)", "d in {24, 26, 28, 30}"}, - {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", "d=16..31"}, - {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", "2", "2", "2", "n/a", "(1)", "d in {24, 26, 28, 30}"}, - {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", "1", "1", "1", "1", "", "d = 16..31"}, - {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", "1", "1", "1", "1", "", "alias for ORI Rd, K"}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", "1", "1", "1", "1", "", "alias for ANDI Rd, (0xFF - K)"}, - {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", "1", "1", "1", "1", "", "alias for AND Rd, Rd"}, - {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", "1", "1", "1", "1", "", "alias for EOR Rd, Rd"}, - {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", "1", "1", "1", "1", "", "alias for LDI Rd, 0xFF"}, - {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", "2", "2", "2", "n/a", "(1)", ""}, - {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", "2", "2", "2", "n/a", "(1)", "d, r=16..31"}, - {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", "2", "2", "2", "n/a", "(1)", "d, r=16..23"}, - {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, - {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, - {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", "2", "2", "2", "n/a", "(1) ", "r, d = 16..23"}, - {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", "n/a", "1/2", "n/a", "n/a", "", ""}, + {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OP_AVR1, OPCODE_add, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, + {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OP_AVR1, OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, + {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OP_AVR2nRC, OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", "2", "2", "2", "n/a", "d in {24, 26, 28, 30}"}, + {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OP_AVR1, OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, + {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OP_AVR1, OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, + {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OP_AVR1, OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, + {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OP_AVR1, OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "d=16..31"}, + {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OP_AVR2nRC, OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", "2", "2", "2", "n/a", "d in {24, 26, 28, 30}"}, + {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OP_AVR1, OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", "1", "1", "1", "1", ""}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", "1", "1", "1", "1", "d = 16..31"}, + {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OP_AVR1, OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", "1", "1", "1", "1", ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", "1", "1", "1", "1", ""}, + {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OP_AVR1, OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", "1", "1", "1", "1", ""}, + {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", "1", "1", "1", "1", ""}, + {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", "1", "1", "1", "1", "alias for ORI Rd, K"}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", "1", "1", "1", "1", "alias for ANDI Rd, (0xFF - K)"}, + {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", "1", "1", "1", "1", ""}, + {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", "1", "1", "1", "1", ""}, + {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", "1", "1", "1", "1", "alias for AND Rd, Rd"}, + {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", "1", "1", "1", "1", "alias for EOR Rd, Rd"}, + {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", "1", "1", "1", "1", "alias for LDI Rd, 0xFF"}, + {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", "2", "2", "2", "n/a", ""}, + {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", "2", "2", "2", "n/a", "d, r=16..31"}, + {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", "2", "2", "2", "n/a", "d, r=16..23"}, + {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OP_AVR4, OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", "2", "2", "2", "n/a", "r, d = 16..23"}, + {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OP_AVR4, OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", "2", "2", "2", "n/a", "r, d = 16..23"}, + {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", "2", "2", "2", "n/a", "r, d = 16..23"}, + {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OP_AVR_XM, OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", "n/a", "1/2", "n/a", "n/a", ""}, // Branch Instructions - {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", "2", "2", "2", "2", "", ""}, - {0xffff, 0x9409, 1, "1001 0100 0000 1001", OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "2", "2", "2", "2", "(1)", ""}, - {0xffff, 0x9419, 1, "1001 0100 0001 1001", OPCODE_eijmp, "eijmp", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "2", "2", "2", "n/a", "(1)", ""}, - {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", "3", "3", "3", "n/a", "(1)", ""}, - {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", "3/4", "2/3", "2/3", "3", "", ""}, - {0xffff, 0x9509, 1, "1001 0101 0000 1001", OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "3/4", "2/3", "2/3", "3", "(1)", ""}, - {0xffff, 0x9519, 1, "1001 0101 0001 1001", OPCODE_eicall, "eicall", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "4", "3", "3", "n/a", "(1)", ""}, - {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", "4/5", "3/4", "3/4", "n/a", "(1)", ""}, - {0xffff, 0x9508, 1, "1001 0101 0000 1000", OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", "4/5", "4/5", "4/5", "6", "", ""}, - {0xffff, 0x9518, 1, "1001 0101 0001 1000", OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", "4/5", "4/5", "4/5", "6", "", ""}, - {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OPCODE_cpse, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, - {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OPCODE_cp, "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OPCODE_cpc, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", "1", "1", "1", "1", "", ""}, - {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OPCODE_cpi, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", "1", "1", "1", "1", "", "d = 16..31"}, - {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OPCODE_sbrc, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, - {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", "", ""}, - {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", "", ""}, - {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", "", ""}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 1, k (Z Zero)"}, - {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 2, k (N Negative)"}, - {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 4, k (S Sign)"}, - {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 5, k (H Half carry)"}, - {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 6, k (T Transfer bit)"}, - {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBS 7, k (I Interrupt enable)"}, - {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", ""}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 1, k (Z Zero)"}, - {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 2, k (N Negative)"}, - {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 4, k (S Sign)"}, - {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 5, k (H Half carry)"}, - {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 6, k (T Transfer bit)"}, - {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", "alias for BRBC 7, k (I Interrupt enable)"}, - {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "", ""}, + {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OP_AVR1, OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", "2", "2", "2", "2", ""}, + {0xffff, 0x9409, 1, "1001 0100 0000 1001", OP_AVR2, OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "2", "2", "2", "2", ""}, + {0xffff, 0x9419, 1, "1001 0100 0001 1001", OP_AVR_XL, OPCODE_eijmp, "eijmp", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "2", "2", "2", "n/a", ""}, + {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", "3", "3", "3", "n/a", ""}, + {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OP_AVR1, OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", "3/4", "2/3", "2/3", "3", ""}, + {0xffff, 0x9509, 1, "1001 0101 0000 1001", OP_AVR2, OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "3/4", "2/3", "2/3", "3", ""}, + {0xffff, 0x9519, 1, "1001 0101 0001 1001", OP_AVR_XL, OPCODE_eicall, "eicall", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "4", "3", "3", "n/a", ""}, + {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", "4/5", "3/4", "3/4", "n/a", ""}, + {0xffff, 0x9508, 1, "1001 0101 0000 1000", OP_AVR1, OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", "4/5", "4/5", "4/5", "6", ""}, + {0xffff, 0x9518, 1, "1001 0101 0001 1000", OP_AVR1, OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", "4/5", "4/5", "4/5", "6", ""}, + {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OP_AVR1, OPCODE_cpse, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", ""}, + {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OP_AVR1, OPCODE_cp, "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, + {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OP_AVR1, OPCODE_cpc, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, + {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OP_AVR1, OPCODE_cpi, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", "1", "1", "1", "1", "d = 16..31"}, + {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OP_AVR1, OPCODE_sbrc, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", ""}, + {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OP_AVR1, OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", ""}, + {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OP_AVR1, OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", ""}, + {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OP_AVR1, OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", ""}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OP_AVR1, OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 1, k (Z Zero)"}, + {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OP_AVR1, OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 2, k (N Negative)"}, + {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OP_AVR1, OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OP_AVR1, OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 4, k (S Sign)"}, + {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OP_AVR1, OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 5, k (H Half carry)"}, + {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OP_AVR1, OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 6, k (T Transfer bit)"}, + {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OP_AVR1, OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 7, k (I Interrupt enable)"}, + {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OP_AVR1, OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", ""}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OP_AVR1, OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 1, k (Z Zero)"}, + {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OP_AVR1, OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 2, k (N Negative)"}, + {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OP_AVR1, OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OP_AVR1, OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 4, k (S Sign)"}, + {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OP_AVR1, OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 5, k (H Half carry)"}, + {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OP_AVR1, OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 6, k (T Transfer bit)"}, + {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OP_AVR1, OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 7, k (I Interrupt enable)"}, + {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OP_AVR1, OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", ""}, // Data Transfer Instructions - {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", "1", "1", "1", "1", "", ""}, - {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", "1", "1", "1", "n/a", "(1)", ""}, - {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", "1", "1", "1", "1", "", "d=16..31"}, - {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "2", "3", "3", "2", "(1)", ""}, - {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "n/a", "n/a", "n/a", "2", "(1)", "attiny only"}, - {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", "2", "2", "2", "1/2", "(2)", ""}, - {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", "2", "2", "2", "2/3", "(2)", ""}, - {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", "2", "3", "2", "2/3", "(2)", ""}, - {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", "2", "2", "2", "1/2", "(2)", "alias for LDD Rd, Y+0"}, - {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", "2", "2", "2", "2/3", "(2)", ""}, - {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", "2", "3", "2", "2/3", "(2)", ""}, - {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", "2", "3", "2", "n/a", "(1)", ""}, - {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", "2", "2", "2", "1/2", "(2)", "alias for LDD Rd,Z+0"}, - {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", "2", "2", "2", "2/3", "(2)", ""}, - {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", "2", "3", "2", "2/3", "(2)", ""}, - {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", "2", "3", "2", "n/a", "(1)", ""}, - {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "2", "2", "2", "1", "(1)", ""}, - {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "n/a", "n/a", "n/a", "1", "(1)", "attiny only"}, - {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", "2", "1", "1", "1", "(2)", ""}, - {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", "2", "1", "1", "1", "(2)", ""}, - {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", "2", "2", "1", "1", "(2)", ""}, - {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", "2", "1", "1", "1", "(2)", "alias for STD Y+0, Rr"}, - {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", "2", "1", "1", "1", "(2)", ""}, - {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", "2", "2", "1", "1", "(2)", ""}, - {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", "2", "2", "1", "n/a", "(1)", ""}, - {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", "2", "1", "1", "1", "(2)", "alias for STD Z+0, Rr"}, - {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", "2", "1", "1", "1", "(2)", ""}, - {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", "2", "2", "1", "1", "(2)", ""}, - {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", "2", "2", "1", "n/a", "(1)", ""}, - {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OPCODE_lpm_1, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, - {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OPCODE_lpm_2, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, - {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OPCODE_lpm_3, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", "(1)(2)", ""}, - {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OPCODE_elpm_1, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", "(1)", ""}, - {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OPCODE_elpm_2, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", "(1)", ""}, - {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", "(1)", ""}, - {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", "-", "-", "-", "-", "(1)", ""}, - {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", "n/a", "-", "-", "n/a", "(1)", ""}, - {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OPCODE_in, "in", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", "1", "1", "1", "1", "", ""}, - {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", "2", "1", "1", "1", "(1)", ""}, - {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", "2", "2", "2", "3", "(1)", ""}, - {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, - {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, - {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, - {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", "", ""}, + {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OP_AVR1, OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", "1", "1", "1", "1", ""}, + {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", "1", "1", "1", "n/a", ""}, + {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", "1", "1", "1", "1", "d=16..31"}, + {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "2", "3", "3", "2", ""}, + {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "n/a", "n/a", "n/a", "2", "AVRrc only (TPI parts)"}, + {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OP_AVR2, OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", "2", "2", "2", "1/2", ""}, + {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OP_AVR2, OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", "2", "2", "2", "2/3", ""}, + {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OP_AVR2, OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", "2", "3", "2", "2/3", ""}, + {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OP_AVR2, OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", "2", "2", "2", "1/2", "alias for LDD Rd, Y+0"}, + {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OP_AVR2, OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", "2", "2", "2", "2/3", ""}, + {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OP_AVR2, OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", "2", "3", "2", "2/3", ""}, + {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OP_AVR2nRC, OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", "2", "3", "2", "n/a", ""}, + {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OP_AVR1, OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", "2", "2", "2", "1/2", "alias for LDD Rd,Z+0"}, + {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OP_AVR1, OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", "2", "2", "2", "2/3", ""}, + {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OP_AVR1, OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", "2", "3", "2", "2/3", ""}, + {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OP_AVR2nRC, OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", "2", "3", "2", "n/a", ""}, + {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "2", "2", "2", "1", ""}, + {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OP_AVR_RC, OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "n/a", "n/a", "n/a", "1", "AVRrc only (TPI parts)"}, + {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OP_AVR2, OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", "2", "1", "1", "1", ""}, + {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OP_AVR2, OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", "2", "1", "1", "1", ""}, + {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OP_AVR2, OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", "2", "2", "1", "1", ""}, + {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OP_AVR2, OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", "2", "1", "1", "1", "alias for STD Y+0, Rr"}, + {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OP_AVR2, OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", "2", "1", "1", "1", ""}, + {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OP_AVR2, OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", "2", "2", "1", "1", ""}, + {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OP_AVR2nRC, OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", "2", "2", "1", "n/a", ""}, + {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OP_AVR1, OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", "2", "1", "1", "1", "alias for STD Z+0, Rr"}, + {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OP_AVR1, OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", "2", "1", "1", "1", ""}, + {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OP_AVR1, OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", "2", "2", "1", "1", ""}, + {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OP_AVR2nRC, OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", "2", "2", "1", "n/a", ""}, + {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OP_AVR1nRC, OPCODE_lpm_1, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", "3", "3", "3", "n/a", ""}, + {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OP_AVR25, OPCODE_lpm_2, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", "3", "3", "3", "n/a", ""}, + {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OP_AVR25, OPCODE_lpm_3, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", ""}, + {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OP_AVR_L, OPCODE_elpm_1, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", ""}, + {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OP_AVR_L, OPCODE_elpm_2, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", ""}, + {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OP_AVR_L, OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", ""}, + {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OP_AVR25, OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", "-", "-", "-", "-", ""}, + {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OP_AVR_XTM, OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", "n/a", "-", "-", "n/a", ""}, + {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", "1", "1", "1", "1", ""}, + {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", "1", "1", "1", "1", ""}, + {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", "2", "1", "1", "1", ""}, + {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", "2", "2", "2", "3", ""}, + {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", ""}, + {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", ""}, + {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", ""}, + {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", ""}, // Bit and Bit-test Instructions - {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", "1", "1", "1", "1", "", "alias for ADD Rd, Rd"}, - {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, - {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", "1", "1", "1", "1", "", "alias for ADC Rd, Rd"}, - {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", "", ""}, - {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", "1", "1", "1", "1", "", ""}, - {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OPCODE_bset, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", "1", "1", "1", "1", "", ""}, - {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", "1", "1", "1", "1", "", "s = 0-7 = C,Z,N,V,S,H,T,I"}, - {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", "2", "1", "1", "1", "", ""}, - {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", "2", "1", "1", "1", "", ""}, - {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OPCODE_bst, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", "1", "1", "1", "1", "", ""}, - {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", "1", "1", "1", "1", "", ""}, - {0xffff, 0x9408, 1, "1001 0100 0000 1000", OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", "1", "1", "1", "1", "", "alias for BSET 0"}, - {0xffff, 0x9488, 1, "1001 0100 1000 1000", OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", "1", "1", "1", "1", "", "alias for BCLR 0"}, - {0xffff, 0x9428, 1, "1001 0100 0010 1000", OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", "1", "1", "1", "1", "", "alias for BSET 2"}, - {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", "1", "1", "1", "1", "", "alias for BCLR 2"}, - {0xffff, 0x9418, 1, "1001 0100 0001 1000", OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", "1", "1", "1", "1", "", "alias for BSET 1"}, - {0xffff, 0x9498, 1, "1001 0100 1001 1000", OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", "1", "1", "1", "1", "", "alias for BCLR 1"}, - {0xffff, 0x9478, 1, "1001 0100 0111 1000", OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", "1", "1", "1", "1", "", "alias for BSET 7"}, - {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", "1", "1", "1", "1", "", "alias for BCLR 7"}, - {0xffff, 0x9448, 1, "1001 0100 0100 1000", OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", "1", "1", "1", "1", "", "alias for BSET 4"}, - {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", "1", "1", "1", "1", "", "alias for BCLR 4"}, - {0xffff, 0x9438, 1, "1001 0100 0011 1000", OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", "1", "1", "1", "1", "", "alias for BSET 3"}, - {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", "1", "1", "1", "1", "", "alias for BCLR 3"}, - {0xffff, 0x9468, 1, "1001 0100 0110 1000", OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", "1", "1", "1", "1", "", "alias for BSET 6"}, - {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", "1", "1", "1", "1", "", "alias for BCLR 6"}, - {0xffff, 0x9458, 1, "1001 0100 0101 1000", OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", "1", "1", "1", "1", "", "alias for BSET 5"}, - {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", "1", "1", "1", "1", "", "alias for BCLR 5"}, + {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", "1", "1", "1", "1", "alias for ADD Rd, Rd"}, + {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OP_AVR1, OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", ""}, + {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", "1", "1", "1", "1", "alias for ADC Rd, Rd"}, + {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OP_AVR1, OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", ""}, + {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OP_AVR1, OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", ""}, + {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OP_AVR1, OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", "1", "1", "1", "1", ""}, + {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OP_AVR1, OPCODE_bset, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", "1", "1", "1", "1", ""}, + {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OP_AVR1, OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", "1", "1", "1", "1", "s = 0-7 = C,Z,N,V,S,H,T,I"}, + {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OP_AVR1, OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", "2", "1", "1", "1", ""}, + {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OP_AVR1, OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", "2", "1", "1", "1", ""}, + {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OP_AVR1, OPCODE_bst, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", "1", "1", "1", "1", ""}, + {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OP_AVR1, OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", "1", "1", "1", "1", ""}, + {0xffff, 0x9408, 1, "1001 0100 0000 1000", OP_AVR1, OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", "1", "1", "1", "1", "alias for BSET 0"}, + {0xffff, 0x9488, 1, "1001 0100 1000 1000", OP_AVR1, OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", "1", "1", "1", "1", "alias for BCLR 0"}, + {0xffff, 0x9428, 1, "1001 0100 0010 1000", OP_AVR1, OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", "1", "1", "1", "1", "alias for BSET 2"}, + {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OP_AVR1, OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", "1", "1", "1", "1", "alias for BCLR 2"}, + {0xffff, 0x9418, 1, "1001 0100 0001 1000", OP_AVR1, OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", "1", "1", "1", "1", "alias for BSET 1"}, + {0xffff, 0x9498, 1, "1001 0100 1001 1000", OP_AVR1, OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", "1", "1", "1", "1", "alias for BCLR 1"}, + {0xffff, 0x9478, 1, "1001 0100 0111 1000", OP_AVR1, OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", "1", "1", "1", "1", "alias for BSET 7"}, + {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OP_AVR1, OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", "1", "1", "1", "1", "alias for BCLR 7"}, + {0xffff, 0x9448, 1, "1001 0100 0100 1000", OP_AVR1, OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", "1", "1", "1", "1", "alias for BSET 4"}, + {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OP_AVR1, OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", "1", "1", "1", "1", "alias for BCLR 4"}, + {0xffff, 0x9438, 1, "1001 0100 0011 1000", OP_AVR1, OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", "1", "1", "1", "1", "alias for BSET 3"}, + {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OP_AVR1, OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", "1", "1", "1", "1", "alias for BCLR 3"}, + {0xffff, 0x9468, 1, "1001 0100 0110 1000", OP_AVR1, OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", "1", "1", "1", "1", "alias for BSET 6"}, + {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OP_AVR1, OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", "1", "1", "1", "1", "alias for BCLR 6"}, + {0xffff, 0x9458, 1, "1001 0100 0101 1000", OP_AVR1, OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", "1", "1", "1", "1", "alias for BSET 5"}, + {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OP_AVR1, OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", "1", "1", "1", "1", "alias for BCLR 5"}, // MCU Control Instructions - {0xffff, 0x9598, 1, "1001 0101 1001 1000", OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", "-", "-", "-", "-", "(1)", ""}, - {0xffff, 0x0000, 1, "0000 0000 0000 0000", OPCODE_nop, "nop", "-", "No Operation", "-", "None", "1", "1", "1", "1", "", ""}, - {0xffff, 0x9588, 1, "1001 0101 1000 1000", OPCODE_sleep, "sleep", "-", "Sleep", "(cf documentation)", "None", "-", "-", "-", "-", "", ""}, - {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", "1", "1", "1", "1", "", ""}, + {0xffff, 0x9598, 1, "1001 0101 1001 1000", OP_AVR1, OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", "-", "-", "-", "-", "not available on all parts"}, + {0xffff, 0x0000, 1, "0000 0000 0000 0000", OP_AVR1, OPCODE_nop, "nop", "-", "No Operation", "-", "None", "1", "1", "1", "1", ""}, + {0xffff, 0x9588, 1, "1001 0101 1000 1000", OP_AVR1, OPCODE_sleep, "sleep", "-", "Sleep", "(cf documentation)", "None", "-", "-", "-", "-", ""}, + {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OP_AVR1, OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", "1", "1", "1", "1", ""}, // Unallocated codes - {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OPCODE_x_nop_1, "nop", "", "", "", "", "", "", "", "", "", "xxxx xxxx != 0000 0000"}, - {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OPCODE_x_nop_2, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OPCODE_x_nop_3, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OPCODE_x_nop_4, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OPCODE_x_nop_5, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OPCODE_x_nop_6, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OPCODE_x_nop_7, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OPCODE_x_icall, "icall", "", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OPCODE_x_eicall, "eicall", "", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OPCODE_x_ret, "ret", "", "", "", "", "", "", "", "", "", "xx != 00"}, - {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OPCODE_x_reti, "reti", "", "", "", "", "", "", "", "", "", "xx != 00"}, - {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OPCODE_x_nop_8, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OPCODE_x_nop_9, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OPCODE_x_nop_a, "nop", "", "", "", "", "", "", "", "", "", ""}, - {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OPCODE_x_ijmp, "ijmp", "", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OPCODE_x_eijmp, "eijmp", "", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xfe08, 0xf808, 1, "1111 100x xxxx 1xxx", OPCODE_x_bld, "bld", "Rd, b", "", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfa08, 1, "1111 101x xxxx 1xxx", OPCODE_x_bst, "bst", "Rd, b", "", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfc08, 1, "1111 110x xxxx 1xxx", OPCODE_x_sbrc, "sbrc", "Rr, b", "", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfe08, 1, "1111 111x xxxx 1xxx", OPCODE_x_sbrs, "sbrs", "Rr, b", "", "", "", "", "", "", "", "", ""}, + {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OP_AVR1, OPCODE_x_nop_1, "nop", "", "", "", "", "", "", "", "", "xxxx xxxx != 0000 0000"}, + {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OP_AVR1, OPCODE_x_nop_2, "nop", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OP_AVR1, OPCODE_x_nop_3, "nop", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OP_AVR1, OPCODE_x_nop_4, "nop", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OP_AVR1, OPCODE_x_nop_5, "nop", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR1, OPCODE_x_nop_6, "nop", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR1, OPCODE_x_nop_7, "nop", "", "", "", "", "", "", "", "", ""}, + {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR2, OPCODE_x_icall, "icall", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_XL, OPCODE_x_eicall, "eicall", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR1, OPCODE_x_ret, "ret", "", "", "", "", "", "", "", "", "xx != 00"}, + {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR1, OPCODE_x_reti, "reti", "", "", "", "", "", "", "", "", "xx != 00"}, + {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR1, OPCODE_x_nop_8, "nop", "", "", "", "", "", "", "", "", ""}, + {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR1, OPCODE_x_nop_9, "nop", "", "", "", "", "", "", "", "", ""}, + {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR1, OPCODE_x_nop_a, "nop", "", "", "", "", "", "", "", "", ""}, + {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR2, OPCODE_x_ijmp, "ijmp", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_XL, OPCODE_x_eijmp, "eijmp", "", "", "", "", "", "", "", "", "xxx != 000"}, + {0xfe08, 0xf808, 1, "1111 100x xxxx 1xxx", OP_AVR1, OPCODE_x_bld, "bld", "Rd, b", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfa08, 1, "1111 101x xxxx 1xxx", OP_AVR1, OPCODE_x_bst, "bst", "Rd, b", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfc08, 1, "1111 110x xxxx 1xxx", OP_AVR1, OPCODE_x_sbrc, "sbrc", "Rr, b", "", "", "", "", "", "", "", ""}, + {0xfe08, 0xfe08, 1, "1111 111x xxxx 1xxx", OP_AVR1, OPCODE_x_sbrs, "sbrs", "Rr, b", "", "", "", "", "", "", "", ""}, }; diff --git a/src/libavrdude.h b/src/libavrdude.h index 707b6eb5..1add10a7 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1445,6 +1445,7 @@ typedef struct { #define STR_XINT32 STR_4 #define STR_XINT64 STR_8 + typedef struct { char Show_Addresses; char Show_Opcodes; @@ -1511,10 +1512,46 @@ typedef struct { } Disasm_opcode; +typedef enum { + OP_AVR_RC = 1, // Reduced-core Tiny only (128 byte STS/LDS) + OP_AVR1 = 2, // All AVR can run this OPCODE + OP_AVR1nRC = 4, // All except reduced-core Tiny (TPI) and AT90S1200 + OP_AVR2 = 8, // AVR with archnum 2 and above + OP_AVR2nRC = 16, // AVR with archnum 2+ but not reduced-core Tiny + OP_AVR25 = 32, // AVR with archnum 25 and above + OP_AVR_M = 64, // AVR with flash > 8 kB or archnum 3+ (JMP, CALL) + OP_AVR4 = 128, // AVR with archnum 4 and above + OP_AVR_L = 256, // AVR with flash > 64 kB (ELMP) + OP_AVR_XL = 512, // AVR with flash > 128 kB (EIJMP, EICALL) + OP_AVR_XM = 1024, // XMEGA only (DES, XCH, LAC, LAS, LAT) + OP_AVR_XTM = 2048, // XMEGA and UPDI only (SPM Z+) +} AVR_archlevel; + +/* + * Approximation(!) of which opcodes a part may have given its archnum + * - Take with a pinch of salt + * - For OP_AVR_XT and OP_AVR_XM one needs to add in OP_AVR_L/ OP_AVR_XL + * depending on flash size + */ +#define PART_AVR1 OP_AVR1 +#define PART_AVR_RC (OP_AVR1|OP_AVR2|OP_AVR_RC) +#define PART_AVR2 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC) +#define PART_AVR25 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25) +#define PART_AVR3 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR_M) +#define PART_AVR31 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR_M) +#define PART_AVR4 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M) +#define PART_AVR5 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M) +#define PART_AVR51 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_L) +#define PART_AVR6 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_L|OP_AVR_XL) +#define PART_AVR_XT (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_XTM) +#define PART_AVR_XM (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_XM|OP_AVR_XTM) + + typedef struct { int mask, value, nwords; const char *opcode_bits; // Eg, "0000 11rd dddd rrrr" + AVR_archlevel avrlevel; // Eg, OP_AVR1 AVR_opcode mnemo; // OPCODE_add, ... const char *opcode, // "add" @@ -1526,7 +1563,7 @@ typedef struct { *clocks_xm, // Timing for AVRxm (XMEGA) *clocks_xt, // Timing for AVRxt (modern UPDI) *clocks_rc, // Timing for AVRrc (reduced core) - *note, *remarks; + *remarks; } AVR_opcode_data; extern const AVR_opcode_data avr_opcodes[164]; From be125ee0ce9f55898def23fe0a8845bf5becfd45 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 15:37:42 +0100 Subject: [PATCH 286/422] Provide avr-gcc's archnum in avrdude.conf --- src/avrdude.conf.in | 156 +++++++++++++++++++++++++++++++++++++++++++ src/config.c | 1 + src/developer_opts.c | 1 + src/doc/avrdude.texi | 1 + src/lexer.l | 2 +- src/libavrdude.h | 1 + 6 files changed, 161 insertions(+), 1 deletion(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 8495e72d..51974300 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -107,6 +107,7 @@ avrdude_conf_version = "@AVRDUDE_FULL_VERSION@"; # family_id = ; # quoted string, eg, "megaAVR" or "tinyAVR" # prog_modes = PM_ {| PM_} # interfaces, eg, PM_SPM|PM_ISP|PM_HVPP|PM_debugWIRE # mcuid = ; # unique id in 0..2039 for 8-bit AVRs +# archnum = ; # avr-gcc architecture number for the part # n_interrupts = ; # number of interrupts, used for vector bootloaders # n_page_erase = ; # if set, number of pages erased during SPM erase # n_boot_sections = ; # Number of boot sections @@ -3430,6 +3431,7 @@ part # .reduced_core_tiny desc = "Common values for reduced core tinys"; id = ".reduced_core_tiny"; prog_modes = PM_TPI; + archnum = 100; memory "fuse" size = 1; @@ -3749,6 +3751,7 @@ part # .classic-nocal desc = "Common values for classic parts without calibration mem"; id = ".classic-nocal"; prog_modes = PM_SPM | PM_ISP; + archnum = 2; memory "lock" size = 1; @@ -3829,6 +3832,7 @@ part parent ".classic" # t11 "ATtiny11L-2SU: SOIC8, Fmax=2 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_HVSP; mcuid = 8; + archnum = 1; n_interrupts = 5; stk500_devcode = 0x11; chip_erase_delay = 20000; @@ -4204,6 +4208,7 @@ part parent ".classic" # t13 "ATtiny13V-10SUR: SOIC8, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; mcuid = 10; + archnum = 25; n_interrupts = 10; stk500_devcode = 0x14; chip_erase_delay = 4000; @@ -4681,6 +4686,7 @@ part parent ".classic" # t2313 "ATtiny2313V-10SUR: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 42; + archnum = 25; n_interrupts = 19; stk500_devcode = 0x23; # Use the ATtiny26 devcode: @@ -4905,6 +4911,7 @@ part parent ".classic" # t24 "ATtiny24V-10SSUR: SOIC14N, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; mcuid = 14; + archnum = 25; n_interrupts = 17; # no STK500 devcode in XML file, use the ATtiny45 one stk500_devcode = 0x14; @@ -5216,6 +5223,7 @@ part parent ".classic" # t441 "ATtiny441-SSUR: SOIC14, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; mcuid = 32; + archnum = 25; n_interrupts = 30; n_page_erase = 4; stk500_devcode = 0x14; @@ -5512,6 +5520,7 @@ part parent ".classic" # t261 "ATtiny261V-10SU: SOIC20, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 30; + archnum = 25; n_interrupts = 19; chip_erase_delay = 4000; pagel = 0xb3; @@ -5808,6 +5817,7 @@ part parent ".classic" # t48 "ATtiny48-PU: PDIP28, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 23; + archnum = 25; n_interrupts = 20; stk500_devcode = 0x73; chip_erase_delay = 15000; @@ -5981,6 +5991,7 @@ part parent ".classic" # t28 "ATtiny28V-1PU: PDIP28, Fmax=1.2 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_HVPP; mcuid = 18; + archnum = 1; n_interrupts = 6; stk500_devcode = 0x22; avr910_devcode = 0x5c; @@ -6062,6 +6073,7 @@ part parent ".classic" # t43u "ATtiny43U-SUR: SOIC20, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 19; + archnum = 25; n_interrupts = 16; stk500_devcode = 0x14; # avr910_devcode = ?; @@ -6198,6 +6210,7 @@ part parent ".classic" # t828 "ATtiny828-MUR: VQFN32, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 35; + archnum = 25; n_interrupts = 26; n_boot_sections = 4; boot_section_size = 256; @@ -6345,6 +6358,7 @@ part parent ".classic" # t87 "ATtiny87-XUR: TSSOP20, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 27; + archnum = 25; n_interrupts = 20; # no STK500 devcode in XML file, use the ATtiny45 one stk500_devcode = 0x14; @@ -6480,6 +6494,7 @@ part parent "t87" # t167 "ATtiny167-XU: TSSOP20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATtiny167-XUR: TSSOP20, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 29; + archnum = 35; signature = 0x1e 0x94 0x87; memory "flash" @@ -6506,6 +6521,7 @@ part parent ".classic" # t1634 "ATtiny1634-SUR: SOIC20, Fmax=12 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 40; + archnum = 35; n_interrupts = 28; n_page_erase = 4; stk500_devcode = 0x86; @@ -6655,6 +6671,7 @@ part parent ".classic" # c32 "AT90CAN32-16MUR: VQFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 171; + archnum = 5; n_interrupts = 37; n_boot_sections = 4; boot_section_size = 1024; @@ -6813,6 +6830,7 @@ part parent "c32" # c128 "AT90CAN128-16MUR: QFN64, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; mcuid = 176; + archnum = 51; # avr910_devcode = 0x43; signature = 0x1e 0x97 0x81; rampz = 0x3b; @@ -6850,6 +6868,7 @@ part parent ".classic" # pwm81 "AT90PWM81EP-16MN: QFN32, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 173; + archnum = 4; n_interrupts = 20; n_boot_sections = 4; boot_section_size = 256; @@ -6978,6 +6997,7 @@ part parent "pwm81" # pwm161 "AT90PWM161-16SN: SOIC20, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]", "AT90PWM161-16SNR: SOIC20, Fmax=16 MHz, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; mcuid = 177; + archnum = 5; signature = 0x1e 0x94 0x8b; memory "flash" @@ -7009,6 +7029,7 @@ part parent ".classic" # pwm1 "AT90PWM1-16SU: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 166; + archnum = 4; n_interrupts = 32; n_boot_sections = 4; boot_section_size = 256; @@ -7137,6 +7158,7 @@ part parent ".classic" # pwm2 "AT90PWM2-16SQR: SOIC24, Fmax=N/A, T=[N/A, N/A], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 167; + archnum = 4; n_interrupts = 32; n_boot_sections = 4; boot_section_size = 256; @@ -7360,6 +7382,7 @@ part parent ".classic" # pwm216 "AT90PWM216-16SUR: SOIC24, Fmax=16 MHz, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 179; + archnum = 5; n_interrupts = 32; n_boot_sections = 4; boot_section_size = 512; @@ -7506,6 +7529,7 @@ part parent ".classic" # usb646 "AT90USB646-MUR: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 181; + archnum = 5; n_interrupts = 38; n_boot_sections = 4; boot_section_size = 1024; @@ -7649,6 +7673,7 @@ part parent "usb646" # usb1286 "AT90USB1286-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", "AT90USB1286-MUR: QFN64, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; mcuid = 184; + archnum = 51; signature = 0x1e 0x97 0x82; usbpid = 0x2ffb; rampz = 0x3b; @@ -7692,6 +7717,7 @@ part parent "usb646" # usb1287 "AT90USB1287-MU: QFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]", "AT90USB1287-MUR: VQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; mcuid = 185; + archnum = 51; signature = 0x1e 0x97 0x82; usbpid = 0x2ffb; rampz = 0x3b; @@ -7733,6 +7759,7 @@ part parent ".classic" # usb82 "AT90USB82-16MUR: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 174; + archnum = 35; n_interrupts = 29; n_boot_sections = 4; boot_section_size = 512; @@ -7906,6 +7933,7 @@ part parent ".classic-nocal" # 1200 "AT90S1200A-4YI: SSOP20, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 6 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 183; + archnum = 1; n_interrupts = 4; stk500_devcode = 0x33; avr910_devcode = 0x13; @@ -8641,6 +8669,7 @@ part parent ".classic-nocal" # m103 "ATmega103L-4AI: TQFP64, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 3.6 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 84; + archnum = 31; n_interrupts = 24; stk500_devcode = 0xb1; avr910_devcode = 0x41; @@ -8748,6 +8777,7 @@ part parent ".classic-nocal" # m161 "ATmega161L-4PI: DIP40, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 89; + archnum = 5; n_interrupts = 21; n_boot_sections = 1; boot_section_size = 1024; @@ -8882,6 +8912,7 @@ part parent ".classic" # m162 "ATmega162V-8PU: DIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; mcuid = 90; + archnum = 5; n_interrupts = 28; n_boot_sections = 4; boot_section_size = 256; @@ -9008,6 +9039,7 @@ part parent ".classic" # m163 "ATmega163L-4PI: DIP40, Fmax=4 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 91; + archnum = 5; n_interrupts = 18; n_boot_sections = 4; boot_section_size = 256; @@ -9129,6 +9161,7 @@ part parent ".classic" # m8515 "ATmega8515L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 160; + archnum = 4; n_interrupts = 17; n_boot_sections = 4; boot_section_size = 256; @@ -9255,6 +9288,7 @@ part parent ".classic" # m8535 "ATmega8535L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 161; + archnum = 4; n_interrupts = 21; n_boot_sections = 4; boot_section_size = 256; @@ -9383,6 +9417,7 @@ part parent ".classic" # m8 "ATmega8L-8PU: PDIP28, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP; mcuid = 45; + archnum = 4; n_interrupts = 19; n_boot_sections = 4; boot_section_size = 256; @@ -9536,6 +9571,7 @@ part parent "m8" # m16 "ATmega16L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; mcuid = 49; + archnum = 5; n_interrupts = 21; stk500_devcode = 0x82; avr910_devcode = 0x74; @@ -9617,6 +9653,7 @@ part parent "m8" # m32 "ATmega32L-8PU: PDIP40, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; mcuid = 58; + archnum = 5; n_interrupts = 21; boot_section_size = 512; stk500_devcode = 0x91; @@ -9713,6 +9750,7 @@ part parent "m8" # m64 "ATmega64L-8MUR: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; mcuid = 72; + archnum = 5; n_interrupts = 35; boot_section_size = 1024; stk500_devcode = 0xa0; @@ -9820,6 +9858,7 @@ part parent "m8" # m128 "ATmega128L-8MUR: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; mcuid = 85; + archnum = 51; n_interrupts = 35; boot_section_size = 1024; stk500_devcode = 0xb2; @@ -9928,6 +9967,7 @@ part parent ".classic" # m640 "ATmega640V-8CUR: TFBGA100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 126; + archnum = 5; n_interrupts = 57; n_boot_sections = 4; boot_section_size = 1024; @@ -10060,6 +10100,7 @@ part parent "m640" # m1280 "ATmega1280V-8AUR: TQFP100, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", "ATmega1280V-8CU: CBGA100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 138; + archnum = 51; signature = 0x1e 0x97 0x03; rampz = 0x3b; @@ -10091,6 +10132,7 @@ part parent "m640" # m1281 "ATmega1281V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega1281V-8MUR: MLF64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; mcuid = 139; + archnum = 51; signature = 0x1e 0x97 0x04; rampz = 0x3b; @@ -10119,6 +10161,7 @@ part parent "m640" # m2560 "ATmega2560V-8AUR: TQFP100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega2560V-8CU: CBGA100, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 143; + archnum = 6; stk500_devcode = 0xb2; signature = 0x1e 0x98 0x01; pp_controlstack = @@ -10159,6 +10202,7 @@ part parent "m640" # m2561 "ATmega2561V-8MU: MLF64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega2561V-8MUR: VQFN64, Fmax=8 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]"; mcuid = 144; + archnum = 6; stk500_devcode = 0xb2; signature = 0x1e 0x98 0x02; pp_controlstack = @@ -10211,6 +10255,7 @@ part parent ".classic" # m164p "ATmega164PV-10PU: PDIP40, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 93; + archnum = 5; n_interrupts = 31; n_boot_sections = 4; boot_section_size = 256; @@ -10641,6 +10686,7 @@ part parent "m164p" # m1284 "ATmega1284-MUR: MLF44, Fmax=20 MHz, T=[N/A, N/A], Vcc=[1.8 V, 5.5 V]", "ATmega1284-PU: PDIP40, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 140; + archnum = 51; n_interrupts = 35; boot_section_size = 1024; signature = 0x1e 0x97 0x06; @@ -10720,6 +10766,7 @@ part parent ".classic" # m128rfa1 "ATmega128RFA1-ZUR00: VFQFN64, Fmax=N/A, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 87; + archnum = 51; n_interrupts = 72; n_boot_sections = 4; boot_section_size = 1024; @@ -10851,6 +10898,7 @@ part parent ".classic" # m644rfr2 "ATmega644RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 131; + archnum = 5; n_interrupts = 77; n_boot_sections = 4; boot_section_size = 1024; @@ -11003,6 +11051,7 @@ part parent "m644rfr2" # m1284rfr2 "ATmega1284RFR2-ZU: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", "ATmega1284RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; mcuid = 142; + archnum = 51; signature = 0x1e 0xa7 0x03; memory "eeprom" @@ -11038,6 +11087,7 @@ part parent "m644rfr2" # m2564rfr2 "ATmega2564RFR2-ZU: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", "ATmega2564RFR2-ZUR: VFQFN48, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; mcuid = 145; + archnum = 6; signature = 0x1e 0xa8 0x03; ocdrev = 4; @@ -11076,6 +11126,7 @@ part parent ".classic" # m64rfr2 "ATmega64RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 78; + archnum = 5; n_interrupts = 77; n_boot_sections = 4; boot_section_size = 1024; @@ -11228,6 +11279,7 @@ part parent "m64rfr2" # m128rfr2 "ATmega128RFR2-ZU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", "ATmega128RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; mcuid = 88; + archnum = 51; signature = 0x1e 0xa7 0x02; memory "eeprom" @@ -11263,6 +11315,7 @@ part parent "m64rfr2" # m256rfr2 "ATmega256RFR2-ZU: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]", "ATmega256RFR2-ZUR: VFQFN64, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 3.6 V]"; mcuid = 108; + archnum = 6; signature = 0x1e 0xa8 0x02; ocdrev = 4; @@ -11306,6 +11359,7 @@ part parent ".classic" # m165 "ATmega165V-8MU: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 95; + archnum = 5; n_interrupts = 22; n_boot_sections = 4; boot_section_size = 256; @@ -11963,6 +12017,7 @@ part parent ".classic" # m48 "ATmega48V-10PU: PDIP28, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 67; + archnum = 4; n_interrupts = 26; stk500_devcode = 0x59; chip_erase_delay = 45000; @@ -12304,6 +12359,7 @@ part parent "m48" # m168 "ATmega168V-10MUR: MLF32, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega168V-10PU: PDIP28, Fmax=10 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 99; + archnum = 5; n_boot_sections = 4; boot_section_size = 256; stk500_devcode = 0x86; @@ -12434,6 +12490,7 @@ part parent "m48" # m328 "ATmega328-MUR: MLF32, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega328-PU: PDIP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 118; + archnum = 5; n_boot_sections = 4; boot_section_size = 512; stk500_devcode = 0x86; @@ -12622,6 +12679,7 @@ part parent ".classic" # m169 "ATmega169V-8MU: VFQFN64, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG | PM_JTAGmkI; mcuid = 104; + archnum = 5; n_interrupts = 23; n_boot_sections = 4; boot_section_size = 256; @@ -13323,6 +13381,7 @@ part parent ".classic" # m8hva "ATmega8HVA-4TUR: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; mcuid = 47; + archnum = 4; n_interrupts = 21; chip_erase_delay = 4000; signature = 0x1e 0x93 0x10; @@ -13433,6 +13492,7 @@ part parent "m8hva" # m16hva "ATmega16HVA-4TU: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]", "ATmega16HVA-4TUR: TSSOP28, Fmax=4 MHz, T=[-20 C, 85 C], Vcc=[1.8 V, 9 V]"; mcuid = 51; + archnum = 5; signature = 0x1e 0x94 0x0c; memory "flash" @@ -13456,6 +13516,7 @@ part parent ".classic" # m32hve2 "ATmega32HVE2-PLQW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; mcuid = 379; + archnum = 5; n_interrupts = 25; n_boot_sections = 4; boot_section_size = 512; @@ -13576,6 +13637,7 @@ part parent ".classic" # m64hve2 "ATmega64HVE2-PLQW: VFQFN48, Fmax=15 MHz, T=[-40 C, 125 C], Vcc=[3 V, 3.6 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVSP | PM_debugWIRE; mcuid = 77; + archnum = 5; n_interrupts = 25; n_boot_sections = 4; boot_section_size = 1024; @@ -13696,6 +13758,7 @@ part parent ".classic" # m16hvb "ATmega16HVB-8X3R: TFSOP44, Fmax=8 MHz, T=[-40 C, 85 C], Vcc=[4 V, 25 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 52; + archnum = 5; n_interrupts = 29; n_boot_sections = 4; boot_section_size = 512; @@ -13869,6 +13932,7 @@ part parent ".classic" # m16m1 "ATmega16M1-MU: QFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 54; + archnum = 5; n_interrupts = 31; n_boot_sections = 4; boot_section_size = 512; @@ -14161,6 +14225,7 @@ part parent ".classic" # m8u2 "ATmega8U2-MUR: VQFN32, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 48; + archnum = 35; n_interrupts = 29; n_boot_sections = 4; boot_section_size = 512; @@ -14346,6 +14411,7 @@ part parent ".classic" # m16u4 "ATmega16U4RC-MU: QFN44, Fmax=16 MHz, T=[-40 C, 85 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_JTAG; mcuid = 57; + archnum = 5; n_interrupts = 43; n_boot_sections = 4; boot_section_size = 512; @@ -14510,6 +14576,7 @@ part parent ".classic" # m406 "ATmega406-1AAU: LQFP48, Fmax=1 MHz, T=[-30 C, 85 C], Vcc=[4 V, 25 V]"; prog_modes = PM_SPM | PM_HVPP | PM_JTAG; mcuid = 125; + archnum = 5; n_interrupts = 23; n_boot_sections = 4; boot_section_size = 512; @@ -14604,6 +14671,7 @@ part parent ".classic" # ata6612c "ATA6612C-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 216; + archnum = 4; n_interrupts = 26; n_boot_sections = 4; boot_section_size = 256; @@ -14731,6 +14799,7 @@ part parent "ata6612c" # ata6613c "ATA6613C-PLQW: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", "ATA6613C-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; mcuid = 217; + archnum = 5; stk500_devcode = 0x86; chip_erase_delay = 9000; signature = 0x1e 0x94 0x06; @@ -14765,6 +14834,7 @@ part parent ".classic" # ata6616c "ATA6616C-P3QW-1: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 219; + archnum = 25; n_interrupts = 20; stk500_devcode = 0x14; avr910_devcode = 0x20; @@ -14890,6 +14960,7 @@ part parent "ata6616c" # ata6617c "ATA6617C-P3QW: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]", "ATA6617C-P3QW-1: VFQFN38, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; mcuid = 220; + archnum = 35; signature = 0x1e 0x94 0x87; memory "flash" @@ -14913,6 +14984,7 @@ part parent ".classic" # ata5505 "ATA5505-P3QW: VFQFN38, Fmax=N/A, T=[-40 C, 105 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 198; + archnum = 35; n_interrupts = 20; stk500_devcode = 0x14; avr910_devcode = 0x20; @@ -15039,6 +15111,7 @@ part parent ".classic" # ata6614q "ATA6614Q-PLQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 218; + archnum = 5; n_interrupts = 26; n_boot_sections = 4; boot_section_size = 512; @@ -15164,6 +15237,7 @@ part parent ".classic" # ata664251 "ATA664251-WGQW-1: VFQFN48, Fmax=16 MHz, T=[-40 C, 125 C], Vcc=[2.7 V, 5.5 V]"; prog_modes = PM_SPM | PM_ISP | PM_HVPP | PM_debugWIRE; mcuid = 225; + archnum = 35; n_interrupts = 20; stk500_devcode = 0x14; avr910_devcode = 0x20; @@ -15386,6 +15460,7 @@ part # 89S51 "AT89S51-24PU: PDIP40, Fmax=24 MHz, T=[-40 C, 85 C], Vcc=[4 V, 5.5 V]"; prog_modes = PM_ISP | PM_HVPP; mcuid = 372; + archnum = 1; stk500_devcode = 0xe0; chip_erase_delay = 250000; signature = 0x1e 0x51 0x06; @@ -15696,6 +15771,7 @@ part parent ".xmega-ab" # x16a4u "ATxmega16A4U-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; prog_modes = PM_SPM | PM_PDI; mcuid = 232; + archnum = 102; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x94 0x41; @@ -15743,6 +15819,7 @@ part parent ".xmega-cd" # x16c4 "ATxmega16C4-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16C4-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 233; + archnum = 102; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x94 0x43; @@ -15795,6 +15872,7 @@ part parent ".xmega-cd" # x16d4 "ATxmega16D4-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16D4-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 234; + archnum = 102; n_interrupts = 91; boot_section_size = 4096; signature = 0x1e 0x94 0x42; @@ -15848,6 +15926,7 @@ part parent ".xmega-ab" # x16a4 "ATxmega16A4-MU: VQFN44, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; prog_modes = PM_SPM | PM_PDI; mcuid = 231; + archnum = 102; n_interrupts = 94; boot_section_size = 4096; signature = 0x1e 0x94 0x41; @@ -15901,6 +15980,7 @@ part parent ".xmega-ab" # x32a4u "ATxmega32A4U-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; prog_modes = PM_SPM | PM_PDI; mcuid = 239; + archnum = 102; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x95 0x41; @@ -15948,6 +16028,7 @@ part parent ".xmega-cd" # x32c4 "ATxmega32C4-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32C4-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 240; + archnum = 102; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x95 0x44; @@ -16001,6 +16082,7 @@ part parent ".xmega-cd" # x32d4 "ATxmega32D4-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32D4-MHR: VQFN44, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 241; + archnum = 102; n_interrupts = 91; boot_section_size = 4096; signature = 0x1e 0x95 0x42; @@ -16054,6 +16136,7 @@ part parent ".xmega-ab" # x32a4 "ATxmega32A4-MU: VQFN44, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; prog_modes = PM_SPM | PM_PDI; mcuid = 238; + archnum = 102; n_interrupts = 94; boot_section_size = 4096; signature = 0x1e 0x95 0x41; @@ -16106,6 +16189,7 @@ part parent ".xmega-ab" # x64a4u "ATxmega64A4U-MHR: VQFN44, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; prog_modes = PM_SPM | PM_PDI; mcuid = 252; + archnum = 104; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x96 0x46; @@ -16138,6 +16222,7 @@ part parent ".xmega-cd" # x32c3 "ATxmega32C3-MH: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32C3-MHR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 236; + archnum = 102; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x95 0x49; @@ -16188,6 +16273,7 @@ part parent ".xmega-cd" # x32d3 "ATxmega32D3-MHR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", "ATxmega32D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 237; + archnum = 102; n_interrupts = 114; boot_section_size = 4096; signature = 0x1e 0x95 0x4a; @@ -16239,6 +16325,7 @@ part parent ".xmega-cd" # x64c3 "ATxmega64C3-MH: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64C3-MHR: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 249; + archnum = 104; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x96 0x49; @@ -16270,6 +16357,7 @@ part parent ".xmega-cd" # x64d3 "ATxmega64D3-MHR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]", "ATxmega64D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 250; + archnum = 104; n_interrupts = 114; boot_section_size = 4096; signature = 0x1e 0x96 0x4a; @@ -16302,6 +16390,7 @@ part parent ".xmega-cd" # x64d4 "ATxmega64D4-MH: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64D4-MHR: VQFN44, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 253; + archnum = 104; n_interrupts = 91; boot_section_size = 4096; signature = 0x1e 0x96 0x47; @@ -16332,6 +16421,7 @@ part parent ".xmega-ab" # x64a1 "ATxmega64A1-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64A1-CUR: BGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 243; + archnum = 105; n_interrupts = 125; boot_section_size = 4096; signature = 0x1e 0x96 0x4e; @@ -16362,6 +16452,7 @@ part parent ".xmega-ab" # x64a1u "ATxmega64A1U-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64A1U-CUR: TFBGA100, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 244; + archnum = 105; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x96 0x4e; @@ -16393,6 +16484,7 @@ part parent ".xmega-ab" # x64a3 "ATxmega64A3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64A3-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 246; + archnum = 104; n_interrupts = 122; boot_section_size = 4096; signature = 0x1e 0x96 0x42; @@ -16422,6 +16514,7 @@ part parent ".xmega-ab" # x64a3u "ATxmega64A3U-MHR: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64A3U-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 247; + archnum = 104; n_interrupts = 127; boot_section_size = 4096; signature = 0x1e 0x96 0x42; @@ -16442,6 +16535,7 @@ part parent ".xmega-ab" # x64a4 variants = "ATxmega64A4: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 251; + archnum = 104; n_interrupts = 125; boot_section_size = 4096; signature = 0x1e 0x96 0x46; @@ -16492,6 +16586,7 @@ part parent ".xmega-ab" # x64b1 "ATxmega64B1-CU: VFBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64B1-CUR: TQFP100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 245; + archnum = 104; n_interrupts = 81; boot_section_size = 4096; signature = 0x1e 0x96 0x52; @@ -16522,6 +16617,7 @@ part parent ".xmega-ab" # x64b3 "ATxmega64B3-AUR: TQFP100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega64B3-MH: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 248; + archnum = 104; n_interrupts = 54; boot_section_size = 4096; signature = 0x1e 0x96 0x51; @@ -16555,6 +16651,7 @@ part parent ".xmega-cd" # x128c3 "ATxmega128C3-MH: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128C3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 261; + archnum = 106; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x97 0x52; @@ -16612,6 +16709,7 @@ part parent ".xmega-cd" # x128d3 "ATxmega128D3-MHR: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 262; + archnum = 106; n_interrupts = 114; boot_section_size = 8192; signature = 0x1e 0x97 0x48; @@ -16671,6 +16769,7 @@ part parent ".xmega-cd" # x128d4 "ATxmega128D4-MH: QFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128D4-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 265; + archnum = 106; n_interrupts = 91; boot_section_size = 8192; signature = 0x1e 0x97 0x47; @@ -16727,6 +16826,7 @@ part parent ".xmega-ab" # x128a1 "ATxmega128A1-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128A1-CUR: BGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 254; + archnum = 107; n_interrupts = 125; boot_section_size = 8192; signature = 0x1e 0x97 0x4c; @@ -16796,6 +16896,7 @@ part parent ".xmega-ab" # x128a1u "ATxmega128A1U-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128A1U-CUR: CBGA100, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 256; + archnum = 107; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x97 0x4c; @@ -16854,6 +16955,7 @@ part parent ".xmega-ab" # x128a3 "ATxmega128A3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128A3-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 258; + archnum = 106; n_interrupts = 122; boot_section_size = 8192; signature = 0x1e 0x97 0x42; @@ -16910,6 +17012,7 @@ part parent ".xmega-ab" # x128a3u "ATxmega128A3U-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128A3U-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 259; + archnum = 106; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x97 0x42; @@ -16957,6 +17060,7 @@ part parent ".xmega-ab" # x128a4 variants = "ATxmega128A4: N/A, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 263; + archnum = 107; boot_section_size = 8192; signature = 0x1e 0x97 0x46; @@ -17039,6 +17143,7 @@ part parent ".xmega-ab" # x128a4u "ATxmega128A4U-MHR: VQFN44, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; prog_modes = PM_SPM | PM_PDI; mcuid = 264; + archnum = 107; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x97 0x46; @@ -17086,6 +17191,7 @@ part parent ".xmega-ab" # x128b1 "ATxmega128B1-CU: VFBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128B1-CUR: TFBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 257; + archnum = 106; n_interrupts = 81; boot_section_size = 8192; signature = 0x1e 0x97 0x4d; @@ -17137,6 +17243,7 @@ part parent ".xmega-ab" # x128b3 "ATxmega128B3-MH: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega128B3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 260; + archnum = 106; n_interrupts = 54; boot_section_size = 8192; signature = 0x1e 0x97 0x4b; @@ -17186,6 +17293,7 @@ part parent ".xmega-cd" # x192c3 "ATxmega192C3-MH: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega192C3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 269; + archnum = 106; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x97 0x51; @@ -17242,6 +17350,7 @@ part parent ".xmega-cd" # x192d3 "ATxmega192D3-MHR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]", "ATxmega192D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 270; + archnum = 106; n_interrupts = 114; boot_section_size = 8192; signature = 0x1e 0x97 0x49; @@ -17294,6 +17403,7 @@ part parent ".xmega-ab" # x192a1 "ATxmega192A1-AU: TQFP100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega192A1-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 266; + archnum = 107; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x97 0x4e; @@ -17378,6 +17488,7 @@ part parent ".xmega-ab" # x192a3 "ATxmega192A3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega192A3-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 267; + archnum = 106; n_interrupts = 122; boot_section_size = 8192; signature = 0x1e 0x97 0x44; @@ -17434,6 +17545,7 @@ part parent ".xmega-ab" # x192a3u "ATxmega192A3U-MHR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]", "ATxmega192A3U-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 268; + archnum = 106; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x97 0x44; @@ -17486,6 +17598,7 @@ part parent ".xmega-cd" # x256c3 "ATxmega256C3-MH: VQFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256C3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 276; + archnum = 106; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x98 0x46; @@ -17547,6 +17660,7 @@ part parent ".xmega-cd" # x256d3 "ATxmega256D3-MHR: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 277; + archnum = 106; n_interrupts = 114; boot_section_size = 8192; signature = 0x1e 0x98 0x44; @@ -17604,6 +17718,7 @@ part parent ".xmega-ab" # x256a1 "ATxmega256A1-AU: TQFP100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256A1-CU: CBGA100, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 271; + archnum = 107; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x98 0x46; @@ -17693,6 +17808,7 @@ part parent ".xmega-ab" # x256a3 "ATxmega256A3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256A3-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 272; + archnum = 106; n_interrupts = 122; boot_section_size = 8192; signature = 0x1e 0x98 0x42; @@ -17754,6 +17870,7 @@ part parent ".xmega-ab" # x256a3u "ATxmega256A3U-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256A3U-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 275; + archnum = 106; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x98 0x42; @@ -17809,6 +17926,7 @@ part parent ".xmega-ab" # x256a3b "ATxmega256A3B-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256A3B-MU: QFN64, Fmax=32 MHz, T=[N/A, N/A], Vcc=[1.6 V, 3.6 V]"; mcuid = 273; + archnum = 106; n_interrupts = 122; boot_section_size = 8192; signature = 0x1e 0x98 0x43; @@ -17867,6 +17985,7 @@ part parent ".xmega-ab" # x256a3bu "ATxmega256A3BU-MH: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega256A3BU-MHR: VQFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 274; + archnum = 106; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x98 0x43; @@ -17923,6 +18042,7 @@ part parent ".xmega-cd" # x384c3 "ATxmega384C3-MH: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega384C3-MHR: VQFN64, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 278; + archnum = 106; n_interrupts = 127; boot_section_size = 8192; signature = 0x1e 0x98 0x45; @@ -17982,6 +18102,7 @@ part parent ".xmega-cd" # x384d3 "ATxmega384D3-MHR: QFN64, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega384D3-MN: QFN64, Fmax=32 MHz, T=[-40 C, 105 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 279; + archnum = 106; n_interrupts = 114; boot_section_size = 8192; signature = 0x1e 0x98 0x47; @@ -18047,6 +18168,7 @@ part parent ".xmega-e" # x8e5 "ATxmega8E5-MU: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega8E5-MUR: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 230; + archnum = 102; boot_section_size = 2048; signature = 0x1e 0x93 0x41; @@ -18097,6 +18219,7 @@ part parent ".xmega-e" # x16e5 "ATxmega16E5-MU: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega16E5-MUR: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 235; + archnum = 102; boot_section_size = 4096; signature = 0x1e 0x94 0x45; @@ -18145,6 +18268,7 @@ part parent ".xmega-e" # x32e5 "ATxmega32E5-MU: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]", "ATxmega32E5-MUR: VQFN32, Fmax=32 MHz, T=[-40 C, 85 C], Vcc=[1.6 V, 3.6 V]"; mcuid = 242; + archnum = 102; boot_section_size = 4096; signature = 0x1e 0x95 0x4c; @@ -18446,6 +18570,7 @@ part parent ".avr8x_tiny" # t202 "ATtiny202-SSN: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny202-SSNR: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 280; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x91 0x23; @@ -18497,6 +18622,7 @@ part parent ".avr8x_tiny" # t204 "ATtiny204-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny204-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 281; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x91 0x22; @@ -18548,6 +18674,7 @@ part parent ".avr8x_tiny" # t402 "ATtiny402-SSN: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny402-SSNR: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 284; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x92 0x27; @@ -18599,6 +18726,7 @@ part parent ".avr8x_tiny" # t404 "ATtiny404-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny404-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 285; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x92 0x26; @@ -18652,6 +18780,7 @@ part parent ".avr8x_tiny" # t406 "ATtiny406-SN: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny406-SNR: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 286; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x92 0x25; @@ -18703,6 +18832,7 @@ part parent ".avr8x_tiny" # t804 "ATtiny804-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny804-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 295; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x93 0x25; @@ -18747,6 +18877,7 @@ part parent ".avr8x_tiny" # t806 "ATtiny806-SN: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny806-SNR: SOIC300-20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 296; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x93 0x24; @@ -18788,6 +18919,7 @@ part parent ".avr8x_tiny" # t807 "ATtiny807-MNR: VQFN24, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny807-MRF: VQFN24, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 297; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x93 0x23; @@ -18828,6 +18960,7 @@ part parent ".avr8x_tiny" # t1604 "ATtiny1604-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny1604-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 304; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x94 0x25; @@ -18872,6 +19005,7 @@ part parent ".avr8x_tiny" # t1606 "ATtiny1606-SN: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny1606-SNR: SOIC300-20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 305; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x94 0x24; @@ -18913,6 +19047,7 @@ part parent ".avr8x_tiny" # t1607 "ATtiny1607-MNR: VQFN24, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny1607-MRF: VQFN24, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 306; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x94 0x23; @@ -18953,6 +19088,7 @@ part parent ".avr8x_tiny" # t212 "ATtiny212-SSN: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny212-SSNR: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 282; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x91 0x21; @@ -19004,6 +19140,7 @@ part parent ".avr8x_tiny" # t214 "ATtiny214-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny214-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 283; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x91 0x20; @@ -19055,6 +19192,7 @@ part parent ".avr8x_tiny" # t412 "ATtiny412-SSN: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny412-SSNR: SOIC8, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 287; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x92 0x23; @@ -19106,6 +19244,7 @@ part parent ".avr8x_tiny" # t414 "ATtiny414-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny414-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 288; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x92 0x22; @@ -19159,6 +19298,7 @@ part parent ".avr8x_tiny" # t416 "ATtiny416-SN: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny416-SNR: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 289; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x92 0x21; @@ -19229,6 +19369,7 @@ part parent ".avr8x_tiny" # t417 "ATtiny417-MN: VQFN24, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny417-MNR: QFN24, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 291; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x92 0x20; @@ -19281,6 +19422,7 @@ part parent ".avr8x_tiny" # t814 "ATtiny814-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny814-SSNRES: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 298; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x93 0x22; @@ -19337,6 +19479,7 @@ part parent ".avr8x_tiny" # t816 "ATtiny816-SN: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny816-SNR: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 299; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x93 0x21; @@ -19389,6 +19532,7 @@ part parent ".avr8x_tiny" # t817 "ATtiny817-MNR: VQFN24, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny817-MNRES: VQFN24, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 300; + archnum = 103; n_interrupts = 26; signature = 0x1e 0x93 0x20; @@ -19440,6 +19584,7 @@ part parent ".avr8x_tiny" # t1614 "ATtiny1614-SSN: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny1614-SSNR: SOIC14, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 307; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x94 0x22; @@ -19493,6 +19638,7 @@ part parent ".avr8x_tiny" # t1616 "ATtiny1616-SN: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny1616-SNR: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 308; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x94 0x21; @@ -19544,6 +19690,7 @@ part parent ".avr8x_tiny" # t1617 "ATtiny1617-MN: QFN24, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny1617-MNR: QFN24, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 309; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x94 0x20; @@ -19595,6 +19742,7 @@ part parent ".avr8x_tiny" # t3216 "ATtiny3216-SN: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]", "ATtiny3216-SNR: SOIC20, Fmax=20 MHz, T=[-40 C, 105 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 314; + archnum = 103; n_interrupts = 31; signature = 0x1e 0x95 0x21; @@ -20263,6 +20411,7 @@ part parent ".avr8x_tiny" # m808 "ATmega808-XU: SSOP28, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", "ATmega808-XUR: SSOP28, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 319; + archnum = 103; n_interrupts = 36; signature = 0x1e 0x93 0x26; @@ -20311,6 +20460,7 @@ part parent ".avr8x_tiny" # m809 "ATmega809-MU: VQFN48, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", "ATmega809-MUR: VQFN48, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 320; + archnum = 103; n_interrupts = 40; signature = 0x1e 0x93 0x2a; @@ -20363,6 +20513,7 @@ part parent ".avr8x_tiny" # m1608 "ATmega1608-XU: SSOP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega1608-XUR: SSOP28, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 321; + archnum = 103; n_interrupts = 36; signature = 0x1e 0x94 0x27; @@ -20411,6 +20562,7 @@ part parent ".avr8x_tiny" # m1609 "ATmega1609-MU: VQFN48, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]", "ATmega1609-MUR: VQFN48, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 322; + archnum = 103; n_interrupts = 40; signature = 0x1e 0x94 0x26; @@ -20463,6 +20615,7 @@ part parent ".avr8x_mega" # m3208 "ATmega3208-XU: SSOP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega3208-XUR: SSOP28, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 323; + archnum = 103; n_interrupts = 36; signature = 0x1e 0x95 0x30; @@ -20513,6 +20666,7 @@ part parent ".avr8x_mega" # m3209 "ATmega3209-MU: VQFN48, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega3209-MUR: VQFN48, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 324; + archnum = 103; n_interrupts = 40; signature = 0x1e 0x95 0x31; @@ -20567,6 +20721,7 @@ part parent ".avr8x_mega" # m4808 "ATmega4808-XU: SSOP28, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega4808-XUR: SSOP28, Fmax=N/A, T=[N/A, N/A], Vcc=[N/A, N/A]"; mcuid = 325; + archnum = 103; n_interrupts = 36; signature = 0x1e 0x96 0x50; @@ -20618,6 +20773,7 @@ part parent ".avr8x_mega" # m4809 "ATmega4809-MUR: VQFN48, Fmax=20 MHz, T=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]", "ATmega4809-PF: PDIP40, Fmax=20 MHz, T=[-40 C, 125 C], Vcc=[1.8 V, 5.5 V]"; mcuid = 326; + archnum = 103; n_interrupts = 40; signature = 0x1e 0x96 0x51; diff --git a/src/config.c b/src/config.c index eb7b45a8..1f25c1ac 100644 --- a/src/config.c +++ b/src/config.c @@ -84,6 +84,7 @@ Component avr_comp[] = { part_comp_desc(family_id, COMP_STRING), part_comp_desc(prog_modes, COMP_INT), part_comp_desc(mcuid, COMP_INT), + part_comp_desc(archnum, COMP_INT), part_comp_desc(n_interrupts, COMP_INT), part_comp_desc(n_page_erase, COMP_INT), part_comp_desc(n_boot_sections, COMP_INT), diff --git a/src/developer_opts.c b/src/developer_opts.c index c47b797a..0114cb48 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -594,6 +594,7 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool } else { _if_partout(intcmp, "%d", mcuid); } + _if_partout(intcmp, "%d", archnum); _if_partout(intcmp, "%d", n_interrupts); _if_partout(intcmp, "%d", n_page_erase); _if_partout(intcmp, "%d", n_boot_sections); diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 3613631e..1bf00c72 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -3399,6 +3399,7 @@ part family_id = ; # quoted string, e.g., "megaAVR" or "tinyAVR" prog_modes = PM_ @{| PM_@} # interfaces, e.g., PM_SPM|PM_ISP|PM_HVPP|PM_debugWIRE mcuid = ; # unique id in 0..2039 for 8-bit AVRs + archnum = ; # avr-gcc architecture number for the part n_interrupts = ; # number of interrupts, used for vector bootloaders n_page_erase = ; # if set, number of pages erased during SPM erase n_boot_sections = ; # Number of boot sections diff --git a/src/lexer.l b/src/lexer.l index f0882904..a68853c4 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -149,7 +149,7 @@ INF [Ii][Nn][Ff]([Ii][Nn][Ii][Tt][Yy])? (?x: desc | prog_modes | is_serialadapter | extra_features | baudrate | usbvid | usbdev | usbsn | usbvendor | usbproduct | - family_id | mcuid | n_interrupts | n_page_erase | n_boot_sections | boot_section_size | + family_id | mcuid | archnum | n_interrupts | n_page_erase | n_boot_sections | boot_section_size | hvupdi_variant | stk500_devcode | avr910_devcode | chip_erase_delay | pagel | bs2 | timeout | stabdelay | cmdexedelay | synchloops | bytedelay | pollindex | pollvalue | predelay | postdelay | pollmethod | hventerstabdelay | progmodedelay | latchcycles | togglevtg | poweroffdelay | resetdelayms | resetdelayus | resetdelay | hvleavestabdelay | diff --git a/src/libavrdude.h b/src/libavrdude.h index 1add10a7..3f4bc03c 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -272,6 +272,7 @@ typedef struct avrpart { const char * family_id; /* family id in the SIB (avr8x) */ int prog_modes; /* Programming interfaces, see #define PM_... */ int mcuid; /* Unique id in 0..2039 for urclock programmer */ + int archnum; /* avr-gcc architecture number for the part */ int n_interrupts; /* Number of interrupts, used for vector bootloaders */ int n_page_erase; /* If set, number of pages erased during NVM erase */ int n_boot_sections; /* Number of boot sections */ From fe263758843c86f4e5bddc5d59517359637e0e19 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 18:49:58 +0100 Subject: [PATCH 287/422] Compute opcodes for disasm, given the part --- src/libavrdude.h | 1 + src/term.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 3f4bc03c..a4d72b6c 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1460,6 +1460,7 @@ typedef struct { char Process_Labels; char Pass; int FlashSize; + int AVR_Level; } Disasm_options; typedef enum { diff --git a/src/term.c b/src/term.c index 59899502..d10a44f9 100644 --- a/src/term.c +++ b/src/term.c @@ -399,6 +399,54 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha return 0; } +static int get_avr_archlevel(const AVRPART *p) { + int ret = + p->prog_modes & PM_UPDI? PART_AVR_XT: + p->prog_modes & PM_PDI? PART_AVR_XM: + p->prog_modes & PM_TPI? PART_AVR_RC: 0; + + if(!ret) { // Non-TPI classic part + switch(p->archnum) { + case 1: + ret = PART_AVR1; + break; + default: // If AVRDUE doesn't know, it's probably rare & old + case 2: + ret = PART_AVR2; + break; + case 25: + ret = PART_AVR25; + break; + case 3: case 31: case 35: // Sic + ret = PART_AVR3; + break; + break; + case 4: + ret = PART_AVR4; + break; + case 5: + ret = PART_AVR5; + break; + case 51: + ret = PART_AVR51; + break; + case 6: + ret = PART_AVR6; + } + } + + AVRMEM *mem = avr_locate_flash(p); + if(mem) { // Add opcodes needed for large parts in any case + if(mem->size > 8192) + ret |= OP_AVR_M; // JMP, CALL + if(mem->size > 65536) + ret |= OP_AVR_L; // ELPM + if(mem->size > 128*1024) + ret |= OP_AVR_XL; // EIJMP, EICALL + } + + return ret; +} static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { int addr, len; @@ -419,11 +467,12 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.CodeStyle = CODESTYLE_AVRGCC; // CODESTYLE_AVR_INSTRUCTION_SET cx->dis_opts.Process_Labels = 1; cx->dis_opts.FlashSize = 0; + if((mem = avr_locate_flash(p))) + cx->dis_opts.FlashSize = mem->size; + cx->dis_opts.AVR_Level = get_avr_archlevel(p); cx->dis_initopts++; } cx->dis_opts.Pass = 1; - if((mem = avr_locate_flash(p))) - cx->dis_opts.FlashSize = mem->size; for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; From 6290e92303b253c93ce97994ec52cbb6d70c14e1 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 19:09:07 +0100 Subject: [PATCH 288/422] Remove pseudocode disassembly --- src/CMakeLists.txt | 2 - src/Makefile.am | 2 - src/disasm.c | 80 +--- src/disasm_callbacks_pseudocode.c | 672 ------------------------------ src/disasm_callbacks_pseudocode.h | 106 ----- src/disasm_ioregisters.c | 2 - src/libavrdude.h | 15 +- src/term.c | 19 +- 8 files changed, 16 insertions(+), 882 deletions(-) delete mode 100644 src/disasm_callbacks_pseudocode.c delete mode 100644 src/disasm_callbacks_pseudocode.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 287bd927..a8f949bb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -184,8 +184,6 @@ add_library(libavrdude disasm.c disasm_callbacks_assembly.c disasm_callbacks_assembly.h - disasm_callbacks_pseudocode.c - disasm_callbacks_pseudocode.h disasm_globals.h disasm_ioregisters.c disasm_ioregisters.h diff --git a/src/Makefile.am b/src/Makefile.am index a7fb916b..c76df991 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,8 +122,6 @@ libavrdude_a_SOURCES = \ disasm.c \ disasm_callbacks_assembly.c \ disasm_callbacks_assembly.h \ - disasm_callbacks_pseudocode.c \ - disasm_callbacks_pseudocode.h \ disasm_globals.h \ disasm_ioregisters.c \ disasm_ioregisters.h \ diff --git a/src/disasm.c b/src/disasm.c index 0fa47056..dcd8fabe 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -38,7 +38,6 @@ #include "disasm_globals.h" #include "disasm_callbacks_assembly.h" -#include "disasm_callbacks_pseudocode.h" #include "disasm_jumpcall.h" #include "disasm_ioregisters.h" #include "disasm_tagfile.h" @@ -222,7 +221,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) { cx->dis_opts.Pass = 1; Pos = 0; - if(cx->dis_opts.Process_Labels || (!cx->dis_opts.Show_PseudoCode && cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC)) { + if(cx->dis_opts.Process_Labels || cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC) { // Preprocess to gather jump labels or to gain knowledge about registers which are being used while(Pos < Read) { Opcode = Get_Next_Opcode(Bitstream + Pos); @@ -289,11 +288,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) { printf("%s\n", cx->dis_code); } else { // Comment available - if(!cx->dis_opts.Show_PseudoCode) { - printf("%-23s ; %s\n", cx->dis_code, cx->dis_comment); - } else { - printf("%-35s ; %s\n", cx->dis_code, cx->dis_comment); - } + printf("%-23s ; %s\n", cx->dis_code, cx->dis_comment); } } printf("%s", cx->dis_after_code); @@ -306,10 +301,6 @@ void Disassemble(const char *Bitstream, int Read, int addr) { } } - if(cx->dis_opts.Show_PseudoCode) { // { - printf("}\n"); - printf("\n"); - } } void Display_Opcodes() { @@ -526,73 +517,6 @@ int disasm(const char *Bitstream, int Read, int addr) { // Register_Opcode(tst_Callback, "0010 00dd dddd dddd", OPCODE_tst); // Implied by and Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); - if(cx->dis_opts.Show_PseudoCode) { - Supersede_Opcode(adc_Callback_PC, OPCODE_adc); - Supersede_Opcode(add_Callback_PC, OPCODE_add); - Supersede_Opcode(sub_Callback_PC, OPCODE_sub); - Supersede_Opcode(sbc_Callback_PC, OPCODE_sbc); - Supersede_Opcode(mov_Callback_PC, OPCODE_mov); - Supersede_Opcode(brcc_Callback_PC, OPCODE_brcc); - Supersede_Opcode(brcs_Callback_PC, OPCODE_brcs); - Supersede_Opcode(breq_Callback_PC, OPCODE_breq); - Supersede_Opcode(brge_Callback_PC, OPCODE_brge); - Supersede_Opcode(brhc_Callback_PC, OPCODE_brhc); - Supersede_Opcode(brhs_Callback_PC, OPCODE_brhs); - Supersede_Opcode(brid_Callback_PC, OPCODE_brid); - Supersede_Opcode(brie_Callback_PC, OPCODE_brie); - Supersede_Opcode(brlo_Callback_PC, OPCODE_brlo); - Supersede_Opcode(brlt_Callback_PC, OPCODE_brlt); - Supersede_Opcode(brmi_Callback_PC, OPCODE_brmi); - Supersede_Opcode(brne_Callback_PC, OPCODE_brne); - Supersede_Opcode(brpl_Callback_PC, OPCODE_brpl); - Supersede_Opcode(brsh_Callback_PC, OPCODE_brsh); - Supersede_Opcode(brtc_Callback_PC, OPCODE_brtc); - Supersede_Opcode(brts_Callback_PC, OPCODE_brts); - Supersede_Opcode(brvc_Callback_PC, OPCODE_brvc); - Supersede_Opcode(brvs_Callback_PC, OPCODE_brvs); - Supersede_Opcode(out_Callback_PC, OPCODE_out); - Supersede_Opcode(in_Callback_PC, OPCODE_in); - Supersede_Opcode(cli_Callback_PC, OPCODE_cli); - Supersede_Opcode(sei_Callback_PC, OPCODE_sei); - Supersede_Opcode(ret_Callback_PC, OPCODE_ret); - Supersede_Opcode(reti_Callback_PC, OPCODE_reti); - Supersede_Opcode(andi_Callback_PC, OPCODE_andi); - Supersede_Opcode(subi_Callback_PC, OPCODE_subi); - Supersede_Opcode(sbci_Callback_PC, OPCODE_sbci); - Supersede_Opcode(sbr_Callback_PC, OPCODE_sbr); - Supersede_Opcode(ori_Callback_PC, OPCODE_ori); - Supersede_Opcode(ldi_Callback_PC, OPCODE_ldi); - Supersede_Opcode(lds_Callback_PC, OPCODE_lds); - Supersede_Opcode(sts_Callback_PC, OPCODE_sts); - Supersede_Opcode(call_Callback_PC, OPCODE_call); - Supersede_Opcode(rcall_Callback_PC, OPCODE_rcall); - Supersede_Opcode(ror_Callback_PC, OPCODE_ror); - Supersede_Opcode(lsr_Callback_PC, OPCODE_lsr); - Supersede_Opcode(eor_Callback_PC, OPCODE_eor); - Supersede_Opcode(swap_Callback_PC, OPCODE_swap); - Supersede_Opcode(jmp_Callback_PC, OPCODE_jmp); - Supersede_Opcode(rjmp_Callback_PC, OPCODE_rjmp); - Supersede_Opcode(cpi_Callback_PC, OPCODE_cpi); - Supersede_Opcode(asr_Callback_PC, OPCODE_asr); - Supersede_Opcode(inc_Callback_PC, OPCODE_inc); - Supersede_Opcode(dec_Callback_PC, OPCODE_dec); - Supersede_Opcode(cp_Callback_PC, OPCODE_cp); - Supersede_Opcode(cpc_Callback_PC, OPCODE_cpc); - Supersede_Opcode(cpse_Callback_PC, OPCODE_cpse); - Supersede_Opcode(and_Callback_PC, OPCODE_and); - Supersede_Opcode(or_Callback_PC, OPCODE_or); - Supersede_Opcode(mul_Callback_PC, OPCODE_mul); - Supersede_Opcode(sbi_Callback_PC, OPCODE_sbi); - Supersede_Opcode(sbis_Callback_PC, OPCODE_sbis); - Supersede_Opcode(sbic_Callback_PC, OPCODE_sbic); - Supersede_Opcode(cbi_Callback_PC, OPCODE_cbi); - Supersede_Opcode(ser_Callback_PC, OPCODE_ser); - Supersede_Opcode(movw_Callback_PC, OPCODE_movw); - Supersede_Opcode(adiw_Callback_PC, OPCODE_adiw); - Supersede_Opcode(lpm1_Callback_PC, OPCODE_lpm_1); - Supersede_Opcode(stx2_Callback_PC, OPCODE_st_2); - } - qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); for(size_t i = 0; i < sizeof avr_opcodes/sizeof*avr_opcodes; i++) diff --git a/src/disasm_callbacks_pseudocode.c b/src/disasm_callbacks_pseudocode.c deleted file mode 100644 index 11dce0c7..00000000 --- a/src/disasm_callbacks_pseudocode.c +++ /dev/null @@ -1,672 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include - -#include "libavrdude.h" - -#include "disasm_globals.h" -#include "disasm_callbacks_pseudocode.h" -#include "disasm_jumpcall.h" -#include "disasm_ioregisters.h" -#include "disasm_tagfile.h" - -void PC_Operation_Simple(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%s", avr_opcodes[mnemo].opcode); -} - -void PC_Operation_Rd(AVR_opcode mnemo) { - switch (mnemo) { - case OPCODE_lsl: - snprintf(cx->dis_code, 255, "r%d <<= 1;", Rd); - snprintf(cx->dis_comment, 255, "_BV(0) = 0 (logical shift)"); - break; - case OPCODE_lsr: - snprintf(cx->dis_code, 255, "r%d >>= 1;", Rd); - snprintf(cx->dis_comment, 255, "_BV(7) = 0, Carry = _BV(0) (logical shift)"); - break; - case OPCODE_ror: - snprintf(cx->dis_code, 255, "r%d >>= 1;", Rd); - snprintf(cx->dis_comment, 255, "_BV(7) = Carry, Carry = _BV(0) (rotate right)"); - break; - case OPCODE_asr: - - // snprintf(cx->dis_code, 255, "r%d >>= 1;", Rd); - - // snprintf(cx->dis_comment, 255, "_BV(7) = Sign (Arithmetic Shift)"); - snprintf(cx->dis_code, 255, "r%d /= 2;", Rd); - snprintf(cx->dis_comment, 255, "arithmetic shift right"); - break; - case OPCODE_swap: - snprintf(cx->dis_code, 255, "r%d = ((r%d & 0xf0) >> 4) | ((r%d & 0x0f) << 4);", Rd, Rd, Rd); - snprintf(cx->dis_comment, 255, "swap nibbles"); - break; - case OPCODE_clr: - snprintf(cx->dis_code, 255, "r%d = 0x00;", Rd); - snprintf(cx->dis_comment, 255, "0"); - break; - default: - snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd); - } -} - -void PC_Operation_Rd16(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd + 16); -} - -void PC_Operation_Rd_Rr(AVR_opcode mnemo) { - switch (mnemo) { - case OPCODE_add: - if(Rd != Rr) { - snprintf(cx->dis_code, 255, "r%d += r%d;", Rd, Rr); - snprintf(cx->dis_comment, 255, "No carry"); - } else { - snprintf(cx->dis_code, 255, "r%d *= 2;", Rd); - } - break; - case OPCODE_adc: - snprintf(cx->dis_code, 255, "r%d += r%d;", Rd, Rr); - snprintf(cx->dis_comment, 255, "With carry"); - break; - case OPCODE_sub: - snprintf(cx->dis_code, 255, "r%d -= r%d;", Rd, Rr); - snprintf(cx->dis_comment, 255, "No carry"); - break; - case OPCODE_sbc: - snprintf(cx->dis_code, 255, "r%d += r%d;", Rd, Rr); - snprintf(cx->dis_comment, 255, "With carry"); - break; - case OPCODE_mul: - snprintf(cx->dis_code, 255, "r1:r0 = r%d * r%d;", Rd, Rr); - snprintf(cx->dis_comment, 255, "Unsigned"); - break; - case OPCODE_mov: - snprintf(cx->dis_code, 255, "r%d = r%d;", Rd, Rr); - break; - case OPCODE_eor: - snprintf(cx->dis_code, 255, "r%d ^= r%d;", Rd, Rr); - break; - case OPCODE_and: - if(Rd != Rr) { - snprintf(cx->dis_code, 255, "r%d &= r%d;", Rd, Rr); - } else { - snprintf(cx->dis_code, 255, "(r%d == 0) || (r%d < 0);", Rd, Rd); - snprintf(cx->dis_comment, 255, "test r%d", Rd); - } - break; - case OPCODE_or: - snprintf(cx->dis_code, 255, "r%d |= r%d;", Rd, Rr); - break; - case OPCODE_cp: - snprintf(cx->dis_code, 255, "cmp(r%d, r%d);", Rd, Rr); - break; - case OPCODE_cpc: - snprintf(cx->dis_code, 255, "cmp(r%d, r%d);", Rd, Rr); - snprintf(cx->dis_comment, 255, "with carry"); - break; - case OPCODE_cpse: - snprintf(cx->dis_code, 255, "skipif (r%d == r%d)", Rd, Rr); - break; - default: - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd, Rr); - } -} - -void PC_Operation_Rd16_Rr16(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd + 16, Rr + 16); -} - -void PC_Operation_Rd16_K(AVR_opcode mnemo) { - switch (mnemo) { - case OPCODE_andi: - snprintf(cx->dis_code, 255, "r%d &= %d;", Rd + 16, RK); - snprintf(cx->dis_comment, 255, "0x%02x", RK); - break; - case OPCODE_subi: - snprintf(cx->dis_code, 255, "r%d -= %d;", Rd + 16, RK); - snprintf(cx->dis_comment, 255, "0x%02x, no carry", RK); - break; - case OPCODE_sbci: - snprintf(cx->dis_code, 255, "r%d -= %d;", Rd + 16, RK); - snprintf(cx->dis_comment, 255, "0x%02x, with carry", RK); - break; - case OPCODE_sbr: - case OPCODE_ori: - snprintf(cx->dis_code, 255, "r%d |= %d;", Rd + 16, RK); - snprintf(cx->dis_comment, 255, "0x%02x", RK); - break; - default: - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 16, RK); - snprintf(cx->dis_comment, 255, "%d", RK); - } -} - -void PC_Operation_Rd_K(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); - snprintf(cx->dis_comment, 255, "%d", RK); -} - -void PC_Operation_RdW_K(AVR_opcode mnemo) { - if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 1, Rd, RK); - } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); - } - snprintf(cx->dis_comment, 255, "%d", RK); -} - -void PC_Operation_RdW_RrW(AVR_opcode mnemo) { - if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", avr_opcodes[mnemo].opcode, (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); - } else { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, 2 * Rd, 2 * Rr); - } -} - -void PC_Operation_s_k(AVR_opcode mnemo, int Position) { - int Bits, Offset; - - Bits = Rs; - Offset = (2 * Rk); - if(Offset > 128) - Offset -= 256; - - int Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, mnemo, 0); - if(cx->dis_opts.Process_Labels == 0) { - if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s %d, .+%d", avr_opcodes[mnemo].opcode, Bits, Offset); - } else { - snprintf(cx->dis_code, 255, "%-7s %d, .%d", avr_opcodes[mnemo].opcode, Bits, Offset); - } - snprintf(cx->dis_comment, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); - } else { - snprintf(cx->dis_code, 255, "%-7s %d, %s", avr_opcodes[mnemo].opcode, Bits, Get_Label_Name(Target, NULL)); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); - } -} - -void PC_Operation_r_b(AVR_opcode mnemo) { - int Register, Bit; - - Register = Rr; - Bit = Rb; - snprintf(cx->dis_code, 255, "%-7s r%d, %d", avr_opcodes[mnemo].opcode, Register, Bit); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void PC_Operation_Rd_b(AVR_opcode mnemo) { - int Register, Bit; - - Register = Rd; - Bit = Rb; - snprintf(cx->dis_code, 255, "%-7s r%d, %d", avr_opcodes[mnemo].opcode, Register, Bit); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void PC_Operation_A_b(AVR_opcode mnemo) { - int Register, Bit; - const char *Register_Name; - char Register_Value[5]; - - Register = RA; - Bit = Rb; - Register_Name = Resolve_IO_Register(Register); - if(Register_Name == NULL) { - snprintf(Register_Value, sizeof(Register_Value), "0x%02x", Register); - Register_Name = Register_Value; - } - switch (mnemo) { - case OPCODE_cbi: - snprintf(cx->dis_code, 255, "IO[%s] &= ~(_BV(%d));", Register_Name, Bit); - break; - case OPCODE_sbi: - snprintf(cx->dis_code, 255, "IO[%s] |= _BV(%d);", Register_Name, Bit); - break; - case OPCODE_sbis: - snprintf(cx->dis_code, 255, "skipif (IO[%s] & _BV(%d))", Register_Name, Bit); - break; - case OPCODE_sbic: - snprintf(cx->dis_code, 255, "skipif (!(IO[%s] & _BV(%d)))", Register_Name, Bit); - break; - default: - snprintf(cx->dis_code, 255, "%-7s %s, %d", avr_opcodes[mnemo].opcode, Register_Name, Bit); - } - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void PC_Operation_s(AVR_opcode mnemo) { - int Bit; - - Bit = Rs; - snprintf(cx->dis_code, 255, "%-7s %d", avr_opcodes[mnemo].opcode, Bit); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -void PC_Operation_k(AVR_opcode mnemo, int Position, char *Pseudocode) { - int Offset; - - Offset = (2 * Rk); - if(Offset > 128) - Offset -= 256; - - int Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, mnemo, 0); - if(cx->dis_opts.Process_Labels == 0) { - if(Offset > 0) { - snprintf(cx->dis_code, 255, "if (%s) goto .+%d;", Pseudocode, Offset); - } else { - snprintf(cx->dis_code, 255, "if (%s) goto .%d", Pseudocode, Offset); - } - snprintf(cx->dis_comment, 255, "0x%02x", Target); - } else { - snprintf(cx->dis_code, 255, "if (%s) goto %s;", Pseudocode, Get_Label_Name(Target, NULL)); - } -} - -/************* Now to the callback functions *************/ - -CALLBACK(adc_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(add_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(sub_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(sbc_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(mov_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(brcc_Callback_PC) { - PC_Operation_k(mnemo, Position, "!Carry"); -} - -CALLBACK(brcs_Callback_PC) { - PC_Operation_k(mnemo, Position, "Carry"); -} - -CALLBACK(breq_Callback_PC) { - PC_Operation_k(mnemo, Position, "c1 == c2"); -} - -CALLBACK(brge_Callback_PC) { - PC_Operation_k(mnemo, Position, "c1 (signed)>= c2"); -} - -CALLBACK(brhc_Callback_PC) { - PC_Operation_k(mnemo, Position, "!HalfCarry"); -} - -CALLBACK(brhs_Callback_PC) { - PC_Operation_k(mnemo, Position, "HalfCarry"); -} - -CALLBACK(brid_Callback_PC) { - PC_Operation_k(mnemo, Position, "Global_Interrupts_Disabled()"); -} - -CALLBACK(brie_Callback_PC) { - PC_Operation_k(mnemo, Position, "Global_Interrupts_Enabled()"); -} - -CALLBACK(brlo_Callback_PC) { - PC_Operation_k(mnemo, Position, "c1 (unsigned)< c2"); -} - -CALLBACK(brlt_Callback_PC) { - PC_Operation_k(mnemo, Position, "c1 (signed)< c2"); -} - -CALLBACK(brmi_Callback_PC) { - PC_Operation_k(mnemo, Position, "< 0"); -} - -CALLBACK(brne_Callback_PC) { - PC_Operation_k(mnemo, Position, "c1 != c2"); -} - -CALLBACK(brpl_Callback_PC) { - PC_Operation_k(mnemo, Position, "> 0"); -} - -CALLBACK(brsh_Callback_PC) { - PC_Operation_k(mnemo, Position, "c1 (unsigned)>= c2"); -} - -CALLBACK(brtc_Callback_PC) { - PC_Operation_k(mnemo, Position, "T == 0"); -} - -CALLBACK(brts_Callback_PC) { - PC_Operation_k(mnemo, Position, "T == 1"); -} - -CALLBACK(brvc_Callback_PC) { - PC_Operation_k(mnemo, Position, "Overflow == 0"); -} - -CALLBACK(brvs_Callback_PC) { - PC_Operation_k(mnemo, Position, "Overflow == 1"); -} - -CALLBACK(out_Callback_PC) { - int Register_Number; - const char *Register_Name; - - Register_Number = RA; - Register_Name = Resolve_IO_Register(Register_Number); - if(Register_Name) { - snprintf(cx->dis_code, 255, "IO[%s] = r%d;", Register_Name, Rr); - } else { - snprintf(cx->dis_code, 255, "IO[0x%02x] = r%d;", Register_Number, Rr); - snprintf(cx->dis_comment, 255, "%d", RA); - } -} - -CALLBACK(in_Callback_PC) { - int Register_Number; - const char *Register_Name; - - Register_Number = RA; - Register_Name = Resolve_IO_Register(Register_Number); - if(Register_Name) { - snprintf(cx->dis_code, 255, "r%d = IO[%s];", Rd, Register_Name); - } else { - snprintf(cx->dis_code, 255, "r%d = IO[0x%02x];", Rd, Register_Number); - snprintf(cx->dis_comment, 255, "%d", RA); - } -} - -CALLBACK(cli_Callback_PC) { - snprintf(cx->dis_code, 255, "Disable_Interrupts();"); -} - -CALLBACK(sei_Callback_PC) { - snprintf(cx->dis_code, 255, "Enable_Interrupts();"); -} - -CALLBACK(ret_Callback_PC) { - snprintf(cx->dis_code, 255, "return;"); - snprintf(cx->dis_after_code, 255, "\n"); -} - -CALLBACK(reti_Callback_PC) { - snprintf(cx->dis_code, 255, "ireturn;"); - snprintf(cx->dis_after_code, 255, "\n"); -} - -CALLBACK(andi_Callback_PC) { - PC_Operation_Rd16_K(mnemo); -} - -CALLBACK(subi_Callback_PC) { - PC_Operation_Rd16_K(mnemo); -} - -CALLBACK(sbci_Callback_PC) { - PC_Operation_Rd16_K(mnemo); -} - -CALLBACK(sbr_Callback_PC) { - PC_Operation_Rd16_K(mnemo); -} - -CALLBACK(ori_Callback_PC) { - PC_Operation_Rd16_K(mnemo); -} - -CALLBACK(ldi_Callback_PC) { - snprintf(cx->dis_code, 255, "r%d = %d;", Rd + 16, RK); - snprintf(cx->dis_comment, 255, "0x%02x", RK); -} - -CALLBACK(lds_Callback_PC) { - const char *MemAddress; - - MemAddress = Tagfile_Resolve_Mem_Address(Rk); - if(!MemAddress) { - snprintf(cx->dis_code, 255, "r%d = Memory[0x%04x];", Rd, Rk); - snprintf(cx->dis_comment, 255, "%d", Rk); - } else { - snprintf(cx->dis_code, 255, "r%d = %s;", Rd, MemAddress); - snprintf(cx->dis_comment, 255, "0x%04x", Rk); - } -} - -CALLBACK(sts_Callback_PC) { - const char *MemAddress; - - MemAddress = Tagfile_Resolve_Mem_Address(Rk); - if(!MemAddress) { - snprintf(cx->dis_code, 255, "Memory[0x%04x] = r%d;", Rk, Rd); - snprintf(cx->dis_comment, 255, "%d", Rk); - } else { - snprintf(cx->dis_code, 255, "%s = r%d;", MemAddress, Rd); - snprintf(cx->dis_comment, 255, "0x%04x", Rk); - } -} - -CALLBACK(call_Callback_PC) { - int Pos; - - Pos = FixTargetAddress(2 * Rk); - Register_JumpCall(Position, Pos, mnemo, 1); - if(cx->dis_opts.Process_Labels == 0) { - snprintf(cx->dis_code, 255, "0x%02x();", Pos); - } else { - char *LabelName; - char *LabelComment = NULL; - - LabelName = Get_Label_Name(Pos, &LabelComment); - snprintf(cx->dis_code, 255, "%s();", LabelName); - if(LabelComment != NULL) { - snprintf(cx->dis_comment, 255, "%s", LabelComment); - } - } -} - -CALLBACK(rcall_Callback_PC) { - int Offset; - - Offset = 2 * (Rk); - if(Offset > 4096) - Offset -= 8192; - - int Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, mnemo, 1); - if(!cx->dis_opts.Process_Labels) { - snprintf(cx->dis_comment, 255, "0x%02x();", Target); - } else { - char *LabelName; - char *LabelComment = NULL; - - LabelName = Get_Label_Name(Target, &LabelComment); - snprintf(cx->dis_code, 255, "%s();", LabelName); - if(LabelComment != NULL) { - snprintf(cx->dis_comment, 255, "%s", LabelComment); - } - } -} - -CALLBACK(ror_Callback_PC) { - PC_Operation_Rd(mnemo); -} - -CALLBACK(lsr_Callback_PC) { - PC_Operation_Rd(mnemo); -} - -CALLBACK(swap_Callback_PC) { - PC_Operation_Rd(mnemo); -} - -CALLBACK(eor_Callback_PC) { - if(Rd == Rr) { - PC_Operation_Rd(OPCODE_clr); - } else { - PC_Operation_Rd_Rr(mnemo); - } -} - -CALLBACK(jmp_Callback_PC) { - int Pos; - - Pos = FixTargetAddress(2 * Rk); - if(cx->dis_opts.Process_Labels == 0) { - snprintf(cx->dis_code, 255, "goto 0x%02x;", Pos); - } else { - snprintf(cx->dis_code, 255, "goto %s;", Get_Label_Name(Pos, NULL)); - } - Register_JumpCall(Position, Pos, mnemo, 0); -} - -CALLBACK(rjmp_Callback_PC) { - int Offset; - - Offset = 2 * (Rk); - if(Offset > 4096) - Offset -= 8192; - - int Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, mnemo, 0); - - if(cx->dis_opts.Process_Labels == 0) { - if(Offset > 0) { - snprintf(cx->dis_code, 255, "goto .+%d;", Offset); - } else { - snprintf(cx->dis_code, 255, "goto .%d", Offset); - } - if(Target >= 0) { - snprintf(cx->dis_comment, 255, "0x%02x", Target); - } else { - snprintf(cx->dis_comment, 255, "-0x%02x - Illegal jump position -- specify flash size!", -(Target)); - } - } else { - snprintf(cx->dis_code, 255, "goto %s;", Get_Label_Name(Position + Offset + 2, NULL)); - } -} - -CALLBACK(cpi_Callback_PC) { - if(RK == 0) { - snprintf(cx->dis_code, 255, "cmp(r%d, 0);", Rd + 16); - } else { - snprintf(cx->dis_code, 255, "cmp(r%d, 0x%02x);", Rd + 16, RK); - snprintf(cx->dis_comment, 255, "%d", RK); - } -} - -CALLBACK(asr_Callback_PC) { - PC_Operation_Rd(mnemo); -} - -CALLBACK(dec_Callback_PC) { - snprintf(cx->dis_code, 255, "r%d--;", Rd); -} - -CALLBACK(inc_Callback_PC) { - snprintf(cx->dis_code, 255, "r%d++;", Rd); -} - -CALLBACK(cp_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(cpc_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(cpse_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(and_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(or_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(mul_Callback_PC) { - PC_Operation_Rd_Rr(mnemo); -} - -CALLBACK(sbi_Callback_PC) { - PC_Operation_A_b(mnemo); -} - -CALLBACK(sbic_Callback_PC) { - PC_Operation_A_b(mnemo); -} - -CALLBACK(sbis_Callback_PC) { - PC_Operation_A_b(mnemo); -} - -CALLBACK(cbi_Callback_PC) { - PC_Operation_A_b(mnemo); -} - -CALLBACK(ser_Callback_PC) { - snprintf(cx->dis_code, 255, "r%d = 0xff;", Rd + 16); - snprintf(cx->dis_comment, 255, "255"); -} - -CALLBACK(adiw_Callback_PC) { - if(RK != 1) { - snprintf(cx->dis_code, 255, "[r%d:r%d] += 0x%02x;", 2 * Rd + 25, 2 * Rd + 24, RK); - snprintf(cx->dis_comment, 255, "%d", RK); - } else { - snprintf(cx->dis_code, 255, "[r%d:r%d]++;", 2 * Rd + 25, 2 * Rd + 24); - } -} - -CALLBACK(movw_Callback_PC) { - snprintf(cx->dis_code, 255, "[r%d:r%d] = [r%d:r%d];", (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); -} - -CALLBACK(lpm1_Callback_PC) { - snprintf(cx->dis_code, 255, "r0 = Flash[r30:r31];"); -} - -CALLBACK(stx2_Callback_PC) { - snprintf(cx->dis_code, 255, "Flash[[r26:r27]++] = r%d;", Rr); -} diff --git a/src/disasm_callbacks_pseudocode.h b/src/disasm_callbacks_pseudocode.h deleted file mode 100644 index 6acf2ada..00000000 --- a/src/disasm_callbacks_pseudocode.h +++ /dev/null @@ -1,106 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -void PC_Operation_Simple(AVR_opcode mnemo); -void PC_Operation_Rd(AVR_opcode mnemo); -void PC_Operation_Rd16(AVR_opcode mnemo); -void PC_Operation_Rd_Rr(AVR_opcode mnemo); -void PC_Operation_Rd16_Rr16(AVR_opcode mnemo); -void PC_Operation_Rd16_K(AVR_opcode mnemo); -void PC_Operation_Rd_K(AVR_opcode mnemo); -void PC_Operation_RdW_K(AVR_opcode mnemo); -void PC_Operation_RdW_RrW(AVR_opcode mnemo); -void PC_Operation_s_k(AVR_opcode mnemo, int Position); -void PC_Operation_r_b(AVR_opcode mnemo); -void PC_Operation_Rd_b(AVR_opcode mnemo); -void PC_Operation_A_b(AVR_opcode mnemo); -void PC_Operation_s(AVR_opcode mnemo); -void PC_Operation_k(AVR_opcode mnemo, int Position, char *Pseudocode); -void adc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void add_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sub_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void mov_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brcc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brcs_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void breq_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brge_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brhc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brhs_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brid_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brie_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brlo_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brlt_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brmi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brne_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brpl_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brsh_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brtc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brts_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brvc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void brvs_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void out_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void in_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void cli_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sei_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void ret_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void reti_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void andi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void subi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbci_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbr_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void ori_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void lds_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sts_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void call_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void rcall_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void ror_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void lsr_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void swap_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void eor_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void jmp_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void rjmp_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void asr_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void dec_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void inc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void cp_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpc_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpse_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void and_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void or_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void mul_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbic_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbis_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void cbi_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void ser_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void adiw_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void movw_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void lpm1_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); -void stx2_Callback_PC(const char *Bitstream, int Position, AVR_opcode mnemo); diff --git a/src/disasm_ioregisters.c b/src/disasm_ioregisters.c index ce87ca49..27e48a9b 100644 --- a/src/disasm_ioregisters.c +++ b/src/disasm_ioregisters.c @@ -117,8 +117,6 @@ const char *Resolve_IO_Register(int Number) { void Emit_Used_IO_Registers() { unsigned int i; - if(cx->dis_opts.Show_PseudoCode) - return; for(i = 0; i < KnownIORegistersCount; i++) { if(KnownIORegisters[i].Used) printf(".equ %s, 0x%x\n", KnownIORegisters[i].Name, KnownIORegisters[i].Address); diff --git a/src/libavrdude.h b/src/libavrdude.h index a4d72b6c..46d217cc 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1448,17 +1448,16 @@ typedef struct { typedef struct { - char Show_Addresses; - char Show_Opcodes; - char Show_Comments; - char Show_Cycles; - char Show_PseudoCode; + int Show_Addresses; + int Show_Opcodes; + int Show_Comments; + int Show_Cycles; char Filename[256]; char MCU[8]; const char *Tagfile; - char CodeStyle; - char Process_Labels; - char Pass; + int CodeStyle; + int Process_Labels; + int Pass; int FlashSize; int AVR_Level; } Disasm_options; diff --git a/src/term.c b/src/term.c index d10a44f9..5aca15d1 100644 --- a/src/term.c +++ b/src/term.c @@ -236,7 +236,6 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, " -c show comments, -C don't show comments\n" " -q show call cycles, -Q don't show call cycles\n" " -s use avr-gcc code style, -S use AVR instruction set code style\n" - " -p include pseudocode, -P don't include pseudocode\n" " -l preprocess jump/call, -L don't preprocess jump/call\n" " -t= set the tagfile to be used\n" ); @@ -460,7 +459,6 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.Show_Opcodes = 0; cx->dis_opts.Show_Comments = 1; cx->dis_opts.Show_Cycles = 0; - cx->dis_opts.Show_PseudoCode = 0; cx->dis_opts.Filename[0] = 0; cx->dis_opts.MCU[0] = 0; cx->dis_opts.Tagfile = NULL; @@ -480,31 +478,28 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c argv[itemac++] = argv[ai]; else { while(*++q) { - switch((chr = *q & 0xff)) { + switch((chr = *q & 0x7f)) { case '?': case 'h': help++; break; case 'a': case 'A': - cx->dis_opts.Show_Addresses = tolower(chr); + cx->dis_opts.Show_Addresses = !!islower(chr); break; case 'o': case 'O': - cx->dis_opts.Show_Opcodes = tolower(chr); + cx->dis_opts.Show_Opcodes = !!islower(chr); break; case 'c': case 'C': - cx->dis_opts.Show_Comments = tolower(chr); + cx->dis_opts.Show_Comments = !!islower(chr); break; case 'q': case 'Q': - cx->dis_opts.Show_Cycles = tolower(chr); - break; - case 'p': case 'P': - cx->dis_opts.Show_PseudoCode = tolower(chr); + cx->dis_opts.Show_Cycles = !!islower(chr); break; case 's': case 'S': - cx->dis_opts.CodeStyle = tolower(chr)? CODESTYLE_AVRGCC: CODESTYLE_AVR_INSTRUCTION_SET; + cx->dis_opts.CodeStyle = islower(chr)? CODESTYLE_AVRGCC: CODESTYLE_AVR_INSTRUCTION_SET; break; case 'l': case 'L': - cx->dis_opts.Process_Labels = tolower(chr); + cx->dis_opts.Process_Labels = !!islower(chr); break; case 't': if(*++q == '=') From a7cf86da1b0acbdf98521b0305d902fdaf418735 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 20:58:50 +0100 Subject: [PATCH 289/422] Show opcode cycles depending on part --- src/avr_opcodes.c | 328 +++++++++++++++++++++++----------------------- src/disasm.c | 2 +- src/libavrdude.h | 15 ++- src/term.c | 9 ++ 4 files changed, 183 insertions(+), 171 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index f5e19e7f..ba061b6a 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -22,178 +22,178 @@ const AVR_opcode_data avr_opcodes[164] = { // Arithmetic and Logic Instructions - {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OP_AVR1, OPCODE_add, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, - {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OP_AVR1, OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, - {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OP_AVR2nRC, OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", "2", "2", "2", "n/a", "d in {24, 26, 28, 30}"}, - {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OP_AVR1, OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, - {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OP_AVR1, OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, - {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OP_AVR1, OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, - {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OP_AVR1, OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", "1", "1", "1", "1", "d=16..31"}, - {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OP_AVR2nRC, OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", "2", "2", "2", "n/a", "d in {24, 26, 28, 30}"}, - {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OP_AVR1, OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", "1", "1", "1", "1", ""}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", "1", "1", "1", "1", "d = 16..31"}, - {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OP_AVR1, OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", "1", "1", "1", "1", ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", "1", "1", "1", "1", ""}, - {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OP_AVR1, OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", "1", "1", "1", "1", ""}, - {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", "1", "1", "1", "1", ""}, - {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", "1", "1", "1", "1", "alias for ORI Rd, K"}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", "1", "1", "1", "1", "alias for ANDI Rd, (0xFF - K)"}, - {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", "1", "1", "1", "1", ""}, - {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", "1", "1", "1", "1", ""}, - {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", "1", "1", "1", "1", "alias for AND Rd, Rd"}, - {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", "1", "1", "1", "1", "alias for EOR Rd, Rd"}, - {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", "1", "1", "1", "1", "alias for LDI Rd, 0xFF"}, - {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", "2", "2", "2", "n/a", ""}, - {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", "2", "2", "2", "n/a", "d, r=16..31"}, - {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", "2", "2", "2", "n/a", "d, r=16..23"}, - {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OP_AVR4, OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", "2", "2", "2", "n/a", "r, d = 16..23"}, - {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OP_AVR4, OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", "2", "2", "2", "n/a", "r, d = 16..23"}, - {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", "2", "2", "2", "n/a", "r, d = 16..23"}, - {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OP_AVR_XM, OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", "n/a", "1/2", "n/a", "n/a", ""}, + {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OP_AVR1, OPCODE_add, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OP_AVR1, OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OP_AVR2nRC, OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, + {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OP_AVR1, OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OP_AVR1, OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OP_AVR1, OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OP_AVR1, OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d=16..31"}, + {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OP_AVR2nRC, OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, + {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OP_AVR1, OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", {"1", "1", "1", "1"}, "d = 16..31"}, + {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OP_AVR1, OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OP_AVR1, OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ORI Rd, K"}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ANDI Rd, (0xFF - K)"}, + {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for AND Rd, Rd"}, + {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for EOR Rd, Rd"}, + {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for LDI Rd, 0xFF"}, + {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", {"2", "2", "2", "n/a"}, ""}, + {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..31"}, + {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..23"}, + {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OP_AVR4, OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, + {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OP_AVR4, OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, + {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, + {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OP_AVR_XM, OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", {"n/a", "1/2", "n/a", "n/a"}, ""}, // Branch Instructions - {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OP_AVR1, OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", "2", "2", "2", "2", ""}, - {0xffff, 0x9409, 1, "1001 0100 0000 1001", OP_AVR2, OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "2", "2", "2", "2", ""}, - {0xffff, 0x9419, 1, "1001 0100 0001 1001", OP_AVR_XL, OPCODE_eijmp, "eijmp", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "2", "2", "2", "n/a", ""}, - {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", "3", "3", "3", "n/a", ""}, - {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OP_AVR1, OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", "3/4", "2/3", "2/3", "3", ""}, - {0xffff, 0x9509, 1, "1001 0101 0000 1001", OP_AVR2, OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", "3/4", "2/3", "2/3", "3", ""}, - {0xffff, 0x9519, 1, "1001 0101 0001 1001", OP_AVR_XL, OPCODE_eicall, "eicall", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", "4", "3", "3", "n/a", ""}, - {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", "4/5", "3/4", "3/4", "n/a", ""}, - {0xffff, 0x9508, 1, "1001 0101 0000 1000", OP_AVR1, OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", "4/5", "4/5", "4/5", "6", ""}, - {0xffff, 0x9518, 1, "1001 0101 0001 1000", OP_AVR1, OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", "4/5", "4/5", "4/5", "6", ""}, - {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OP_AVR1, OPCODE_cpse, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", ""}, - {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OP_AVR1, OPCODE_cp, "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, - {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OP_AVR1, OPCODE_cpc, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", "1", "1", "1", "1", ""}, - {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OP_AVR1, OPCODE_cpi, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", "1", "1", "1", "1", "d = 16..31"}, - {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OP_AVR1, OPCODE_sbrc, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", ""}, - {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OP_AVR1, OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", "1/2/3", "1/2/3", "1/2/3", "1/2", ""}, - {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OP_AVR1, OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", ""}, - {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OP_AVR1, OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", "1/2/3", "2/3/4", "1/2/3", "1/2", ""}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OP_AVR1, OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 1, k (Z Zero)"}, - {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OP_AVR1, OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 2, k (N Negative)"}, - {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OP_AVR1, OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OP_AVR1, OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 4, k (S Sign)"}, - {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OP_AVR1, OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 5, k (H Half carry)"}, - {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OP_AVR1, OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 6, k (T Transfer bit)"}, - {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OP_AVR1, OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBS 7, k (I Interrupt enable)"}, - {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OP_AVR1, OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", ""}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OP_AVR1, OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 1, k (Z Zero)"}, - {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OP_AVR1, OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 2, k (N Negative)"}, - {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OP_AVR1, OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OP_AVR1, OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 4, k (S Sign)"}, - {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OP_AVR1, OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 5, k (H Half carry)"}, - {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OP_AVR1, OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 6, k (T Transfer bit)"}, - {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OP_AVR1, OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", "alias for BRBC 7, k (I Interrupt enable)"}, - {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OP_AVR1, OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", "1/2", "1/2", "1/2", "1/2", ""}, + {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OP_AVR1, OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", {"2", "2", "2", "2"}, ""}, + {0xffff, 0x9409, 1, "1001 0100 0000 1001", OP_AVR2, OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, ""}, + {0xffff, 0x9419, 1, "1001 0100 0001 1001", OP_AVR_XL, OPCODE_eijmp, "eijmp", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, ""}, + {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", {"3", "3", "3", "n/a"}, ""}, + {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OP_AVR1, OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", {"3/4", "2/3", "2/3", "3"}, ""}, + {0xffff, 0x9509, 1, "1001 0101 0000 1001", OP_AVR2, OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, ""}, + {0xffff, 0x9519, 1, "1001 0101 0001 1001", OP_AVR_XL, OPCODE_eicall, "eicall", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, ""}, + {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", {"4/5", "3/4", "3/4", "n/a"}, ""}, + {0xffff, 0x9508, 1, "1001 0101 0000 1000", OP_AVR1, OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, ""}, + {0xffff, 0x9518, 1, "1001 0101 0001 1000", OP_AVR1, OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, ""}, + {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OP_AVR1, OPCODE_cpse, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OP_AVR1, OPCODE_cp, "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OP_AVR1, OPCODE_cpc, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OP_AVR1, OPCODE_cpi, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d = 16..31"}, + {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OP_AVR1, OPCODE_sbrc, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OP_AVR1, OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OP_AVR1, OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, + {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OP_AVR1, OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OP_AVR1, OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 1, k (Z Zero)"}, + {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OP_AVR1, OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 2, k (N Negative)"}, + {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OP_AVR1, OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OP_AVR1, OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 4, k (S Sign)"}, + {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OP_AVR1, OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 5, k (H Half carry)"}, + {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OP_AVR1, OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 6, k (T Transfer bit)"}, + {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OP_AVR1, OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 7, k (I Interrupt enable)"}, + {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OP_AVR1, OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OP_AVR1, OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 1, k (Z Zero)"}, + {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OP_AVR1, OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 2, k (N Negative)"}, + {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OP_AVR1, OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OP_AVR1, OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 4, k (S Sign)"}, + {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OP_AVR1, OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 5, k (H Half carry)"}, + {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OP_AVR1, OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 6, k (T Transfer bit)"}, + {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OP_AVR1, OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 7, k (I Interrupt enable)"}, + {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OP_AVR1, OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, // Data Transfer Instructions - {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OP_AVR1, OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", "1", "1", "1", "1", ""}, - {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", "1", "1", "1", "n/a", ""}, - {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", "1", "1", "1", "1", "d=16..31"}, - {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "2", "3", "3", "2", ""}, - {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", "n/a", "n/a", "n/a", "2", "AVRrc only (TPI parts)"}, - {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OP_AVR2, OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", "2", "2", "2", "1/2", ""}, - {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OP_AVR2, OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", "2", "2", "2", "2/3", ""}, - {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OP_AVR2, OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", "2", "3", "2", "2/3", ""}, - {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OP_AVR2, OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", "2", "2", "2", "1/2", "alias for LDD Rd, Y+0"}, - {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OP_AVR2, OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", "2", "2", "2", "2/3", ""}, - {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OP_AVR2, OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", "2", "3", "2", "2/3", ""}, - {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OP_AVR2nRC, OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", "2", "3", "2", "n/a", ""}, - {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OP_AVR1, OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", "2", "2", "2", "1/2", "alias for LDD Rd,Z+0"}, - {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OP_AVR1, OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", "2", "2", "2", "2/3", ""}, - {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OP_AVR1, OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", "2", "3", "2", "2/3", ""}, - {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OP_AVR2nRC, OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", "2", "3", "2", "n/a", ""}, - {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "2", "2", "2", "1", ""}, - {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OP_AVR_RC, OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", "n/a", "n/a", "n/a", "1", "AVRrc only (TPI parts)"}, - {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OP_AVR2, OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", "2", "1", "1", "1", ""}, - {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OP_AVR2, OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", "2", "1", "1", "1", ""}, - {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OP_AVR2, OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", "2", "2", "1", "1", ""}, - {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OP_AVR2, OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", "2", "1", "1", "1", "alias for STD Y+0, Rr"}, - {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OP_AVR2, OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", "2", "1", "1", "1", ""}, - {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OP_AVR2, OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", "2", "2", "1", "1", ""}, - {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OP_AVR2nRC, OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", "2", "2", "1", "n/a", ""}, - {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OP_AVR1, OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", "2", "1", "1", "1", "alias for STD Z+0, Rr"}, - {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OP_AVR1, OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", "2", "1", "1", "1", ""}, - {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OP_AVR1, OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", "2", "2", "1", "1", ""}, - {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OP_AVR2nRC, OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", "2", "2", "1", "n/a", ""}, - {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OP_AVR1nRC, OPCODE_lpm_1, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", "3", "3", "3", "n/a", ""}, - {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OP_AVR25, OPCODE_lpm_2, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", "3", "3", "3", "n/a", ""}, - {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OP_AVR25, OPCODE_lpm_3, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", ""}, - {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OP_AVR_L, OPCODE_elpm_1, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", ""}, - {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OP_AVR_L, OPCODE_elpm_2, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", "3", "3", "3", "n/a", ""}, - {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OP_AVR_L, OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", "3", "3", "3", "n/a", ""}, - {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OP_AVR25, OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", "-", "-", "-", "-", ""}, - {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OP_AVR_XTM, OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", "n/a", "-", "-", "n/a", ""}, - {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", "1", "1", "1", "1", ""}, - {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", "1", "1", "1", "1", ""}, - {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", "2", "1", "1", "1", ""}, - {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", "2", "2", "2", "3", ""}, - {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", ""}, - {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", ""}, - {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", ""}, - {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", "n/a", "1", "n/a", "n/a", ""}, + {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OP_AVR1, OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", {"1", "1", "1", "1"}, ""}, + {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", {"1", "1", "1", "n/a"}, ""}, + {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", {"1", "1", "1", "1"}, "d=16..31"}, + {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"2", "3", "3", "2"}, ""}, + {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts)"}, + {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OP_AVR2, OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", {"2", "2", "2", "1/2"}, ""}, + {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OP_AVR2, OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", {"2", "2", "2", "2/3"}, ""}, + {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OP_AVR2, OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", {"2", "3", "2", "2/3"}, ""}, + {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OP_AVR2, OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", {"2", "2", "2", "1/2"}, "alias for LDD Rd, Y+0"}, + {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OP_AVR2, OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", {"2", "2", "2", "2/3"}, ""}, + {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OP_AVR2, OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", {"2", "3", "2", "2/3"}, ""}, + {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OP_AVR2nRC, OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", {"2", "3", "2", "n/a"}, ""}, + {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OP_AVR1, OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", {"2", "2", "2", "1/2"}, "alias for LDD Rd,Z+0"}, + {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OP_AVR1, OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"2", "2", "2", "2/3"}, ""}, + {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OP_AVR1, OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", {"2", "3", "2", "2/3"}, ""}, + {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OP_AVR2nRC, OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", {"2", "3", "2", "n/a"}, ""}, + {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", {"2", "2", "2", "1"}, ""}, + {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OP_AVR_RC, OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts)"}, + {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OP_AVR2, OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OP_AVR2, OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OP_AVR2, OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, + {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OP_AVR2, OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for STD Y+0, Rr"}, + {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OP_AVR2, OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OP_AVR2, OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, + {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OP_AVR2nRC, OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, + {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OP_AVR1, OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for STD Z+0, Rr"}, + {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OP_AVR1, OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OP_AVR1, OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", {"2", "2", "1", "1"}, ""}, + {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OP_AVR2nRC, OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, + {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OP_AVR1nRC, OPCODE_lpm_1, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", {"3", "3", "3", "n/a"}, ""}, + {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OP_AVR25, OPCODE_lpm_2, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", {"3", "3", "3", "n/a"}, ""}, + {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OP_AVR25, OPCODE_lpm_3, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, + {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OP_AVR_L, OPCODE_elpm_1, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", {"3", "3", "3", "n/a"}, ""}, + {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OP_AVR_L, OPCODE_elpm_2, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", {"3", "3", "3", "n/a"}, ""}, + {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OP_AVR_L, OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, + {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OP_AVR25, OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", {"-", "-", "-", "-"}, ""}, + {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OP_AVR_XTM, OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", {"n/a", "-", "-", "n/a"}, ""}, + {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", {"1", "1", "1", "1"}, ""}, + {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", {"2", "2", "2", "3"}, ""}, + {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions - {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", "1", "1", "1", "1", "alias for ADD Rd, Rd"}, - {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OP_AVR1, OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", ""}, - {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", "1", "1", "1", "1", "alias for ADC Rd, Rd"}, - {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OP_AVR1, OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", ""}, - {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OP_AVR1, OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", "1", "1", "1", "1", ""}, - {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OP_AVR1, OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", "1", "1", "1", "1", ""}, - {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OP_AVR1, OPCODE_bset, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", "1", "1", "1", "1", ""}, - {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OP_AVR1, OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", "1", "1", "1", "1", "s = 0-7 = C,Z,N,V,S,H,T,I"}, - {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OP_AVR1, OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", "2", "1", "1", "1", ""}, - {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OP_AVR1, OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", "2", "1", "1", "1", ""}, - {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OP_AVR1, OPCODE_bst, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", "1", "1", "1", "1", ""}, - {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OP_AVR1, OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", "1", "1", "1", "1", ""}, - {0xffff, 0x9408, 1, "1001 0100 0000 1000", OP_AVR1, OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", "1", "1", "1", "1", "alias for BSET 0"}, - {0xffff, 0x9488, 1, "1001 0100 1000 1000", OP_AVR1, OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", "1", "1", "1", "1", "alias for BCLR 0"}, - {0xffff, 0x9428, 1, "1001 0100 0010 1000", OP_AVR1, OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", "1", "1", "1", "1", "alias for BSET 2"}, - {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OP_AVR1, OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", "1", "1", "1", "1", "alias for BCLR 2"}, - {0xffff, 0x9418, 1, "1001 0100 0001 1000", OP_AVR1, OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", "1", "1", "1", "1", "alias for BSET 1"}, - {0xffff, 0x9498, 1, "1001 0100 1001 1000", OP_AVR1, OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", "1", "1", "1", "1", "alias for BCLR 1"}, - {0xffff, 0x9478, 1, "1001 0100 0111 1000", OP_AVR1, OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", "1", "1", "1", "1", "alias for BSET 7"}, - {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OP_AVR1, OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", "1", "1", "1", "1", "alias for BCLR 7"}, - {0xffff, 0x9448, 1, "1001 0100 0100 1000", OP_AVR1, OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", "1", "1", "1", "1", "alias for BSET 4"}, - {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OP_AVR1, OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", "1", "1", "1", "1", "alias for BCLR 4"}, - {0xffff, 0x9438, 1, "1001 0100 0011 1000", OP_AVR1, OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", "1", "1", "1", "1", "alias for BSET 3"}, - {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OP_AVR1, OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", "1", "1", "1", "1", "alias for BCLR 3"}, - {0xffff, 0x9468, 1, "1001 0100 0110 1000", OP_AVR1, OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", "1", "1", "1", "1", "alias for BSET 6"}, - {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OP_AVR1, OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", "1", "1", "1", "1", "alias for BCLR 6"}, - {0xffff, 0x9458, 1, "1001 0100 0101 1000", OP_AVR1, OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", "1", "1", "1", "1", "alias for BSET 5"}, - {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OP_AVR1, OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", "1", "1", "1", "1", "alias for BCLR 5"}, + {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADD Rd, Rd"}, + {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OP_AVR1, OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADC Rd, Rd"}, + {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OP_AVR1, OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OP_AVR1, OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OP_AVR1, OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", {"1", "1", "1", "1"}, ""}, + {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OP_AVR1, OPCODE_bset, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", {"1", "1", "1", "1"}, ""}, + {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OP_AVR1, OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, + {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OP_AVR1, OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", {"2", "1", "1", "1"}, ""}, + {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OP_AVR1, OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", {"2", "1", "1", "1"}, ""}, + {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OP_AVR1, OPCODE_bst, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", {"1", "1", "1", "1"}, ""}, + {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OP_AVR1, OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, + {0xffff, 0x9408, 1, "1001 0100 0000 1000", OP_AVR1, OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", {"1", "1", "1", "1"}, "alias for BSET 0"}, + {0xffff, 0x9488, 1, "1001 0100 1000 1000", OP_AVR1, OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", {"1", "1", "1", "1"}, "alias for BCLR 0"}, + {0xffff, 0x9428, 1, "1001 0100 0010 1000", OP_AVR1, OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", {"1", "1", "1", "1"}, "alias for BSET 2"}, + {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OP_AVR1, OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", {"1", "1", "1", "1"}, "alias for BCLR 2"}, + {0xffff, 0x9418, 1, "1001 0100 0001 1000", OP_AVR1, OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", {"1", "1", "1", "1"}, "alias for BSET 1"}, + {0xffff, 0x9498, 1, "1001 0100 1001 1000", OP_AVR1, OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", {"1", "1", "1", "1"}, "alias for BCLR 1"}, + {0xffff, 0x9478, 1, "1001 0100 0111 1000", OP_AVR1, OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", {"1", "1", "1", "1"}, "alias for BSET 7"}, + {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OP_AVR1, OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", {"1", "1", "1", "1"}, "alias for BCLR 7"}, + {0xffff, 0x9448, 1, "1001 0100 0100 1000", OP_AVR1, OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", {"1", "1", "1", "1"}, "alias for BSET 4"}, + {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OP_AVR1, OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", {"1", "1", "1", "1"}, "alias for BCLR 4"}, + {0xffff, 0x9438, 1, "1001 0100 0011 1000", OP_AVR1, OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", {"1", "1", "1", "1"}, "alias for BSET 3"}, + {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OP_AVR1, OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", {"1", "1", "1", "1"}, "alias for BCLR 3"}, + {0xffff, 0x9468, 1, "1001 0100 0110 1000", OP_AVR1, OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", {"1", "1", "1", "1"}, "alias for BSET 6"}, + {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OP_AVR1, OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", {"1", "1", "1", "1"}, "alias for BCLR 6"}, + {0xffff, 0x9458, 1, "1001 0100 0101 1000", OP_AVR1, OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", {"1", "1", "1", "1"}, "alias for BSET 5"}, + {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OP_AVR1, OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", {"1", "1", "1", "1"}, "alias for BCLR 5"}, // MCU Control Instructions - {0xffff, 0x9598, 1, "1001 0101 1001 1000", OP_AVR1, OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", "-", "-", "-", "-", "not available on all parts"}, - {0xffff, 0x0000, 1, "0000 0000 0000 0000", OP_AVR1, OPCODE_nop, "nop", "-", "No Operation", "-", "None", "1", "1", "1", "1", ""}, - {0xffff, 0x9588, 1, "1001 0101 1000 1000", OP_AVR1, OPCODE_sleep, "sleep", "-", "Sleep", "(cf documentation)", "None", "-", "-", "-", "-", ""}, - {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OP_AVR1, OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", "1", "1", "1", "1", ""}, + {0xffff, 0x9598, 1, "1001 0101 1001 1000", OP_AVR1, OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", {"-", "-", "-", "-"}, "not available on all parts"}, + {0xffff, 0x0000, 1, "0000 0000 0000 0000", OP_AVR1, OPCODE_nop, "nop", "-", "No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xffff, 0x9588, 1, "1001 0101 1000 1000", OP_AVR1, OPCODE_sleep, "sleep", "-", "Sleep", "(cf documentation)", "None", {"-", "-", "-", "-"}, ""}, + {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OP_AVR1, OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", {"1", "1", "1", "1"}, ""}, // Unallocated codes - {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OP_AVR1, OPCODE_x_nop_1, "nop", "", "", "", "", "", "", "", "", "xxxx xxxx != 0000 0000"}, - {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OP_AVR1, OPCODE_x_nop_2, "nop", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OP_AVR1, OPCODE_x_nop_3, "nop", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OP_AVR1, OPCODE_x_nop_4, "nop", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OP_AVR1, OPCODE_x_nop_5, "nop", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR1, OPCODE_x_nop_6, "nop", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR1, OPCODE_x_nop_7, "nop", "", "", "", "", "", "", "", "", ""}, - {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR2, OPCODE_x_icall, "icall", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_XL, OPCODE_x_eicall, "eicall", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR1, OPCODE_x_ret, "ret", "", "", "", "", "", "", "", "", "xx != 00"}, - {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR1, OPCODE_x_reti, "reti", "", "", "", "", "", "", "", "", "xx != 00"}, - {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR1, OPCODE_x_nop_8, "nop", "", "", "", "", "", "", "", "", ""}, - {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR1, OPCODE_x_nop_9, "nop", "", "", "", "", "", "", "", "", ""}, - {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR1, OPCODE_x_nop_a, "nop", "", "", "", "", "", "", "", "", ""}, - {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR2, OPCODE_x_ijmp, "ijmp", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_XL, OPCODE_x_eijmp, "eijmp", "", "", "", "", "", "", "", "", "xxx != 000"}, - {0xfe08, 0xf808, 1, "1111 100x xxxx 1xxx", OP_AVR1, OPCODE_x_bld, "bld", "Rd, b", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfa08, 1, "1111 101x xxxx 1xxx", OP_AVR1, OPCODE_x_bst, "bst", "Rd, b", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfc08, 1, "1111 110x xxxx 1xxx", OP_AVR1, OPCODE_x_sbrc, "sbrc", "Rr, b", "", "", "", "", "", "", "", ""}, - {0xfe08, 0xfe08, 1, "1111 111x xxxx 1xxx", OP_AVR1, OPCODE_x_sbrs, "sbrs", "Rr, b", "", "", "", "", "", "", "", ""}, + {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OP_AVR1, OPCODE_x_nop_1, "nop", "", "", "", "", {"", "", "", ""}, "xxxx xxxx != 0000 0000"}, + {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OP_AVR1, OPCODE_x_nop_2, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OP_AVR1, OPCODE_x_nop_3, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OP_AVR1, OPCODE_x_nop_4, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OP_AVR1, OPCODE_x_nop_5, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR1, OPCODE_x_nop_6, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR1, OPCODE_x_nop_7, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR2, OPCODE_x_icall, "icall", "", "", "", "", {"", "", "", ""}, "xxx != 000"}, + {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_XL, OPCODE_x_eicall, "eicall", "", "", "", "", {"", "", "", ""}, "xxx != 000"}, + {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR1, OPCODE_x_ret, "ret", "", "", "", "", {"", "", "", ""}, "xx != 00"}, + {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR1, OPCODE_x_reti, "reti", "", "", "", "", {"", "", "", ""}, "xx != 00"}, + {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR1, OPCODE_x_nop_8, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR1, OPCODE_x_nop_9, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR1, OPCODE_x_nop_a, "nop", "", "", "", "", {"", "", "", ""}, ""}, + {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR2, OPCODE_x_ijmp, "ijmp", "", "", "", "", {"", "", "", ""}, "xxx != 000"}, + {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_XL, OPCODE_x_eijmp, "eijmp", "", "", "", "", {"", "", "", ""}, "xxx != 000"}, + {0xfe08, 0xf808, 1, "1111 100x xxxx 1xxx", OP_AVR1, OPCODE_x_bld, "bld", "Rd, b", "", "", "", {"", "", "", ""}, ""}, + {0xfe08, 0xfa08, 1, "1111 101x xxxx 1xxx", OP_AVR1, OPCODE_x_bst, "bst", "Rd, b", "", "", "", {"", "", "", ""}, ""}, + {0xfe08, 0xfc08, 1, "1111 110x xxxx 1xxx", OP_AVR1, OPCODE_x_sbrc, "sbrc", "Rr, b", "", "", "", {"", "", "", ""}, ""}, + {0xfe08, 0xfe08, 1, "1111 111x xxxx 1xxx", OP_AVR1, OPCODE_x_sbrs, "sbrs", "Rr, b", "", "", "", {"", "", "", ""}, ""}, }; diff --git a/src/disasm.c b/src/disasm.c index dcd8fabe..65bf2044 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -265,7 +265,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) { if(cx->dis_opts.Show_Addresses) printf("%4x: ", Pos); if(cx->dis_opts.Show_Cycles) // @@@ select correct clocks_xx - printf("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clocks_e); + printf("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clock[cx->dis_opts.cycle_index]); if(cx->dis_opts.Show_Opcodes) { // Now display the Opcode diff --git a/src/libavrdude.h b/src/libavrdude.h index 46d217cc..38d2a0d2 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1446,6 +1446,13 @@ typedef struct { #define STR_XINT32 STR_4 #define STR_XINT64 STR_8 +typedef enum { + OP_AVRe, + OP_AVRxm, + OP_AVRxt, + OP_AVRrc, + OP_AVR_cycle_N +} AVR_cycle_index; typedef struct { int Show_Addresses; @@ -1460,6 +1467,7 @@ typedef struct { int Pass; int FlashSize; int AVR_Level; + AVR_cycle_index cycle_index; } Disasm_options; typedef enum { @@ -1547,8 +1555,6 @@ typedef enum { #define PART_AVR_XT (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_XTM) #define PART_AVR_XM (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_XM|OP_AVR_XTM) - - typedef struct { int mask, value, nwords; const char *opcode_bits; // Eg, "0000 11rd dddd rrrr" @@ -1560,10 +1566,7 @@ typedef struct { *description, // "Add without Carry" *operation, // "Rd ← Rd+Rr" *flags, // "Z,C,N,V,S,H" - *clocks_e, // Timing for AVRe (extended AVR opcode set) - *clocks_xm, // Timing for AVRxm (XMEGA) - *clocks_xt, // Timing for AVRxt (modern UPDI) - *clocks_rc, // Timing for AVRrc (reduced core) + *clock[OP_AVR_cycle_N], // Timing tables for AVRe, AVRxm, AVRxt and AVRrc *remarks; } AVR_opcode_data; diff --git a/src/term.c b/src/term.c index 5aca15d1..01190963 100644 --- a/src/term.c +++ b/src/term.c @@ -447,6 +447,14 @@ static int get_avr_archlevel(const AVRPART *p) { return ret; } +static AVR_cycle_index get_avr_cycle_index(const AVRPART *p) { + return + p->prog_modes & PM_UPDI? OP_AVRxt: + p->prog_modes & PM_PDI? OP_AVRxm: + p->prog_modes & PM_TPI? OP_AVRrc: OP_AVRe; +} + + static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { int addr, len; const AVRMEM *mem = NULL; @@ -468,6 +476,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c if((mem = avr_locate_flash(p))) cx->dis_opts.FlashSize = mem->size; cx->dis_opts.AVR_Level = get_avr_archlevel(p); + cx->dis_opts.cycle_index = get_avr_cycle_index(p); cx->dis_initopts++; } cx->dis_opts.Pass = 1; From 3a7c295aa9df4e178ed8ac9bdcb3526f8c639e55 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 21:35:29 +0100 Subject: [PATCH 290/422] Only disassemble opcodes that the part has --- src/disasm.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 65bf2044..d76aacfe 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -80,23 +80,13 @@ int Compare_Opcode(const char *Bitstream, const char *Bitmask) { } void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char *New_Opcode_String, AVR_opcode mnemo) { - cx->dis_n_ops++; - cx->dis_op[cx->dis_n_ops - 1].Opcode_String = malloc(strlen(New_Opcode_String) + 1); - strcpy(cx->dis_op[cx->dis_n_ops - 1].Opcode_String, New_Opcode_String); - cx->dis_op[cx->dis_n_ops - 1].mnemo = mnemo; - cx->dis_op[cx->dis_n_ops - 1].Callback = Callback; -} - -void Supersede_Opcode(void (*Callback)(const char *, int, AVR_opcode), AVR_opcode mnemo) { - int i; - - for(i = 0; i < cx->dis_n_ops; i++) { - if(cx->dis_op[i].mnemo == mnemo) { - cx->dis_op[i].Callback = Callback; - return; - } + // Only register opcode if the part has it + if(avr_opcodes[mnemo].avrlevel & cx->dis_opts.AVR_Level) { + cx->dis_op[cx->dis_n_ops].Opcode_String = mmt_strdup(New_Opcode_String); + cx->dis_op[cx->dis_n_ops].mnemo = mnemo; + cx->dis_op[cx->dis_n_ops].Callback = Callback; + cx->dis_n_ops++; } - fprintf(stderr, "Error: No callback fund to supersede opcode %d (%s).\n", mnemo, avr_opcodes[mnemo].opcode); } int Get_Bitmask_Length(const char *Bitmask) { From f9ef0ec9d5b50763bce0d1d90504681e90ced07d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 22:47:19 +0100 Subject: [PATCH 291/422] Init IORegisters from avrintel register file --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/disasm.c | 3 +- src/disasm_callbacks_assembly.c | 3 +- src/disasm_ioregisters.c | 124 --------------------- src/disasm_ioregisters.h | 30 ----- src/disasm_jumpcall.c | 2 +- src/{disasm_globals.h => disasm_private.h} | 2 +- src/disasm_tagfile.c | 81 ++++++++++++++ src/disasm_tagfile.h | 3 + src/libavrdude.h | 1 + src/term.c | 1 + 12 files changed, 92 insertions(+), 166 deletions(-) delete mode 100644 src/disasm_ioregisters.c delete mode 100644 src/disasm_ioregisters.h rename src/{disasm_globals.h => disasm_private.h} (98%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8f949bb..c8324ac2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -182,11 +182,9 @@ add_library(libavrdude crc16.c crc16.h disasm.c + disasm_private.h disasm_callbacks_assembly.c disasm_callbacks_assembly.h - disasm_globals.h - disasm_ioregisters.c - disasm_ioregisters.h disasm_jumpcall.c disasm_jumpcall.h disasm_tagfile.c diff --git a/src/Makefile.am b/src/Makefile.am index c76df991..7ee7d71d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -120,11 +120,9 @@ libavrdude_a_SOURCES = \ crc16.c \ crc16.h \ disasm.c \ + disasm_private.h \ disasm_callbacks_assembly.c \ disasm_callbacks_assembly.h \ - disasm_globals.h \ - disasm_ioregisters.c \ - disasm_ioregisters.h \ disasm_jumpcall.c \ disasm_jumpcall.h \ disasm_tagfile.c \ diff --git a/src/disasm.c b/src/disasm.c index d76aacfe..bc8aa70a 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -36,10 +36,9 @@ #include "avrdude.h" #include "libavrdude.h" -#include "disasm_globals.h" +#include "disasm_private.h" #include "disasm_callbacks_assembly.h" #include "disasm_jumpcall.h" -#include "disasm_ioregisters.h" #include "disasm_tagfile.h" void Display_Registers() { diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 80c78aa9..35d7c55e 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -30,10 +30,9 @@ #include "libavrdude.h" -#include "disasm_globals.h" +#include "disasm_private.h" #include "disasm_callbacks_assembly.h" #include "disasm_jumpcall.h" -#include "disasm_ioregisters.h" #include "disasm_tagfile.h" // Return the number of bits set in Number diff --git a/src/disasm_ioregisters.c b/src/disasm_ioregisters.c deleted file mode 100644 index 27e48a9b..00000000 --- a/src/disasm_ioregisters.c +++ /dev/null @@ -1,124 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#include -#include -#include - -#include "libavrdude.h" - -#include "disasm_globals.h" - -static struct IO_Register *KnownIORegisters = NULL; -static unsigned int KnownIORegistersCount = 0; - -unsigned int ReadIORegisterFile() { - FILE *f; - - f = fopen("/etc/disasm.conf", "r"); - if(!f) { - f = fopen("disasm.conf", "r"); - } - if(!f) { - fprintf(stderr, "Could not read any configuration file.\n"); - return 0; - } - - { - char Buffer[256]; - int CurrentMCU = 0; - - while(fgets(Buffer, sizeof(Buffer), f)) { - char *Token; - struct IO_Register TempRegister; - - if(!(Token = strtok(Buffer, "\t\n"))) - continue; - if(!strcmp(Token, "Register")) { - if(!CurrentMCU) - continue; - if(!(Token = strtok(NULL, "\t\n"))) - continue; - if(strlen(Token) == 0) - continue; - if(Token[1] == 'x') { - TempRegister.Address = strtol(Token + 2, NULL, 16); - } else { - TempRegister.Address = atoi(Token); - } - if(!(Token = strtok(NULL, "\t\n"))) - continue; - strncpy(TempRegister.Name, Token, 16); - TempRegister.Used = 0; - - KnownIORegisters = - (struct IO_Register *) realloc(KnownIORegisters, sizeof(struct IO_Register) * (KnownIORegistersCount + 1)); - KnownIORegisters[KnownIORegistersCount] = TempRegister; - KnownIORegistersCount++; - } else if(!strcmp(Token, "Unit")) { - if(!(Token = strtok(NULL, "\t\n"))) - continue; - CurrentMCU = (!strcmp(Token, cx->dis_opts.MCU)) || (!strcmp(Token, "Global")); - } - } - } - - fclose(f); - return KnownIORegistersCount; -} - -const char *Resolve_IO_Register(int Number) { - int Resolved; - unsigned int i; - - if(!strcmp(cx->dis_opts.MCU, "None")) - return NULL; - - Resolved = -1; - for(i = 0; i < KnownIORegistersCount; i++) { - if(KnownIORegisters[i].Address == Number) { - Resolved = i; - break; - } - } - - if(Resolved != -1) { - KnownIORegisters[Resolved].Used = 1; - return KnownIORegisters[Resolved].Name; - } else { - return NULL; - } -} - -void Emit_Used_IO_Registers() { - unsigned int i; - - for(i = 0; i < KnownIORegistersCount; i++) { - if(KnownIORegisters[i].Used) - printf(".equ %s, 0x%x\n", KnownIORegisters[i].Name, KnownIORegisters[i].Address); - } -} diff --git a/src/disasm_ioregisters.h b/src/disasm_ioregisters.h deleted file mode 100644 index b6b3c634..00000000 --- a/src/disasm_ioregisters.h +++ /dev/null @@ -1,30 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -unsigned int ReadIORegisterFile(); -const char *Resolve_IO_Register(int Number); -void Emit_Used_IO_Registers(); diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 074381e5..0c0278af 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -31,7 +31,7 @@ #include "libavrdude.h" -#include "disasm_globals.h" +#include "disasm_private.h" #include "disasm_tagfile.h" #include "disasm_jumpcall.h" diff --git a/src/disasm_globals.h b/src/disasm_private.h similarity index 98% rename from src/disasm_globals.h rename to src/disasm_private.h index 8aa8ba9a..31d77555 100644 --- a/src/disasm_globals.h +++ b/src/disasm_private.h @@ -46,7 +46,7 @@ struct JumpCall { struct IO_Register { int Address; - char Name[16]; + char *Name; unsigned char Used; }; diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index 31d91d51..ead61489 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -28,10 +28,13 @@ #include #include #include +#include #include +#include "avrdude.h" #include "libavrdude.h" +#include "disasm_private.h" #include "disasm_tagfile.h" struct CodeLabel { @@ -523,3 +526,81 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { printf("\n"); return BytesAdvanced; } + + +static struct IO_Register *IORegisters = NULL; +static int IORegistersCount = 0; + +static char *regname(const char *reg, int suf) { + char *ret = + suf <= -1? mmt_strdup(reg): + suf == 'h' || suf == 'l'? str_sprintf("%s%c", reg, suf): + str_sprintf("%s%d", reg, suf); + + for(char *s = ret; *s; s++) + *s = *s == '.'? '_': isascii(*s & 0xff)? toupper(*s & 0xff): *s; + + return ret; +} + +int initIORegisters(const AVRPART *p) { + int nr = 0, nio = 0; + const Register_file *rf = avr_locate_register_file(p, &nr); + if(rf) { + if(IORegisters) { + for(int i = 0; i < IORegistersCount; i++) + mmt_free(IORegisters[i].Name); + mmt_free(IORegisters); + } + + // Count how many entries are needed + for(int i = 0; i< nr; i++) + if(rf[i].addr < 0x40) + nio += rf[i].size; + IORegisters = mmt_malloc(nio*sizeof*IORegisters); + + nio = 0; + for(int i = 0; i< nr; i++) { + if(rf[i].addr < 0x40) { + if(rf[i].size == 1) { + IORegisters[nio].Name = regname(rf[i].reg, -1); + IORegisters[nio].Address = rf[i].addr; + nio++; + } else if(rf[i].size == 2) { + IORegisters[nio].Name = regname(rf[i].reg, 'l'); + IORegisters[nio].Address = rf[i].addr; + nio++; + IORegisters[nio].Name = regname(rf[i].reg, 'h'); + IORegisters[nio].Address = rf[i].addr+1; + nio++; + } else { + for(int k = 0; k < rf[i].size; k++) { + IORegisters[nio].Name = regname(rf[i].reg, k); + IORegisters[nio].Address = rf[i].addr + k; + nio++; + } + } + } + } + IORegistersCount = nio; + } + + return IORegistersCount; +} + +const char *Resolve_IO_Register(int Number) { + for(int i = 0; i < IORegistersCount; i++) { + if(IORegisters[i].Address == Number) { + IORegisters[i].Used = 1; + return IORegisters[i].Name; + } + } + + return NULL; +} + +void Emit_Used_IO_Registers() { + for(int i = 0; i < IORegistersCount; i++) + if(IORegisters[i].Used) + printf(".equ %s, 0x%x\n", IORegisters[i].Name, IORegisters[i].Address); +} diff --git a/src/disasm_tagfile.h b/src/disasm_tagfile.h index 1247491e..db1066da 100644 --- a/src/disasm_tagfile.h +++ b/src/disasm_tagfile.h @@ -37,3 +37,6 @@ char *Tagfile_GetLabelComment(int TagIndex); int Tagfile_FindPGMAddress(int Address); const char *Tagfile_Resolve_Mem_Address(int Address); int Tagfile_Process_Data(const char *Bitstream, int Position); + +const char *Resolve_IO_Register(int Number); +void Emit_Used_IO_Registers(); diff --git a/src/libavrdude.h b/src/libavrdude.h index 38d2a0d2..95c35692 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1676,6 +1676,7 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); int disasm(const char *buf, int len, int addr); +int initIORegisters(const AVRPART *p); #ifdef __cplusplus } diff --git a/src/term.c b/src/term.c index 01190963..0bfc62c3 100644 --- a/src/term.c +++ b/src/term.c @@ -477,6 +477,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.FlashSize = mem->size; cx->dis_opts.AVR_Level = get_avr_archlevel(p); cx->dis_opts.cycle_index = get_avr_cycle_index(p); + initIORegisters(p); cx->dis_initopts++; } cx->dis_opts.Pass = 1; From e7a6a29997f0387131a83f49cba51f8fb7d7bf7d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 23:38:58 +0100 Subject: [PATCH 292/422] Init MemLabels from avrintel register file --- src/disasm_private.h | 6 ---- src/disasm_tagfile.c | 68 +++++++++++++++++++++++--------------------- src/libavrdude.h | 2 +- src/term.c | 2 +- 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/disasm_private.h b/src/disasm_private.h index 31d77555..053abe39 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -44,9 +44,3 @@ struct JumpCall { unsigned char FunctionCall; }; -struct IO_Register { - int Address; - char *Name; - unsigned char Used; -}; - diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index ead61489..b2a370a9 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -57,6 +57,12 @@ struct MemLabel { char *Comment; }; +struct IO_Register { + int Address; + char *Name; + unsigned char Used; +}; + static int CodeLabelCount = 0; static struct CodeLabel *CodeLabels; @@ -66,6 +72,9 @@ static struct PGMLabel *PGMLabels = NULL; static int MemLabelCount = 0; static struct MemLabel *MemLabels = NULL; +static struct IO_Register *IORegisters = NULL; +static int IORegistersCount = 0; + /* static void Display_Tagfile() { int i; @@ -115,48 +124,30 @@ static int ahtoi(const char *String) { static void Add_LabelTag(int Address, const char *LabelText, const char *LabelComment) { CodeLabelCount++; - CodeLabels = (struct CodeLabel *) realloc(CodeLabels, sizeof(struct CodeLabel) * CodeLabelCount); + CodeLabels = (struct CodeLabel *) mmt_realloc(CodeLabels, sizeof(struct CodeLabel) * CodeLabelCount); CodeLabels[CodeLabelCount - 1].Address = Address; - - CodeLabels[CodeLabelCount - 1].Text = (char *) malloc(strlen(LabelText) + 1); - strcpy(CodeLabels[CodeLabelCount - 1].Text, LabelText); - - if(LabelComment != NULL) { - CodeLabels[CodeLabelCount - 1].Comment = (char *) malloc(strlen(LabelComment) + 1); - strcpy(CodeLabels[CodeLabelCount - 1].Comment, LabelComment); - } else { - CodeLabels[CodeLabelCount - 1].Comment = NULL; - } + CodeLabels[CodeLabelCount - 1].Text = LabelText? mmt_strdup(LabelText): NULL; + CodeLabels[CodeLabelCount - 1].Comment = LabelComment? mmt_strdup(LabelComment): NULL; } static void Add_PGM_Tag(int Address, char Type, unsigned int Count, const char *Comment) { PGMLabelCount++; - PGMLabels = (struct PGMLabel *) realloc(PGMLabels, sizeof(struct PGMLabel) * PGMLabelCount); + PGMLabels = (struct PGMLabel *) mmt_realloc(PGMLabels, sizeof(struct PGMLabel) * PGMLabelCount); PGMLabels[PGMLabelCount - 1].Address = Address; PGMLabels[PGMLabelCount - 1].Type = Type; PGMLabels[PGMLabelCount - 1].Count = Count; - if(Comment != NULL) { - PGMLabels[PGMLabelCount - 1].Comment = (char *) malloc(strlen(Comment) + 1); - strcpy(PGMLabels[PGMLabelCount - 1].Comment, Comment); - } else { - PGMLabels[PGMLabelCount - 1].Comment = NULL; - } + PGMLabels[PGMLabelCount - 1].Comment = Comment? mmt_strdup(Comment): NULL; } static void Add_Mem_Tag(int Address, char Type, unsigned int Count, const char *Comment) { MemLabelCount++; - MemLabels = (struct MemLabel *) realloc(MemLabels, sizeof(struct MemLabel) * MemLabelCount); + MemLabels = (struct MemLabel *) mmt_realloc(MemLabels, sizeof(struct MemLabel) * MemLabelCount); MemLabels[MemLabelCount - 1].Address = Address; MemLabels[MemLabelCount - 1].Type = Type; MemLabels[MemLabelCount - 1].Count = Count; - if(Comment != NULL) { - MemLabels[MemLabelCount - 1].Comment = (char *) malloc(strlen(Comment) + 1); - strcpy(MemLabels[MemLabelCount - 1].Comment, Comment); - } else { - MemLabels[MemLabelCount - 1].Comment = NULL; - } + MemLabels[MemLabelCount - 1].Comment = Comment? mmt_strdup(Comment): NULL; } static void Tagfile_Readline(char *Line, int LineNo) { @@ -528,9 +519,6 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { } -static struct IO_Register *IORegisters = NULL; -static int IORegistersCount = 0; - static char *regname(const char *reg, int suf) { char *ret = suf <= -1? mmt_strdup(reg): @@ -543,24 +531,40 @@ static char *regname(const char *reg, int suf) { return ret; } -int initIORegisters(const AVRPART *p) { - int nr = 0, nio = 0; +// Initialise IORegisters and MemLabels from part register file +void initRegisters(const AVRPART *p) { + int nr = 0, nio = 0, offset = 0; const Register_file *rf = avr_locate_register_file(p, &nr); + if(rf) { if(IORegisters) { for(int i = 0; i < IORegistersCount; i++) mmt_free(IORegisters[i].Name); mmt_free(IORegisters); } + if(MemLabels) { + for(int i = 0; i < MemLabelCount; i++) + mmt_free(MemLabels[i].Comment); + mmt_free(MemLabels); + } // Count how many entries are needed for(int i = 0; i< nr; i++) if(rf[i].addr < 0x40) nio += rf[i].size; IORegisters = mmt_malloc(nio*sizeof*IORegisters); + MemLabels = mmt_malloc(nr*sizeof*MemLabels); + AVRMEM *mem = avr_locate_io(p); + if(mem) + offset = mem->offset; nio = 0; for(int i = 0; i< nr; i++) { + MemLabels[i].Address = offset + rf[i].addr; + MemLabels[i].Type = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; + MemLabels[i].Count = rf[i].size > 2? rf[i].size: 1; + MemLabels[i].Comment = regname(rf[i].reg, -1); + if(rf[i].addr < 0x40) { if(rf[i].size == 1) { IORegisters[nio].Name = regname(rf[i].reg, -1); @@ -583,9 +587,9 @@ int initIORegisters(const AVRPART *p) { } } IORegistersCount = nio; + MemLabelCount = nr; + qsort(MemLabels, MemLabelCount, sizeof(struct MemLabel), MemLabelSort); } - - return IORegistersCount; } const char *Resolve_IO_Register(int Number) { diff --git a/src/libavrdude.h b/src/libavrdude.h index 95c35692..ecf0c52e 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1676,7 +1676,7 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); int disasm(const char *buf, int len, int addr); -int initIORegisters(const AVRPART *p); +void initRegisters(const AVRPART *p); #ifdef __cplusplus } diff --git a/src/term.c b/src/term.c index 0bfc62c3..94682204 100644 --- a/src/term.c +++ b/src/term.c @@ -477,7 +477,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.FlashSize = mem->size; cx->dis_opts.AVR_Level = get_avr_archlevel(p); cx->dis_opts.cycle_index = get_avr_cycle_index(p); - initIORegisters(p); + initRegisters(p); cx->dis_initopts++; } cx->dis_opts.Pass = 1; From e81ab78a3c677af15aaa87a9d5855fae8ac2f0dd Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jul 2024 23:57:08 +0100 Subject: [PATCH 293/422] Move remaining memory allocation to mmt_xyz() functions --- src/disasm_jumpcall.c | 3 ++- src/disasm_tagfile.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 0c0278af..0b6ebfd1 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -29,6 +29,7 @@ #include #include +#include "avrdude.h" #include "libavrdude.h" #include "disasm_private.h" @@ -63,7 +64,7 @@ int FixTargetAddress(int Address) { void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { if((cx->dis_opts.Process_Labels == 1) && (cx->dis_opts.Pass == 1)) { JumpCall_Count++; - JumpCalls = realloc(JumpCalls, sizeof(struct JumpCall) * (JumpCall_Count)); + JumpCalls = mmt_realloc(JumpCalls, sizeof(struct JumpCall) * (JumpCall_Count)); JumpCalls[JumpCall_Count - 1].From = From; JumpCalls[JumpCall_Count - 1].To = To; JumpCalls[JumpCall_Count - 1].Type = Type; diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index b2a370a9..3c3b119d 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -519,6 +519,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { } +// Allocate, copy, append a suffix (H, L, 0...8 or nothing), make upper case and return static char *regname(const char *reg, int suf) { char *ret = suf <= -1? mmt_strdup(reg): @@ -550,7 +551,7 @@ void initRegisters(const AVRPART *p) { // Count how many entries are needed for(int i = 0; i< nr; i++) - if(rf[i].addr < 0x40) + if(rf[i].addr < 0x40 && rf[i].size > 0) nio += rf[i].size; IORegisters = mmt_malloc(nio*sizeof*IORegisters); MemLabels = mmt_malloc(nr*sizeof*MemLabels); @@ -577,7 +578,7 @@ void initRegisters(const AVRPART *p) { IORegisters[nio].Name = regname(rf[i].reg, 'h'); IORegisters[nio].Address = rf[i].addr+1; nio++; - } else { + } else if(rf[i].size > 2) { for(int k = 0; k < rf[i].size; k++) { IORegisters[nio].Name = regname(rf[i].reg, k); IORegisters[nio].Address = rf[i].addr + k; From cf9229ad2617962e48b92ee236fd9130882ecf39 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 00:25:24 +0100 Subject: [PATCH 294/422] Simplify Tagfile_Resolve_Mem_Address() and avoid static memory --- src/disasm_tagfile.c | 61 +++++++++++--------------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index 3c3b119d..9f2e7f1f 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -333,56 +333,25 @@ int Tagfile_FindPGMAddress(int Address) { } const char *Tagfile_Resolve_Mem_Address(int Address) { - static char Buffer[64]; - int i; + for(int i = 0; i < MemLabelCount && MemLabels[i].Address <= Address; i++) { + int Start = MemLabels[i].Address; + int Size = MemLabels[i].Type == TYPE_WORD? 2: 1; + int End = MemLabels[i].Address + MemLabels[i].Count * Size - 1; - for(i = 0; i < MemLabelCount; i++) { - int Start, End, Size; - - Size = 0; - if(MemLabels[i].Address > Address) - return NULL; - - Start = MemLabels[i].Address; - switch (MemLabels[i].Type) { - case TYPE_BYTE: - Size = 1; - break; - case TYPE_WORD: - Size = 2; - break; - } - End = MemLabels[i].Address + MemLabels[i].Count * Size - 1; - - if((Address >= Start) && (Address <= End)) { - if(MemLabels[i].Count == 1) { - // Single variable - if(Size == 1) { - strncpy(Buffer, MemLabels[i].Comment, sizeof(Buffer)); - } else { - if((Address - Start) == 0) { - snprintf(Buffer, sizeof(Buffer), "_lo8(%s)", MemLabels[i].Comment); - } else { - snprintf(Buffer, sizeof(Buffer), "_hi8(%s)", MemLabels[i].Comment); - } - } - } else { - // Array - if(Size == 1) { - snprintf(Buffer, sizeof(Buffer), "%s[%d]", MemLabels[i].Comment, (Address - Start) / 1); - } else { - int HiLo = (Address - Start) % 2; - - if(HiLo == 0) { - snprintf(Buffer, sizeof(Buffer), "_lo8(%s[%d])", MemLabels[i].Comment, (Address - Start) / 2); - } else { - snprintf(Buffer, sizeof(Buffer), "_hi8(%s[%d])", MemLabels[i].Comment, (Address - Start) / 2); - } - } + if(Address >= Start && Address <= End) { + if(MemLabels[i].Count == 1) { // Single variable + if(Size == 1) + return str_ccprintf("%s", MemLabels[i].Comment); + return str_ccprintf("_%s8(%s)", Address == Start? "lo": "hi", MemLabels[i].Comment); } - return Buffer; + // Array + if(Size == 1) + return str_ccprintf("%s[%d]", MemLabels[i].Comment, Address - Start); + return str_ccprintf("_%s8(%s[%d])", (Address-Start)%2? "hi": "lo", MemLabels[i].Comment, + (Address - Start)/2); } } + return NULL; } From 67d627ee4c034d796ddf6ff847cae1c76393f184 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 00:45:47 +0100 Subject: [PATCH 295/422] Make Operation_xyz() functions static --- src/disasm_callbacks_assembly.c | 34 +++++++++++++++++---------------- src/disasm_callbacks_assembly.h | 15 --------------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 35d7c55e..9ba7db22 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -41,42 +41,43 @@ static unsigned BitCount(unsigned n) { // A la Kernighan (and Richie): iteratively clear the least significant bit set for(ret = 0; n; ret++) - n &= n -1; + n &= n-1; return ret; } -void Operation_Simple(AVR_opcode mnemo) { +static void Operation_Simple(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%s", avr_opcodes[mnemo].opcode); } -void Operation_Rd(AVR_opcode mnemo) { +static void Operation_Rd(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd); } -void Operation_Rd16(AVR_opcode mnemo) { +static void Operation_Rd16(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd + 16); } -void Operation_Rd_Rr(AVR_opcode mnemo) { +static void Operation_Rd_Rr(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd, Rr); } -void Operation_Rd16_Rr16(AVR_opcode mnemo) { +static void Operation_Rd16_Rr16(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd + 16, Rr + 16); } -void Operation_Rd16_K(AVR_opcode mnemo) { +static void Operation_Rd16_K(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 16, RK); snprintf(cx->dis_comment, 255, "%d", RK); } -void Operation_Rd_K(AVR_opcode mnemo) { +/**** +static void Operation_Rd_K(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); snprintf(cx->dis_comment, 255, "%d", RK); } -void Operation_RdW_K(AVR_opcode mnemo) { +static void Operation_RdW_K(AVR_opcode mnemo) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 1, Rd, RK); } else { @@ -84,8 +85,9 @@ void Operation_RdW_K(AVR_opcode mnemo) { } snprintf(cx->dis_comment, 255, "%d", RK); } +****/ -void Operation_RdW_RrW(AVR_opcode mnemo) { +static void Operation_RdW_RrW(AVR_opcode mnemo) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", avr_opcodes[mnemo].opcode, (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); } else { @@ -93,7 +95,7 @@ void Operation_RdW_RrW(AVR_opcode mnemo) { } } -void Operation_s_k(AVR_opcode mnemo, int Position) { +static void Operation_s_k(AVR_opcode mnemo, int Position) { int Bits, Offset; int Target; @@ -117,7 +119,7 @@ void Operation_s_k(AVR_opcode mnemo, int Position) { } } -void Operation_r_b(AVR_opcode mnemo) { +static void Operation_r_b(AVR_opcode mnemo) { int Register, Bit; Register = Rr; @@ -126,7 +128,7 @@ void Operation_r_b(AVR_opcode mnemo) { snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void Operation_Rd_b(AVR_opcode mnemo) { +static void Operation_Rd_b(AVR_opcode mnemo) { int Register, Bit; Register = Rd; @@ -135,7 +137,7 @@ void Operation_Rd_b(AVR_opcode mnemo) { snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void Operation_A_b(AVR_opcode mnemo) { +static void Operation_A_b(AVR_opcode mnemo) { int Register, Bit; const char *Register_Name; @@ -151,7 +153,7 @@ void Operation_A_b(AVR_opcode mnemo) { } } -void Operation_s(AVR_opcode mnemo) { +static void Operation_s(AVR_opcode mnemo) { int Bit; Bit = Rs; @@ -159,7 +161,7 @@ void Operation_s(AVR_opcode mnemo) { snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } -void Operation_k(AVR_opcode mnemo, int Position, const char *Pseudocode) { +static void Operation_k(AVR_opcode mnemo, int Position, const char *Pseudocode) { int Offset; int Target; diff --git a/src/disasm_callbacks_assembly.h b/src/disasm_callbacks_assembly.h index 2ef9a5d8..25ae4ba9 100644 --- a/src/disasm_callbacks_assembly.h +++ b/src/disasm_callbacks_assembly.h @@ -25,21 +25,6 @@ JohannesBauer@gmx.de */ -void Operation_Simple(AVR_opcode mnemo); -void Operation_Rd(AVR_opcode mnemo); -void Operation_Rd16(AVR_opcode mnemo); -void Operation_Rd_Rr(AVR_opcode mnemo); -void Operation_Rd16_Rr16(AVR_opcode mnemo); -void Operation_Rd16_K(AVR_opcode mnemo); -void Operation_Rd_K(AVR_opcode mnemo); -void Operation_RdW_K(AVR_opcode mnemo); -void Operation_RdW_RrW(AVR_opcode mnemo); -void Operation_s_k(AVR_opcode mnemo, int Position); -void Operation_r_b(AVR_opcode mnemo); -void Operation_Rd_b(AVR_opcode mnemo); -void Operation_A_b(AVR_opcode mnemo); -void Operation_s(AVR_opcode mnemo); -void Operation_k(AVR_opcode mnemo, int Position, const char *Pseudocode); void adc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void add_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void adiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From 781c87d034259874b8c8af32568e4570e7ca6368 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 01:00:04 +0100 Subject: [PATCH 296/422] Move static buffer to closed circuit space --- src/disasm_jumpcall.c | 31 ++++++++----------------------- src/disasm_jumpcall.h | 2 +- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 0b6ebfd1..6b17a320 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -141,34 +141,21 @@ void Enumerate_Labels(void) { } } -char *Get_Label_Name(int Destination, char **LabelComment) { - int i; - static char Buffer[256]; +const char *Get_Label_Name(int Destination, char **LabelComment) { int TagIndex; - char *TagLabel; TagIndex = Tagfile_FindLabelAddress(Destination); if(TagIndex != -1) { - TagLabel = Tagfile_GetLabel(TagIndex); - snprintf(Buffer, sizeof(Buffer), "%s", TagLabel); - if(LabelComment != NULL) + if(LabelComment) *LabelComment = Tagfile_GetLabelComment(TagIndex); - return Buffer; + return str_ccprintf("%s", Tagfile_GetLabel(TagIndex)); } - for(i = 0; i < JumpCall_Count; i++) { - if((JumpCalls[i].To) == Destination) { - if(JumpCalls[i].FunctionCall) { - snprintf(Buffer, sizeof(Buffer), "Function%d", JumpCalls[i].LabelNumber); - } else { - snprintf(Buffer, sizeof(Buffer), "Label%d", JumpCalls[i].LabelNumber); - } - return Buffer; - } - } + for(int i = 0; i < JumpCall_Count; i++) + if(JumpCalls[i].To == Destination) + return str_ccprintf("%s%d", JumpCalls[i].FunctionCall? "Function": "Label", JumpCalls[i].LabelNumber); - snprintf(Buffer, sizeof(Buffer), "UNKNOWN"); - return Buffer; + return "UNKNOWN"; } // Show all references which refer to "Position" as destination @@ -186,10 +173,8 @@ void Print_JumpCalls(int Position) { } } if(Match == 1) { - char *LabelName; char *LabelComment = NULL; - - LabelName = Get_Label_Name(Position, &LabelComment); + const char *LabelName = Get_Label_Name(Position, &LabelComment); if(LabelComment == NULL) { printf("%s:\n", LabelName); } else { diff --git a/src/disasm_jumpcall.h b/src/disasm_jumpcall.h index 30a13b43..1e7a3b4c 100644 --- a/src/disasm_jumpcall.h +++ b/src/disasm_jumpcall.h @@ -30,6 +30,6 @@ void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall); int JC_Comparison(const void *Element1, const void *Element2); void Sort_JumpCalls(); void Enumerate_Labels(); -char *Get_Label_Name(int Destination, char **LabelComment); +const char *Get_Label_Name(int Destination, char **LabelComment); void Print_JumpCalls(int Position); int FixTargetAddress(int Address); From 72c70cb98b7de0ab8f40bc9397a254cafdbeca9d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 01:28:06 +0100 Subject: [PATCH 297/422] Move remaining static variables into context structure --- src/disasm.c | 6 +- src/disasm_callbacks_assembly.c | 6 +- src/disasm_jumpcall.c | 83 ++++++----- src/disasm_private.h | 8 -- src/disasm_tagfile.c | 234 +++++++++++++------------------- src/libavrdude.h | 40 ++++++ 6 files changed, 181 insertions(+), 196 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index bc8aa70a..aaf206c1 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -293,13 +293,9 @@ void Disassemble(const char *Bitstream, int Read, int addr) { } void Display_Opcodes() { - unsigned int i; - printf("%d opcodes registered:\n", cx->dis_n_ops); - for(i = 0; i < cx->dis_n_ops; i++) { - // This invokes UB as a function pointer is converted to void * - beware + for(int i = 0; i < cx->dis_n_ops; i++) printf("%3d: '%-80s' -> %p\n", i, cx->dis_op[i].Opcode_String, (void *) cx->dis_op[i].Callback); - } } int Get_Specifity(const char *Opcode) { diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 9ba7db22..5434667d 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -340,10 +340,9 @@ CALLBACK(call_Callback) { if(!cx->dis_opts.Process_Labels) { snprintf(cx->dis_code, 255, "%-7s 0x%02x", avr_opcodes[mnemo].opcode, Pos); } else { - char *LabelName; char *LabelComment = NULL; + const char *LabelName = Get_Label_Name(Pos, &LabelComment); - LabelName = Get_Label_Name(Pos, &LabelComment); snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, LabelName); if(LabelComment != NULL) snprintf(cx->dis_comment, 255, "%s", LabelComment); @@ -639,10 +638,9 @@ CALLBACK(rcall_Callback) { } snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { - char *LabelName; char *LabelComment = NULL; + const char *LabelName = Get_Label_Name(Target, &LabelComment); - LabelName = Get_Label_Name(Target, &LabelComment); snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, LabelName); if(LabelComment != NULL) snprintf(cx->dis_comment, 255, "%s", LabelComment); diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 6b17a320..3058a66c 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -36,16 +36,13 @@ #include "disasm_tagfile.h" #include "disasm_jumpcall.h" -static int JumpCall_Count; -static struct JumpCall *JumpCalls; - void Display_JumpCalls() { int i; - printf("%d jumps/calls found:\n", JumpCall_Count); - for(i = 0; i < JumpCall_Count; i++) { - printf("%3d: 0x%-4x -> 0x%-4x %s (%d)\n", i, (unsigned int) JumpCalls[i].From, (unsigned int) JumpCalls[i].To, - avr_opcodes[JumpCalls[i].Type].opcode, JumpCalls[i].FunctionCall); + printf("%d jumps/calls found:\n", cx->dis_JumpCallN); + for(i = 0; i < cx->dis_JumpCallN; i++) { + printf("%3d: 0x%-4x -> 0x%-4x %s (%d)\n", i, (unsigned int) cx->dis_JumpCalls[i].From, (unsigned int) cx->dis_JumpCalls[i].To, + avr_opcodes[cx->dis_JumpCalls[i].Type].opcode, cx->dis_JumpCalls[i].FunctionCall); } } @@ -63,21 +60,21 @@ int FixTargetAddress(int Address) { void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { if((cx->dis_opts.Process_Labels == 1) && (cx->dis_opts.Pass == 1)) { - JumpCall_Count++; - JumpCalls = mmt_realloc(JumpCalls, sizeof(struct JumpCall) * (JumpCall_Count)); - JumpCalls[JumpCall_Count - 1].From = From; - JumpCalls[JumpCall_Count - 1].To = To; - JumpCalls[JumpCall_Count - 1].Type = Type; - JumpCalls[JumpCall_Count - 1].LabelNumber = 0; - JumpCalls[JumpCall_Count - 1].FunctionCall = FunctionCall; + cx->dis_JumpCallN++; + cx->dis_JumpCalls = mmt_realloc(cx->dis_JumpCalls, sizeof(Disasm_JumpCall) * (cx->dis_JumpCallN)); + cx->dis_JumpCalls[cx->dis_JumpCallN - 1].From = From; + cx->dis_JumpCalls[cx->dis_JumpCallN - 1].To = To; + cx->dis_JumpCalls[cx->dis_JumpCallN - 1].Type = Type; + cx->dis_JumpCalls[cx->dis_JumpCallN - 1].LabelNumber = 0; + cx->dis_JumpCalls[cx->dis_JumpCallN - 1].FunctionCall = FunctionCall; } } int JC_Comparison(const void *Element1, const void *Element2) { - struct JumpCall *JC1, *JC2; + Disasm_JumpCall *JC1, *JC2; - JC1 = (struct JumpCall *) Element1; - JC2 = (struct JumpCall *) Element2; + JC1 = (Disasm_JumpCall *) Element1; + JC2 = (Disasm_JumpCall *) Element2; if((JC1->To) > (JC2->To)) return 1; else if((JC1->To) == (JC2->To)) @@ -86,27 +83,27 @@ int JC_Comparison(const void *Element1, const void *Element2) { } void Sort_JumpCalls() { - qsort(JumpCalls, JumpCall_Count, sizeof(struct JumpCall), JC_Comparison); + qsort(cx->dis_JumpCalls, cx->dis_JumpCallN, sizeof(Disasm_JumpCall), JC_Comparison); } void Correct_Label_Types(void) { int i, j; int LastIdx = 0; - int LastDest = JumpCalls[0].To; - char CurType = JumpCalls[0].FunctionCall; + int LastDest = cx->dis_JumpCalls[0].To; + char CurType = cx->dis_JumpCalls[0].FunctionCall; - for(i = 1; i < JumpCall_Count; i++) { - if(JumpCalls[i].To != LastDest) { + for(i = 1; i < cx->dis_JumpCallN; i++) { + if(cx->dis_JumpCalls[i].To != LastDest) { for(j = LastIdx; j < i; j++) - JumpCalls[j].FunctionCall = CurType; + cx->dis_JumpCalls[j].FunctionCall = CurType; LastIdx = i; - LastDest = JumpCalls[i].To; + LastDest = cx->dis_JumpCalls[i].To; CurType = 0; } - CurType = (CurType || JumpCalls[i].FunctionCall); + CurType = (CurType || cx->dis_JumpCalls[i].FunctionCall); } - for(j = LastIdx; j < JumpCall_Count; j++) - JumpCalls[j].FunctionCall = CurType; + for(j = LastIdx; j < cx->dis_JumpCallN; j++) + cx->dis_JumpCalls[j].FunctionCall = CurType; } void Enumerate_Labels(void) { @@ -115,29 +112,29 @@ void Enumerate_Labels(void) { int CurrentFunctionNumber = 0; int Destination; - if(JumpCall_Count < 2) + if(cx->dis_JumpCallN < 2) return; Sort_JumpCalls(); Correct_Label_Types(); - Destination = JumpCalls[0].To; - if(JumpCalls[0].FunctionCall) + Destination = cx->dis_JumpCalls[0].To; + if(cx->dis_JumpCalls[0].FunctionCall) CurrentFunctionNumber++; else CurrentLabelNumber++; - for(i = 0; i < JumpCall_Count; i++) { - if(Destination != JumpCalls[i].To) { - if(JumpCalls[i].FunctionCall) + for(i = 0; i < cx->dis_JumpCallN; i++) { + if(Destination != cx->dis_JumpCalls[i].To) { + if(cx->dis_JumpCalls[i].FunctionCall) CurrentFunctionNumber++; else CurrentLabelNumber++; - Destination = JumpCalls[i].To; + Destination = cx->dis_JumpCalls[i].To; } - if(JumpCalls[i].FunctionCall) - JumpCalls[i].LabelNumber = CurrentFunctionNumber; + if(cx->dis_JumpCalls[i].FunctionCall) + cx->dis_JumpCalls[i].LabelNumber = CurrentFunctionNumber; else - JumpCalls[i].LabelNumber = CurrentLabelNumber; + cx->dis_JumpCalls[i].LabelNumber = CurrentLabelNumber; } } @@ -151,9 +148,9 @@ const char *Get_Label_Name(int Destination, char **LabelComment) { return str_ccprintf("%s", Tagfile_GetLabel(TagIndex)); } - for(int i = 0; i < JumpCall_Count; i++) - if(JumpCalls[i].To == Destination) - return str_ccprintf("%s%d", JumpCalls[i].FunctionCall? "Function": "Label", JumpCalls[i].LabelNumber); + for(int i = 0; i < cx->dis_JumpCallN; i++) + if(cx->dis_JumpCalls[i].To == Destination) + return str_ccprintf("%s%d", cx->dis_JumpCalls[i].FunctionCall? "Function": "Label", cx->dis_JumpCalls[i].LabelNumber); return "UNKNOWN"; } @@ -163,13 +160,13 @@ void Print_JumpCalls(int Position) { int i; int Match = 0; - for(i = 0; i < JumpCall_Count; i++) { - if((JumpCalls[i].To) == Position) { + for(i = 0; i < cx->dis_JumpCallN; i++) { + if((cx->dis_JumpCalls[i].To) == Position) { if(Match == 0) { printf("\n"); Match = 1; } - printf("; Referenced from offset 0x%02x by %s\n", JumpCalls[i].From, avr_opcodes[JumpCalls[i].Type].opcode); + printf("; Referenced from offset 0x%02x by %s\n", cx->dis_JumpCalls[i].From, avr_opcodes[cx->dis_JumpCalls[i].Type].opcode); } } if(Match == 1) { diff --git a/src/disasm_private.h b/src/disasm_private.h index 053abe39..2889b4e5 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -36,11 +36,3 @@ #define CALLBACK(name) void name(const char *Bitstream, int Position, AVR_opcode mnemo) -struct JumpCall { - int From; - int To; - int Type; - unsigned int LabelNumber; - unsigned char FunctionCall; -}; - diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index 9f2e7f1f..d324b7f7 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -37,54 +37,16 @@ #include "disasm_private.h" #include "disasm_tagfile.h" -struct CodeLabel { - int Address; - char *Text; - char *Comment; -}; - -struct PGMLabel { - int Address; - char Type; - unsigned int Count; - char *Comment; -}; - -struct MemLabel { - int Address; - char Type; - unsigned int Count; - char *Comment; -}; - -struct IO_Register { - int Address; - char *Name; - unsigned char Used; -}; - -static int CodeLabelCount = 0; -static struct CodeLabel *CodeLabels; - -static int PGMLabelCount = 0; -static struct PGMLabel *PGMLabels = NULL; - -static int MemLabelCount = 0; -static struct MemLabel *MemLabels = NULL; - -static struct IO_Register *IORegisters = NULL; -static int IORegistersCount = 0; - /* static void Display_Tagfile() { int i; - printf("%d code labels:\n", CodeLabelCount); - for(i = 0; i < CodeLabelCount; i++) - printf("%d: 0x%x = %s\n", i, CodeLabels[i].Address, CodeLabels[i].Text); + printf("%d code labels:\n", cx->dis_CodeLabelN); + for(i = 0; i < cx->dis_CodeLabelN; i++) + printf("%d: 0x%x = %s\n", i, cx->dis_CodeLabels[i].Address, cx->dis_CodeLabels[i].Text); - printf("%d PGM labels:\n", PGMLabelCount); - for(i = 0; i < PGMLabelCount; i++) - printf("%d: 0x%x = %d * %d\n", i, PGMLabels[i].Address, PGMLabels[i].Count, PGMLabels[i].Type); + printf("%d PGM labels:\n", cx->dis_PGMLabelN); + for(i = 0; i < cx->dis_PGMLabelN; i++) + printf("%d: 0x%x = %d * %d\n", i, cx->dis_PGMLabels[i].Address, cx->dis_PGMLabels[i].Count, cx->dis_PGMLabels[i].Type); } */ @@ -122,32 +84,32 @@ static int ahtoi(const char *String) { } static void Add_LabelTag(int Address, const char *LabelText, const char *LabelComment) { - CodeLabelCount++; + cx->dis_CodeLabelN++; - CodeLabels = (struct CodeLabel *) mmt_realloc(CodeLabels, sizeof(struct CodeLabel) * CodeLabelCount); - CodeLabels[CodeLabelCount - 1].Address = Address; - CodeLabels[CodeLabelCount - 1].Text = LabelText? mmt_strdup(LabelText): NULL; - CodeLabels[CodeLabelCount - 1].Comment = LabelComment? mmt_strdup(LabelComment): NULL; + cx->dis_CodeLabels = (Disasm_CodeLabel *) mmt_realloc(cx->dis_CodeLabels, sizeof(Disasm_CodeLabel) * cx->dis_CodeLabelN); + cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].Address = Address; + cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].Text = LabelText? mmt_strdup(LabelText): NULL; + cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].Comment = LabelComment? mmt_strdup(LabelComment): NULL; } static void Add_PGM_Tag(int Address, char Type, unsigned int Count, const char *Comment) { - PGMLabelCount++; + cx->dis_PGMLabelN++; - PGMLabels = (struct PGMLabel *) mmt_realloc(PGMLabels, sizeof(struct PGMLabel) * PGMLabelCount); - PGMLabels[PGMLabelCount - 1].Address = Address; - PGMLabels[PGMLabelCount - 1].Type = Type; - PGMLabels[PGMLabelCount - 1].Count = Count; - PGMLabels[PGMLabelCount - 1].Comment = Comment? mmt_strdup(Comment): NULL; + cx->dis_PGMLabels = (Disasm_PGMLabel *) mmt_realloc(cx->dis_PGMLabels, sizeof(Disasm_PGMLabel) * cx->dis_PGMLabelN); + cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Address = Address; + cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Type = Type; + cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Count = Count; + cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Comment = Comment? mmt_strdup(Comment): NULL; } static void Add_Mem_Tag(int Address, char Type, unsigned int Count, const char *Comment) { - MemLabelCount++; + cx->dis_MemLabelN++; - MemLabels = (struct MemLabel *) mmt_realloc(MemLabels, sizeof(struct MemLabel) * MemLabelCount); - MemLabels[MemLabelCount - 1].Address = Address; - MemLabels[MemLabelCount - 1].Type = Type; - MemLabels[MemLabelCount - 1].Count = Count; - MemLabels[MemLabelCount - 1].Comment = Comment? mmt_strdup(Comment): NULL; + cx->dis_MemLabels = (Disasm_MemLabel *) mmt_realloc(cx->dis_MemLabels, sizeof(Disasm_MemLabel) * cx->dis_MemLabelN); + cx->dis_MemLabels[cx->dis_MemLabelN - 1].Address = Address; + cx->dis_MemLabels[cx->dis_MemLabelN - 1].Type = Type; + cx->dis_MemLabels[cx->dis_MemLabelN - 1].Count = Count; + cx->dis_MemLabels[cx->dis_MemLabelN - 1].Comment = Comment? mmt_strdup(Comment): NULL; } static void Tagfile_Readline(char *Line, int LineNo) { @@ -237,10 +199,10 @@ static void Tagfile_Readline(char *Line, int LineNo) { } static int CodeLabelSort(const void *A, const void *B) { - const struct CodeLabel *X, *Y; + const Disasm_CodeLabel *X, *Y; - X = (const struct CodeLabel *) A; - Y = (const struct CodeLabel *) B; + X = (const Disasm_CodeLabel *) A; + Y = (const Disasm_CodeLabel *) B; if(X->Address == Y->Address) return 0; if(X->Address < Y->Address) @@ -249,10 +211,10 @@ static int CodeLabelSort(const void *A, const void *B) { } static int PGMLabelSort(const void *A, const void *B) { - const struct PGMLabel *X, *Y; + const Disasm_PGMLabel *X, *Y; - X = (const struct PGMLabel *) A; - Y = (const struct PGMLabel *) B; + X = (const Disasm_PGMLabel *) A; + Y = (const Disasm_PGMLabel *) B; if(X->Address == Y->Address) return 0; if(X->Address < Y->Address) @@ -261,10 +223,10 @@ static int PGMLabelSort(const void *A, const void *B) { } static int MemLabelSort(const void *A, const void *B) { - const struct MemLabel *X, *Y; + const Disasm_MemLabel *X, *Y; - X = (const struct MemLabel *) A; - Y = (const struct MemLabel *) B; + X = (const Disasm_MemLabel *) A; + Y = (const Disasm_MemLabel *) B; if(X->Address == Y->Address) return 0; if(X->Address < Y->Address) @@ -273,9 +235,9 @@ static int MemLabelSort(const void *A, const void *B) { } static void Tagfile_SortLabels() { - qsort(CodeLabels, CodeLabelCount, sizeof(struct CodeLabel), CodeLabelSort); - qsort(PGMLabels, PGMLabelCount, sizeof(struct PGMLabel), PGMLabelSort); - qsort(MemLabels, MemLabelCount, sizeof(struct MemLabel), MemLabelSort); + qsort(cx->dis_CodeLabels, cx->dis_CodeLabelN, sizeof(Disasm_CodeLabel), CodeLabelSort); + qsort(cx->dis_PGMLabels, cx->dis_PGMLabelN, sizeof(Disasm_PGMLabel), PGMLabelSort); + qsort(cx->dis_MemLabels, cx->dis_MemLabelN, sizeof(Disasm_MemLabel), MemLabelSort); } int Read_Tagfile(const char *Filename) { @@ -303,51 +265,51 @@ int Read_Tagfile(const char *Filename) { } int Tagfile_FindLabelAddress(int Address) { - struct CodeLabel Goal; - struct CodeLabel *Result; + Disasm_CodeLabel Goal; + Disasm_CodeLabel *Result; Goal.Address = Address; - Result = bsearch(&Goal, CodeLabels, CodeLabelCount, sizeof(struct CodeLabel), CodeLabelSort); + Result = bsearch(&Goal, cx->dis_CodeLabels, cx->dis_CodeLabelN, sizeof(Disasm_CodeLabel), CodeLabelSort); if(Result == NULL) return -1; - return Result - CodeLabels; + return Result - cx->dis_CodeLabels; } char *Tagfile_GetLabel(int TagIndex) { - return CodeLabels[TagIndex].Text; + return cx->dis_CodeLabels[TagIndex].Text; } char *Tagfile_GetLabelComment(int TagIndex) { - return CodeLabels[TagIndex].Comment; + return cx->dis_CodeLabels[TagIndex].Comment; } int Tagfile_FindPGMAddress(int Address) { - struct PGMLabel Goal; - struct PGMLabel *Result; + Disasm_PGMLabel Goal; + Disasm_PGMLabel *Result; Goal.Address = Address; - Result = bsearch(&Goal, PGMLabels, PGMLabelCount, sizeof(struct PGMLabel), PGMLabelSort); + Result = bsearch(&Goal, cx->dis_PGMLabels, cx->dis_PGMLabelN, sizeof(Disasm_PGMLabel), PGMLabelSort); if(Result == NULL) return -1; - return Result - PGMLabels; + return Result - cx->dis_PGMLabels; } const char *Tagfile_Resolve_Mem_Address(int Address) { - for(int i = 0; i < MemLabelCount && MemLabels[i].Address <= Address; i++) { - int Start = MemLabels[i].Address; - int Size = MemLabels[i].Type == TYPE_WORD? 2: 1; - int End = MemLabels[i].Address + MemLabels[i].Count * Size - 1; + for(int i = 0; i < cx->dis_MemLabelN && cx->dis_MemLabels[i].Address <= Address; i++) { + int Start = cx->dis_MemLabels[i].Address; + int Size = cx->dis_MemLabels[i].Type == TYPE_WORD? 2: 1; + int End = cx->dis_MemLabels[i].Address + cx->dis_MemLabels[i].Count * Size - 1; if(Address >= Start && Address <= End) { - if(MemLabels[i].Count == 1) { // Single variable + if(cx->dis_MemLabels[i].Count == 1) { // Single variable if(Size == 1) - return str_ccprintf("%s", MemLabels[i].Comment); - return str_ccprintf("_%s8(%s)", Address == Start? "lo": "hi", MemLabels[i].Comment); + return str_ccprintf("%s", cx->dis_MemLabels[i].Comment); + return str_ccprintf("_%s8(%s)", Address == Start? "lo": "hi", cx->dis_MemLabels[i].Comment); } // Array if(Size == 1) - return str_ccprintf("%s[%d]", MemLabels[i].Comment, Address - Start); - return str_ccprintf("_%s8(%s[%d])", (Address-Start)%2? "hi": "lo", MemLabels[i].Comment, + return str_ccprintf("%s[%d]", cx->dis_MemLabels[i].Comment, Address - Start); + return str_ccprintf("_%s8(%s[%d])", (Address-Start)%2? "hi": "lo", cx->dis_MemLabels[i].Comment, (Address - Start)/2); } } @@ -418,7 +380,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { if(Index == -1) return 0; - switch (PGMLabels[Index].Type) { + switch (cx->dis_PGMLabels[Index].Type) { case TYPE_BYTE: ProcessingFunction = Tagfile_Process_Byte; break; @@ -433,8 +395,8 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { break; } - printf("; Inline PGM data: %d ", PGMLabels[Index].Count); - switch (PGMLabels[Index].Type) { + printf("; Inline PGM data: %d ", cx->dis_PGMLabels[Index].Count); + switch (cx->dis_PGMLabels[Index].Type) { case TYPE_BYTE: printf("byte"); break; @@ -448,18 +410,18 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { printf("string"); break; } - if(PGMLabels[Index].Count != 1) + if(cx->dis_PGMLabels[Index].Count != 1) printf("s"); printf(" starting at 0x%x", Position); - if(PGMLabels[Index].Comment != NULL) { - printf(" (%s)", PGMLabels[Index].Comment); + if(cx->dis_PGMLabels[Index].Comment != NULL) { + printf(" (%s)", cx->dis_PGMLabels[Index].Comment); } printf("\n"); - if((PGMLabels[Index].Type == TYPE_ASTRING) || (PGMLabels[Index].Type == TYPE_STRING)) { - if(PGMLabels[Index].Comment != NULL) { - snprintf(Buffer, sizeof(Buffer), "%x_%s", Position, PGMLabels[Index].Comment); + if((cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].Type == TYPE_STRING)) { + if(cx->dis_PGMLabels[Index].Comment != NULL) { + snprintf(Buffer, sizeof(Buffer), "%x_%s", Position, cx->dis_PGMLabels[Index].Comment); Sanitize_String(Buffer); } else { snprintf(Buffer, sizeof(Buffer), "%x", Position); @@ -467,11 +429,11 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { } BytesAdvanced = 0; - for(i = 0; i < PGMLabels[Index].Count; i++) { + for(i = 0; i < cx->dis_PGMLabels[Index].Count; i++) { BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, i, Buffer); } - if(PGMLabels[Index].Type == TYPE_ASTRING) { + if(cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) { // Autoaligned string if((BytesAdvanced % 2) != 0) { // Not yet aligned correctly @@ -501,72 +463,72 @@ static char *regname(const char *reg, int suf) { return ret; } -// Initialise IORegisters and MemLabels from part register file +// Initialise cx->dis_IORegisters and cx->dis_MemLabels from part register file void initRegisters(const AVRPART *p) { int nr = 0, nio = 0, offset = 0; const Register_file *rf = avr_locate_register_file(p, &nr); if(rf) { - if(IORegisters) { - for(int i = 0; i < IORegistersCount; i++) - mmt_free(IORegisters[i].Name); - mmt_free(IORegisters); + if(cx->dis_IORegisters) { + for(int i = 0; i < cx->dis_IORegisterN; i++) + mmt_free(cx->dis_IORegisters[i].Name); + mmt_free(cx->dis_IORegisters); } - if(MemLabels) { - for(int i = 0; i < MemLabelCount; i++) - mmt_free(MemLabels[i].Comment); - mmt_free(MemLabels); + if(cx->dis_MemLabels) { + for(int i = 0; i < cx->dis_MemLabelN; i++) + mmt_free(cx->dis_MemLabels[i].Comment); + mmt_free(cx->dis_MemLabels); } // Count how many entries are needed for(int i = 0; i< nr; i++) if(rf[i].addr < 0x40 && rf[i].size > 0) nio += rf[i].size; - IORegisters = mmt_malloc(nio*sizeof*IORegisters); - MemLabels = mmt_malloc(nr*sizeof*MemLabels); + cx->dis_IORegisters = mmt_malloc(nio*sizeof*cx->dis_IORegisters); + cx->dis_MemLabels = mmt_malloc(nr*sizeof*cx->dis_MemLabels); AVRMEM *mem = avr_locate_io(p); if(mem) offset = mem->offset; nio = 0; for(int i = 0; i< nr; i++) { - MemLabels[i].Address = offset + rf[i].addr; - MemLabels[i].Type = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; - MemLabels[i].Count = rf[i].size > 2? rf[i].size: 1; - MemLabels[i].Comment = regname(rf[i].reg, -1); + cx->dis_MemLabels[i].Address = offset + rf[i].addr; + cx->dis_MemLabels[i].Type = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; + cx->dis_MemLabels[i].Count = rf[i].size > 2? rf[i].size: 1; + cx->dis_MemLabels[i].Comment = regname(rf[i].reg, -1); if(rf[i].addr < 0x40) { if(rf[i].size == 1) { - IORegisters[nio].Name = regname(rf[i].reg, -1); - IORegisters[nio].Address = rf[i].addr; + cx->dis_IORegisters[nio].Name = regname(rf[i].reg, -1); + cx->dis_IORegisters[nio].Address = rf[i].addr; nio++; } else if(rf[i].size == 2) { - IORegisters[nio].Name = regname(rf[i].reg, 'l'); - IORegisters[nio].Address = rf[i].addr; + cx->dis_IORegisters[nio].Name = regname(rf[i].reg, 'l'); + cx->dis_IORegisters[nio].Address = rf[i].addr; nio++; - IORegisters[nio].Name = regname(rf[i].reg, 'h'); - IORegisters[nio].Address = rf[i].addr+1; + cx->dis_IORegisters[nio].Name = regname(rf[i].reg, 'h'); + cx->dis_IORegisters[nio].Address = rf[i].addr+1; nio++; } else if(rf[i].size > 2) { for(int k = 0; k < rf[i].size; k++) { - IORegisters[nio].Name = regname(rf[i].reg, k); - IORegisters[nio].Address = rf[i].addr + k; + cx->dis_IORegisters[nio].Name = regname(rf[i].reg, k); + cx->dis_IORegisters[nio].Address = rf[i].addr + k; nio++; } } } } - IORegistersCount = nio; - MemLabelCount = nr; - qsort(MemLabels, MemLabelCount, sizeof(struct MemLabel), MemLabelSort); + cx->dis_IORegisterN = nio; + cx->dis_MemLabelN = nr; + qsort(cx->dis_MemLabels, cx->dis_MemLabelN, sizeof(Disasm_MemLabel), MemLabelSort); } } const char *Resolve_IO_Register(int Number) { - for(int i = 0; i < IORegistersCount; i++) { - if(IORegisters[i].Address == Number) { - IORegisters[i].Used = 1; - return IORegisters[i].Name; + for(int i = 0; i < cx->dis_IORegisterN; i++) { + if(cx->dis_IORegisters[i].Address == Number) { + cx->dis_IORegisters[i].Used = 1; + return cx->dis_IORegisters[i].Name; } } @@ -574,7 +536,7 @@ const char *Resolve_IO_Register(int Number) { } void Emit_Used_IO_Registers() { - for(int i = 0; i < IORegistersCount; i++) - if(IORegisters[i].Used) - printf(".equ %s, 0x%x\n", IORegisters[i].Name, IORegisters[i].Address); + for(int i = 0; i < cx->dis_IORegisterN; i++) + if(cx->dis_IORegisters[i].Used) + printf(".equ %s, 0x%x\n", cx->dis_IORegisters[i].Name, cx->dis_IORegisters[i].Address); } diff --git a/src/libavrdude.h b/src/libavrdude.h index ecf0c52e..1c2b8f74 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1470,6 +1470,40 @@ typedef struct { AVR_cycle_index cycle_index; } Disasm_options; +typedef struct { + int From; + int To; + int Type; + unsigned int LabelNumber; + unsigned char FunctionCall; +} Disasm_JumpCall; + +typedef struct { + int Address; + char *Text; + char *Comment; +} Disasm_CodeLabel; + +typedef struct { + int Address; + char Type; + unsigned int Count; + char *Comment; +} Disasm_PGMLabel; + +typedef struct { + int Address; + char Type; + unsigned int Count; + char *Comment; +} Disasm_MemLabel; + +typedef struct { + int Address; + char *Name; + unsigned char Used; +} Disasm_IO_Register; + typedef enum { OPCODE_add, OPCODE_adc, OPCODE_adiw, OPCODE_sub, OPCODE_subi, OPCODE_sbc, OPCODE_sbci, OPCODE_sbiw, @@ -1776,6 +1810,12 @@ typedef struct { Disasm_opcode dis_op[256]; // Must be 256 int dis_regs[256]; // Must be 256 char dis_code[256], dis_comment[256], dis_after_code[256]; // Must be 256 + int dis_JumpCallN, dis_CodeLabelN, dis_PGMLabelN, dis_MemLabelN, dis_IORegisterN; + Disasm_JumpCall *dis_JumpCalls; + Disasm_CodeLabel *dis_CodeLabels; + Disasm_PGMLabel *dis_PGMLabels; + Disasm_MemLabel *dis_MemLabels; + Disasm_IO_Register *dis_IORegisters; // Static variables from usb_libusb.c #include "usbdevs.h" From ebd740d6da87af9152e4e29beed129f937167cc5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 01:35:48 +0100 Subject: [PATCH 298/422] Suppress compiler warning --- src/disasm.c | 2 ++ src/disasm_tagfile.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index aaf206c1..b897f681 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -41,6 +41,7 @@ #include "disasm_jumpcall.h" #include "disasm_tagfile.h" +/**** void Display_Registers() { int i; @@ -52,6 +53,7 @@ void Display_Registers() { } printf("End of register dump.\n"); } +****/ int Compare_Opcode(const char *Bitstream, const char *Bitmask) { size_t i; diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index d324b7f7..a1e5b295 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -370,7 +370,6 @@ static void Sanitize_String(char *String) { } int Tagfile_Process_Data(const char *Bitstream, int Position) { - int i; int BytesAdvanced; int Index; int (*ProcessingFunction)(const char *, int, int, const char *) = NULL; @@ -429,9 +428,8 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { } BytesAdvanced = 0; - for(i = 0; i < cx->dis_PGMLabels[Index].Count; i++) { + for(unsigned i = 0; i < cx->dis_PGMLabels[Index].Count; i++) BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, i, Buffer); - } if(cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) { // Autoaligned string From 06a40f5017728fc8261efd8796c27e14f84f0a1e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 02:13:28 +0100 Subject: [PATCH 299/422] Adjust address to disassembly start --- src/disasm.c | 20 ++++++++++---------- src/disasm_tagfile.c | 20 ++++++++++---------- src/disasm_tagfile.h | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index b897f681..c41986ad 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -219,7 +219,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) { if(Opcode == -1) { Pos += 2; } else { - cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].mnemo); + cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos + addr, cx->dis_op[Opcode].mnemo); Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; } } @@ -235,7 +235,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) { int Added; // Check if this is actually code or maybe only data from tagfile - Added = Tagfile_Process_Data(Bitstream, Pos); + Added = Tagfile_Process_Data(Bitstream, Pos, addr); if(Added != 0) { // Data was added Pos += Added; @@ -247,22 +247,22 @@ void Disassemble(const char *Bitstream, int Read, int addr) { cx->dis_code[0] = 0; cx->dis_comment[0] = 0; cx->dis_after_code[0] = 0; - cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].mnemo); + cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos + addr, cx->dis_op[Opcode].mnemo); if(cx->dis_opts.Process_Labels) { - Print_JumpCalls(Pos); + Print_JumpCalls(Pos + addr); } if(cx->dis_opts.Show_Addresses) - printf("%4x: ", Pos); - if(cx->dis_opts.Show_Cycles) // @@@ select correct clocks_xx + printf("%4x: ", Pos + addr); + if(cx->dis_opts.Show_Cycles) printf("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clock[cx->dis_opts.cycle_index]); if(cx->dis_opts.Show_Opcodes) { // Now display the Opcode - for(i = 0; i < (Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8; i++) { + for(i = 0; i < (Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8; i++) printf("%02x ", (unsigned char) (Bitstream[Pos + i])); - } + printf(" "); // Missing spaces for(i = 0; i < 5 - ((Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8); i++) { @@ -286,8 +286,8 @@ void Disassemble(const char *Bitstream, int Read, int addr) { Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; } else { - printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x (%d). Disassembler skipped two bytes.\n", - ((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], Pos, Pos); + printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x\n", // @@@ show unoffical opcode what it might do + ((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], Pos + addr); Pos += 2; } } diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index a1e5b295..eed19e6f 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -317,17 +317,17 @@ const char *Tagfile_Resolve_Mem_Address(int Address) { return NULL; } -static int Tagfile_Process_Byte(const char *Bitstream, int Position, int ArgumentNo, const char *Label) { +static int Tagfile_Process_Byte(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { printf(".byte 0x%02x\n", Bitstream[Position] & 0xff); return 1; } -static int Tagfile_Process_Word(const char *Bitstream, int Position, int ArgumentNo, const char *Label) { +static int Tagfile_Process_Word(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { printf(".word 0x%02x%02x\n", Bitstream[Position + 1] & 0xff, Bitstream[Position] & 0xff); return 2; } -static int Tagfile_Process_String(const char *Bitstream, int Position, int ArgumentNo, const char *Label) { +static int Tagfile_Process_String(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { int i; unsigned char c; unsigned int InString = 0; @@ -369,13 +369,13 @@ static void Sanitize_String(char *String) { } } -int Tagfile_Process_Data(const char *Bitstream, int Position) { +int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { int BytesAdvanced; int Index; - int (*ProcessingFunction)(const char *, int, int, const char *) = NULL; + int (*ProcessingFunction)(const char *, int, int, int, const char *) = NULL; char Buffer[32]; - Index = Tagfile_FindPGMAddress(Position); + Index = Tagfile_FindPGMAddress(Position + offset); if(Index == -1) return 0; @@ -411,7 +411,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { } if(cx->dis_PGMLabels[Index].Count != 1) printf("s"); - printf(" starting at 0x%x", Position); + printf(" starting at 0x%x", Position + offset); if(cx->dis_PGMLabels[Index].Comment != NULL) { printf(" (%s)", cx->dis_PGMLabels[Index].Comment); @@ -420,16 +420,16 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) { if((cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].Type == TYPE_STRING)) { if(cx->dis_PGMLabels[Index].Comment != NULL) { - snprintf(Buffer, sizeof(Buffer), "%x_%s", Position, cx->dis_PGMLabels[Index].Comment); + snprintf(Buffer, sizeof(Buffer), "%x_%s", Position + offset, cx->dis_PGMLabels[Index].Comment); Sanitize_String(Buffer); } else { - snprintf(Buffer, sizeof(Buffer), "%x", Position); + snprintf(Buffer, sizeof(Buffer), "%x", Position + offset); } } BytesAdvanced = 0; for(unsigned i = 0; i < cx->dis_PGMLabels[Index].Count; i++) - BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, i, Buffer); + BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, offset, i, Buffer); if(cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) { // Autoaligned string diff --git a/src/disasm_tagfile.h b/src/disasm_tagfile.h index db1066da..ddac58d1 100644 --- a/src/disasm_tagfile.h +++ b/src/disasm_tagfile.h @@ -36,7 +36,7 @@ char *Tagfile_GetLabel(int TagIndex); char *Tagfile_GetLabelComment(int TagIndex); int Tagfile_FindPGMAddress(int Address); const char *Tagfile_Resolve_Mem_Address(int Address); -int Tagfile_Process_Data(const char *Bitstream, int Position); +int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); const char *Resolve_IO_Register(int Number); void Emit_Used_IO_Registers(); From 058265a25a436651b71d04b24b8935b4c260179a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 14:11:46 +0100 Subject: [PATCH 300/422] Update spacing in avr_opcodes table and describe unallocated opcodes --- src/avr_opcodes.c | 328 +++++++++++++++++++++++----------------------- 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index ba061b6a..e8ffa350 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -22,178 +22,178 @@ const AVR_opcode_data avr_opcodes[164] = { // Arithmetic and Logic Instructions - {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OP_AVR1, OPCODE_add, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OP_AVR1, OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OP_AVR2nRC, OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, - {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OP_AVR1, OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OP_AVR1, OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OP_AVR1, OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OP_AVR1, OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d=16..31"}, - {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OP_AVR2nRC, OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, - {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OP_AVR1, OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", {"1", "1", "1", "1"}, "d = 16..31"}, - {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OP_AVR1, OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OP_AVR1, OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ORI Rd, K"}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ANDI Rd, (0xFF - K)"}, - {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for AND Rd, Rd"}, - {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for EOR Rd, Rd"}, - {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for LDI Rd, 0xFF"}, - {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", {"2", "2", "2", "n/a"}, ""}, - {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..31"}, - {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..23"}, - {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OP_AVR4, OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, - {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OP_AVR4, OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, - {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, - {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OP_AVR_XM, OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", {"n/a", "1/2", "n/a", "n/a"}, ""}, + {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OP_AVR1, OPCODE_add, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OP_AVR1, OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OP_AVR2nRC, OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, + {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OP_AVR1, OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OP_AVR1, OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OP_AVR1, OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OP_AVR1, OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d=16..31"}, + {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OP_AVR2nRC, OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, + {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OP_AVR1, OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", {"1", "1", "1", "1"}, "d = 16..31"}, + {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OP_AVR1, OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OP_AVR1, OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ORI Rd, K"}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ANDI Rd, (0xFF - K)"}, + {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for AND Rd, Rd"}, + {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for EOR Rd, Rd"}, + {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for LDI Rd, 0xFF"}, + {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", {"2", "2", "2", "n/a"}, ""}, + {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..31"}, + {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..23"}, + {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OP_AVR4, OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, + {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OP_AVR4, OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, + {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, + {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OP_AVR_XM, OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", {"n/a", "1/2", "n/a", "n/a"}, ""}, // Branch Instructions - {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OP_AVR1, OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", {"2", "2", "2", "2"}, ""}, - {0xffff, 0x9409, 1, "1001 0100 0000 1001", OP_AVR2, OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, ""}, - {0xffff, 0x9419, 1, "1001 0100 0001 1001", OP_AVR_XL, OPCODE_eijmp, "eijmp", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, ""}, - {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", {"3", "3", "3", "n/a"}, ""}, - {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OP_AVR1, OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", {"3/4", "2/3", "2/3", "3"}, ""}, - {0xffff, 0x9509, 1, "1001 0101 0000 1001", OP_AVR2, OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, ""}, - {0xffff, 0x9519, 1, "1001 0101 0001 1001", OP_AVR_XL, OPCODE_eicall, "eicall", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, ""}, - {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", {"4/5", "3/4", "3/4", "n/a"}, ""}, - {0xffff, 0x9508, 1, "1001 0101 0000 1000", OP_AVR1, OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, ""}, - {0xffff, 0x9518, 1, "1001 0101 0001 1000", OP_AVR1, OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, ""}, - {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OP_AVR1, OPCODE_cpse, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OP_AVR1, OPCODE_cp, "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OP_AVR1, OPCODE_cpc, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OP_AVR1, OPCODE_cpi, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d = 16..31"}, - {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OP_AVR1, OPCODE_sbrc, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OP_AVR1, OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OP_AVR1, OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, - {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OP_AVR1, OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OP_AVR1, OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 1, k (Z Zero)"}, - {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OP_AVR1, OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 2, k (N Negative)"}, - {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OP_AVR1, OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OP_AVR1, OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 4, k (S Sign)"}, - {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OP_AVR1, OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 5, k (H Half carry)"}, - {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OP_AVR1, OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 6, k (T Transfer bit)"}, - {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OP_AVR1, OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 7, k (I Interrupt enable)"}, - {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OP_AVR1, OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OP_AVR1, OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 1, k (Z Zero)"}, - {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OP_AVR1, OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 2, k (N Negative)"}, - {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OP_AVR1, OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OP_AVR1, OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 4, k (S Sign)"}, - {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OP_AVR1, OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 5, k (H Half carry)"}, - {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OP_AVR1, OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 6, k (T Transfer bit)"}, - {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OP_AVR1, OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 7, k (I Interrupt enable)"}, - {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OP_AVR1, OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, + {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OP_AVR1, OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", {"2", "2", "2", "2"}, ""}, + {0xffff, 0x9409, 1, "1001 0100 0000 1001", OP_AVR2, OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, ""}, + {0xffff, 0x9419, 1, "1001 0100 0001 1001", OP_AVR_XL, OPCODE_eijmp, "eijmp", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, ""}, + {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", {"3", "3", "3", "n/a"}, ""}, + {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OP_AVR1, OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", {"3/4", "2/3", "2/3", "3"}, ""}, + {0xffff, 0x9509, 1, "1001 0101 0000 1001", OP_AVR2, OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, ""}, + {0xffff, 0x9519, 1, "1001 0101 0001 1001", OP_AVR_XL, OPCODE_eicall, "eicall", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, ""}, + {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", {"4/5", "3/4", "3/4", "n/a"}, ""}, + {0xffff, 0x9508, 1, "1001 0101 0000 1000", OP_AVR1, OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, ""}, + {0xffff, 0x9518, 1, "1001 0101 0001 1000", OP_AVR1, OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, ""}, + {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OP_AVR1, OPCODE_cpse, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OP_AVR1, OPCODE_cp, "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OP_AVR1, OPCODE_cpc, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OP_AVR1, OPCODE_cpi, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d = 16..31"}, + {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OP_AVR1, OPCODE_sbrc, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OP_AVR1, OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OP_AVR1, OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, + {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OP_AVR1, OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 0, k (C Carry)"}, + {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OP_AVR1, OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 1, k (Z Zero)"}, + {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OP_AVR1, OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 2, k (N Negative)"}, + {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OP_AVR1, OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OP_AVR1, OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 4, k (S Sign)"}, + {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OP_AVR1, OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 5, k (H Half carry)"}, + {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OP_AVR1, OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 6, k (T Transfer bit)"}, + {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OP_AVR1, OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 7, k (I Interrupt enable)"}, + {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OP_AVR1, OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 0, k (C Carry)"}, + {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OP_AVR1, OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 1, k (Z Zero)"}, + {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OP_AVR1, OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 2, k (N Negative)"}, + {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OP_AVR1, OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OP_AVR1, OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 4, k (S Sign)"}, + {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OP_AVR1, OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 5, k (H Half carry)"}, + {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OP_AVR1, OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 6, k (T Transfer bit)"}, + {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OP_AVR1, OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 7, k (I Interrupt enable)"}, + {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OP_AVR1, OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, // Data Transfer Instructions - {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OP_AVR1, OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", {"1", "1", "1", "1"}, ""}, - {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", {"1", "1", "1", "n/a"}, ""}, - {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", {"1", "1", "1", "1"}, "d=16..31"}, - {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"2", "3", "3", "2"}, ""}, - {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts)"}, - {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OP_AVR2, OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", {"2", "2", "2", "1/2"}, ""}, - {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OP_AVR2, OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", {"2", "2", "2", "2/3"}, ""}, - {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OP_AVR2, OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", {"2", "3", "2", "2/3"}, ""}, - {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OP_AVR2, OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", {"2", "2", "2", "1/2"}, "alias for LDD Rd, Y+0"}, - {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OP_AVR2, OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", {"2", "2", "2", "2/3"}, ""}, - {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OP_AVR2, OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", {"2", "3", "2", "2/3"}, ""}, - {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OP_AVR2nRC, OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", {"2", "3", "2", "n/a"}, ""}, - {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OP_AVR1, OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", {"2", "2", "2", "1/2"}, "alias for LDD Rd,Z+0"}, - {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OP_AVR1, OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"2", "2", "2", "2/3"}, ""}, - {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OP_AVR1, OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", {"2", "3", "2", "2/3"}, ""}, - {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OP_AVR2nRC, OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", {"2", "3", "2", "n/a"}, ""}, - {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", {"2", "2", "2", "1"}, ""}, - {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OP_AVR_RC, OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts)"}, - {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OP_AVR2, OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OP_AVR2, OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OP_AVR2, OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, - {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OP_AVR2, OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for STD Y+0, Rr"}, - {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OP_AVR2, OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OP_AVR2, OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, - {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OP_AVR2nRC, OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, - {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OP_AVR1, OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for STD Z+0, Rr"}, - {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OP_AVR1, OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OP_AVR1, OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", {"2", "2", "1", "1"}, ""}, - {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OP_AVR2nRC, OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, - {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OP_AVR1nRC, OPCODE_lpm_1, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", {"3", "3", "3", "n/a"}, ""}, - {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OP_AVR25, OPCODE_lpm_2, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", {"3", "3", "3", "n/a"}, ""}, - {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OP_AVR25, OPCODE_lpm_3, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, - {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OP_AVR_L, OPCODE_elpm_1, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", {"3", "3", "3", "n/a"}, ""}, - {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OP_AVR_L, OPCODE_elpm_2, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", {"3", "3", "3", "n/a"}, ""}, - {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OP_AVR_L, OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, - {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OP_AVR25, OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", {"-", "-", "-", "-"}, ""}, - {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OP_AVR_XTM, OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", {"n/a", "-", "-", "n/a"}, ""}, - {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", {"1", "1", "1", "1"}, ""}, - {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", {"2", "2", "2", "3"}, ""}, - {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OP_AVR1, OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", {"1", "1", "1", "1"}, ""}, + {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", {"1", "1", "1", "n/a"}, ""}, + {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", {"1", "1", "1", "1"}, "d=16..31"}, + {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"2", "3", "3", "2"}, ""}, + {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts)"}, + {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OP_AVR2, OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", {"2", "2", "2", "1/2"}, ""}, + {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OP_AVR2, OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", {"2", "2", "2", "2/3"}, ""}, + {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OP_AVR2, OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", {"2", "3", "2", "2/3"}, ""}, + {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OP_AVR2, OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", {"2", "2", "2", "1/2"}, "alias for LDD Rd, Y+0"}, + {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OP_AVR2, OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", {"2", "2", "2", "2/3"}, ""}, + {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OP_AVR2, OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", {"2", "3", "2", "2/3"}, ""}, + {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OP_AVR2nRC, OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", {"2", "3", "2", "n/a"}, ""}, + {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OP_AVR1, OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", {"2", "2", "2", "1/2"}, "alias for LDD Rd,Z+0"}, + {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OP_AVR1, OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"2", "2", "2", "2/3"}, ""}, + {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OP_AVR1, OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", {"2", "3", "2", "2/3"}, ""}, + {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OP_AVR2nRC, OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", {"2", "3", "2", "n/a"}, ""}, + {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", {"2", "2", "2", "1"}, ""}, + {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OP_AVR_RC, OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts)"}, + {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OP_AVR2, OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OP_AVR2, OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OP_AVR2, OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, + {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OP_AVR2, OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for STD Y+0, Rr"}, + {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OP_AVR2, OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OP_AVR2, OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, + {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OP_AVR2nRC, OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, + {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OP_AVR1, OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for STD Z+0, Rr"}, + {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OP_AVR1, OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OP_AVR1, OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", {"2", "2", "1", "1"}, ""}, + {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OP_AVR2nRC, OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, + {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OP_AVR1nRC, OPCODE_lpm_1, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", {"3", "3", "3", "n/a"}, ""}, + {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OP_AVR25, OPCODE_lpm_2, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", {"3", "3", "3", "n/a"}, ""}, + {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OP_AVR25, OPCODE_lpm_3, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, + {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OP_AVR_L, OPCODE_elpm_1, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", {"3", "3", "3", "n/a"}, ""}, + {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OP_AVR_L, OPCODE_elpm_2, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", {"3", "3", "3", "n/a"}, ""}, + {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OP_AVR_L, OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, + {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OP_AVR25, OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", {"-", "-", "-", "-"}, ""}, + {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OP_AVR_XTM, OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", {"n/a", "-", "-", "n/a"}, ""}, + {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", {"1", "1", "1", "1"}, ""}, + {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", {"2", "2", "2", "3"}, ""}, + {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions - {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADD Rd, Rd"}, - {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OP_AVR1, OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADC Rd, Rd"}, - {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OP_AVR1, OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OP_AVR1, OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OP_AVR1, OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", {"1", "1", "1", "1"}, ""}, - {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OP_AVR1, OPCODE_bset, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", {"1", "1", "1", "1"}, ""}, - {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OP_AVR1, OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, - {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OP_AVR1, OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", {"2", "1", "1", "1"}, ""}, - {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OP_AVR1, OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", {"2", "1", "1", "1"}, ""}, - {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OP_AVR1, OPCODE_bst, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", {"1", "1", "1", "1"}, ""}, - {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OP_AVR1, OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, - {0xffff, 0x9408, 1, "1001 0100 0000 1000", OP_AVR1, OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", {"1", "1", "1", "1"}, "alias for BSET 0"}, - {0xffff, 0x9488, 1, "1001 0100 1000 1000", OP_AVR1, OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", {"1", "1", "1", "1"}, "alias for BCLR 0"}, - {0xffff, 0x9428, 1, "1001 0100 0010 1000", OP_AVR1, OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", {"1", "1", "1", "1"}, "alias for BSET 2"}, - {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OP_AVR1, OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", {"1", "1", "1", "1"}, "alias for BCLR 2"}, - {0xffff, 0x9418, 1, "1001 0100 0001 1000", OP_AVR1, OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", {"1", "1", "1", "1"}, "alias for BSET 1"}, - {0xffff, 0x9498, 1, "1001 0100 1001 1000", OP_AVR1, OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", {"1", "1", "1", "1"}, "alias for BCLR 1"}, - {0xffff, 0x9478, 1, "1001 0100 0111 1000", OP_AVR1, OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", {"1", "1", "1", "1"}, "alias for BSET 7"}, - {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OP_AVR1, OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", {"1", "1", "1", "1"}, "alias for BCLR 7"}, - {0xffff, 0x9448, 1, "1001 0100 0100 1000", OP_AVR1, OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", {"1", "1", "1", "1"}, "alias for BSET 4"}, - {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OP_AVR1, OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", {"1", "1", "1", "1"}, "alias for BCLR 4"}, - {0xffff, 0x9438, 1, "1001 0100 0011 1000", OP_AVR1, OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", {"1", "1", "1", "1"}, "alias for BSET 3"}, - {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OP_AVR1, OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", {"1", "1", "1", "1"}, "alias for BCLR 3"}, - {0xffff, 0x9468, 1, "1001 0100 0110 1000", OP_AVR1, OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", {"1", "1", "1", "1"}, "alias for BSET 6"}, - {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OP_AVR1, OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", {"1", "1", "1", "1"}, "alias for BCLR 6"}, - {0xffff, 0x9458, 1, "1001 0100 0101 1000", OP_AVR1, OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", {"1", "1", "1", "1"}, "alias for BSET 5"}, - {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OP_AVR1, OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", {"1", "1", "1", "1"}, "alias for BCLR 5"}, + {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADD Rd, Rd"}, + {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OP_AVR1, OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, + {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADC Rd, Rd"}, + {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OP_AVR1, OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OP_AVR1, OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OP_AVR1, OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", {"1", "1", "1", "1"}, ""}, + {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OP_AVR1, OPCODE_bset, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", {"1", "1", "1", "1"}, ""}, + {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OP_AVR1, OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, + {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OP_AVR1, OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", {"2", "1", "1", "1"}, ""}, + {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OP_AVR1, OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", {"2", "1", "1", "1"}, ""}, + {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OP_AVR1, OPCODE_bst, "bst", "Rd, b", "Bit Store from Register to T", "T <-- Rd(b)", "T", {"1", "1", "1", "1"}, ""}, + {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OP_AVR1, OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, + {0xffff, 0x9408, 1, "1001 0100 0000 1000", OP_AVR1, OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", {"1", "1", "1", "1"}, "alias for BSET 0"}, + {0xffff, 0x9488, 1, "1001 0100 1000 1000", OP_AVR1, OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", {"1", "1", "1", "1"}, "alias for BCLR 0"}, + {0xffff, 0x9428, 1, "1001 0100 0010 1000", OP_AVR1, OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", {"1", "1", "1", "1"}, "alias for BSET 2"}, + {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OP_AVR1, OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", {"1", "1", "1", "1"}, "alias for BCLR 2"}, + {0xffff, 0x9418, 1, "1001 0100 0001 1000", OP_AVR1, OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", {"1", "1", "1", "1"}, "alias for BSET 1"}, + {0xffff, 0x9498, 1, "1001 0100 1001 1000", OP_AVR1, OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", {"1", "1", "1", "1"}, "alias for BCLR 1"}, + {0xffff, 0x9478, 1, "1001 0100 0111 1000", OP_AVR1, OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", {"1", "1", "1", "1"}, "alias for BSET 7"}, + {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OP_AVR1, OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", {"1", "1", "1", "1"}, "alias for BCLR 7"}, + {0xffff, 0x9448, 1, "1001 0100 0100 1000", OP_AVR1, OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", {"1", "1", "1", "1"}, "alias for BSET 4"}, + {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OP_AVR1, OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", {"1", "1", "1", "1"}, "alias for BCLR 4"}, + {0xffff, 0x9438, 1, "1001 0100 0011 1000", OP_AVR1, OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", {"1", "1", "1", "1"}, "alias for BSET 3"}, + {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OP_AVR1, OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", {"1", "1", "1", "1"}, "alias for BCLR 3"}, + {0xffff, 0x9468, 1, "1001 0100 0110 1000", OP_AVR1, OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", {"1", "1", "1", "1"}, "alias for BSET 6"}, + {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OP_AVR1, OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", {"1", "1", "1", "1"}, "alias for BCLR 6"}, + {0xffff, 0x9458, 1, "1001 0100 0101 1000", OP_AVR1, OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", {"1", "1", "1", "1"}, "alias for BSET 5"}, + {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OP_AVR1, OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", {"1", "1", "1", "1"}, "alias for BCLR 5"}, // MCU Control Instructions - {0xffff, 0x9598, 1, "1001 0101 1001 1000", OP_AVR1, OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", {"-", "-", "-", "-"}, "not available on all parts"}, - {0xffff, 0x0000, 1, "0000 0000 0000 0000", OP_AVR1, OPCODE_nop, "nop", "-", "No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xffff, 0x9588, 1, "1001 0101 1000 1000", OP_AVR1, OPCODE_sleep, "sleep", "-", "Sleep", "(cf documentation)", "None", {"-", "-", "-", "-"}, ""}, - {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OP_AVR1, OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", {"1", "1", "1", "1"}, ""}, + {0xffff, 0x9598, 1, "1001 0101 1001 1000", OP_AVR1, OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", {"-", "-", "-", "-"}, "not available on all parts"}, + {0xffff, 0x0000, 1, "0000 0000 0000 0000", OP_AVR1, OPCODE_nop, "nop", "-", "No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xffff, 0x9588, 1, "1001 0101 1000 1000", OP_AVR1, OPCODE_sleep, "sleep", "-", "Sleep", "(cf documentation)", "None", {"-", "-", "-", "-"}, ""}, + {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OP_AVR1, OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", {"1", "1", "1", "1"}, ""}, // Unallocated codes - {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OP_AVR1, OPCODE_x_nop_1, "nop", "", "", "", "", {"", "", "", ""}, "xxxx xxxx != 0000 0000"}, - {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OP_AVR1, OPCODE_x_nop_2, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OP_AVR1, OPCODE_x_nop_3, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OP_AVR1, OPCODE_x_nop_4, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OP_AVR1, OPCODE_x_nop_5, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR1, OPCODE_x_nop_6, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR1, OPCODE_x_nop_7, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR2, OPCODE_x_icall, "icall", "", "", "", "", {"", "", "", ""}, "xxx != 000"}, - {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_XL, OPCODE_x_eicall, "eicall", "", "", "", "", {"", "", "", ""}, "xxx != 000"}, - {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR1, OPCODE_x_ret, "ret", "", "", "", "", {"", "", "", ""}, "xx != 00"}, - {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR1, OPCODE_x_reti, "reti", "", "", "", "", {"", "", "", ""}, "xx != 00"}, - {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR1, OPCODE_x_nop_8, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR1, OPCODE_x_nop_9, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR1, OPCODE_x_nop_a, "nop", "", "", "", "", {"", "", "", ""}, ""}, - {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR2, OPCODE_x_ijmp, "ijmp", "", "", "", "", {"", "", "", ""}, "xxx != 000"}, - {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_XL, OPCODE_x_eijmp, "eijmp", "", "", "", "", {"", "", "", ""}, "xxx != 000"}, - {0xfe08, 0xf808, 1, "1111 100x xxxx 1xxx", OP_AVR1, OPCODE_x_bld, "bld", "Rd, b", "", "", "", {"", "", "", ""}, ""}, - {0xfe08, 0xfa08, 1, "1111 101x xxxx 1xxx", OP_AVR1, OPCODE_x_bst, "bst", "Rd, b", "", "", "", {"", "", "", ""}, ""}, - {0xfe08, 0xfc08, 1, "1111 110x xxxx 1xxx", OP_AVR1, OPCODE_x_sbrc, "sbrc", "Rr, b", "", "", "", {"", "", "", ""}, ""}, - {0xfe08, 0xfe08, 1, "1111 111x xxxx 1xxx", OP_AVR1, OPCODE_x_sbrs, "sbrs", "Rr, b", "", "", "", {"", "", "", ""}, ""}, + {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OP_AVR1, OPCODE_x_nop_1, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, + {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OP_AVR1, OPCODE_x_nop_2, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OP_AVR1, OPCODE_x_nop_3, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OP_AVR1, OPCODE_x_nop_4, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OP_AVR1, OPCODE_x_nop_5, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR1, OPCODE_x_nop_6, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR1, OPCODE_x_nop_7, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR2, OPCODE_x_icall, "x_icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, + {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_XL, OPCODE_x_eicall, "x_eicall", "EIND:Z", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, "xxx != 000"}, + {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR1, OPCODE_x_ret, "x_ret", "-", "alt Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, + {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR1, OPCODE_x_reti, "x_reti", "-", "alt Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, + {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR1, OPCODE_x_nop_8, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR1, OPCODE_x_nop_9, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR1, OPCODE_x_nop_a, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR2, OPCODE_x_ijmp, "x_ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, "xxx != 000"}, + {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_XL, OPCODE_x_eijmp, "x_eijmp", "EIND:Z", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, "xxx != 000"}, + {0xfe08, 0xf808, 1, "1111 100d dddd 1bbb", OP_AVR1, OPCODE_x_bld, "x_bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, + {0xfe08, 0xfa08, 1, "1111 101d dddd 1bbb", OP_AVR1, OPCODE_x_bst, "x_bst", "Rd, b", "alt Bit Store from Register to T", "T <-- Rd(b)", "T", {"1", "1", "1", "1"}, ""}, + {0xfe08, 0xfc08, 1, "1111 110r rrrr 1bbb", OP_AVR1, OPCODE_x_sbrc, "x_sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xfe08, 0xfe08, 1, "1111 111r rrrr 1bbb", OP_AVR1, OPCODE_x_sbrs, "x_sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, }; From b100868fd64a2f3a01764b72005bef35c855bf78 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 14:13:47 +0100 Subject: [PATCH 301/422] Reduce code footprint of disasm.c --- src/disasm.c | 80 ++++++---------------------------------------------- 1 file changed, 8 insertions(+), 72 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index c41986ad..57951c83 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -41,46 +41,8 @@ #include "disasm_jumpcall.h" #include "disasm_tagfile.h" -/**** -void Display_Registers() { - int i; - printf("Register dump:\n"); - for(i = 0; i < 256; i++) { - if(cx->dis_regs[i] != 0) { - printf("Registers[%3d] '%c': %d = 0x%x\n", i, i, cx->dis_regs[i], cx->dis_regs[i]); - } - } - printf("End of register dump.\n"); -} -****/ - -int Compare_Opcode(const char *Bitstream, const char *Bitmask) { - size_t i; - char Bit; - - for(i = 0; i < strlen(Bitmask); i++) { - if((Bitmask[i] != 'x') && (Bitmask[i] != '1') && (Bitmask[i] != '0')) { - fprintf(stderr, "Invalid Bitmask!\n"); - return 0; - } - - if(Bitmask[i] == 'x') - continue; // Ignore character - // Retrieve the i-th Bit of Bitstream - Bit = (Bitstream[i / 8] >> (7 - (i % 8))) & 1; - - // printf("Bit %d is %d [should be %c]\n", i, Bit, Bitmask[i]); - if((Bitmask[i] == '1') && (Bit == 1)) - continue; - if((Bitmask[i] == '0') && (Bit == 0)) - continue; - return 0; // No match - } - return 1; // Match -} - -void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char *New_Opcode_String, AVR_opcode mnemo) { +static void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char *New_Opcode_String, AVR_opcode mnemo) { // Only register opcode if the part has it if(avr_opcodes[mnemo].avrlevel & cx->dis_opts.AVR_Level) { cx->dis_op[cx->dis_n_ops].Opcode_String = mmt_strdup(New_Opcode_String); @@ -90,7 +52,7 @@ void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char } } -int Get_Bitmask_Length(const char *Bitmask) { +static int Get_Bitmask_Length(const char *Bitmask) { int Length = 0; size_t i; @@ -101,14 +63,14 @@ int Get_Bitmask_Length(const char *Bitmask) { return Length; } -void Clear_Registers() { +static void Clear_Registers() { int i; for(i = 0; i < 256; i++) cx->dis_regs[i] = 0; } -char Get_From_Bitmask(const char *Bitmask, int Byte, int Bit) { +static char Get_From_Bitmask(const char *Bitmask, int Byte, int Bit) { size_t i; int Cnt = 0; int GetBit; @@ -124,26 +86,7 @@ char Get_From_Bitmask(const char *Bitmask, int Byte, int Bit) { return '?'; } -void Display_Binary(const char *Bitstream, int Count) { - int i, j; - - for(i = 0; i < Count; i++) { - for(j = 7; j >= 0; j--) { - if((Bitstream[i] & (1 << j)) != 0) - printf("1"); - else - printf("0"); - if(j == 4) - printf(" "); - } - printf(" "); - if((((i + 1) % 2) == 0) && (i != 0)) - printf(" "); - } - printf("\n"); -} - -int Match_Opcode(const char *Bitmask, const char *Bitstream) { +static int Match_Opcode(const char *Bitmask, const char *Bitstream) { int i; int Length; int Byte_Mask, Bit_Mask; @@ -193,7 +136,7 @@ int Match_Opcode(const char *Bitmask, const char *Bitstream) { return 1; } -int Get_Next_Opcode(const char *Bitstream) { +static int Get_Next_Opcode(const char *Bitstream) { int i; for(i = 0; i < cx->dis_n_ops; i++) { @@ -291,16 +234,9 @@ void Disassemble(const char *Bitstream, int Read, int addr) { Pos += 2; } } - } -void Display_Opcodes() { - printf("%d opcodes registered:\n", cx->dis_n_ops); - for(int i = 0; i < cx->dis_n_ops; i++) - printf("%3d: '%-80s' -> %p\n", i, cx->dis_op[i].Opcode_String, (void *) cx->dis_op[i].Callback); -} - -int Get_Specifity(const char *Opcode) { +static int Get_Specifity(const char *Opcode) { size_t i; int Specifity = 0; @@ -311,7 +247,7 @@ int Get_Specifity(const char *Opcode) { return Specifity; } -int Comparison(const void *Element1, const void *Element2) { +static int Comparison(const void *Element1, const void *Element2) { Disasm_opcode *OC1, *OC2; int SP1, SP2; From be8b49b112cc9f4ec56f07c7d2504980f08f47fc Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 14:41:06 +0100 Subject: [PATCH 302/422] Make sbr implicit through ori --- src/avr_opcodes.c | 2 +- src/disasm.c | 3 ++- src/disasm_callbacks_assembly.c | 8 ++------ src/disasm_callbacks_assembly.h | 1 - 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index e8ffa350..66f207cd 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -43,7 +43,7 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for AND Rd, Rd"}, {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for EOR Rd, Rd"}, - {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for LDI Rd, 0xFF"}, + {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for LDI Rd, 0xFF; d = 16...31"}, {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", {"2", "2", "2", "n/a"}, ""}, {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..31"}, {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..23"}, diff --git a/src/disasm.c b/src/disasm.c index 57951c83..660fa44d 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -337,6 +337,7 @@ int disasm(const char *Bitstream, int Read, int addr) { Register_Opcode(bst_Callback, "1111 101d dddd 0bbb", OPCODE_bst); Register_Opcode(call_Callback, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call); Register_Opcode(cbi_Callback, "1001 1000 AAAA Abbb", OPCODE_cbi); + // Register_Opcode(cbr_Callback, "0111 KKKK dddd KKKK", OPCODE_cbr); // Implied by (a function of) andi Register_Opcode(clc_Callback, "1001 0100 1000 1000", OPCODE_clc); Register_Opcode(clh_Callback, "1001 0100 1101 1000", OPCODE_clh); Register_Opcode(cli_Callback, "1001 0100 1111 1000", OPCODE_cli); @@ -408,7 +409,7 @@ int disasm(const char *Bitstream, int Read, int addr) { Register_Opcode(sbic_Callback, "1001 1001 AAAA Abbb", OPCODE_sbic); Register_Opcode(sbis_Callback, "1001 1011 AAAA Abbb", OPCODE_sbis); Register_Opcode(sbiw_Callback, "1001 0111 KKdd KKKK", OPCODE_sbiw); - Register_Opcode(sbr_Callback, "0110 KKKK dddd KKKK", OPCODE_sbr); + // Register_Opcode(sbr_Callback, "0110 KKKK dddd KKKK", OPCODE_sbr); // Implied by ori Register_Opcode(sbrc_Callback, "1111 110r rrrr 0bbb", OPCODE_sbrc); Register_Opcode(sbrs_Callback, "1111 111r rrrr 0bbb", OPCODE_sbrs); Register_Opcode(sec_Callback, "1001 0100 0000 1000", OPCODE_sec); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 5434667d..7b57cf2f 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -595,7 +595,7 @@ CALLBACK(or_Callback) { } CALLBACK(ori_Callback) { - Operation_Rd16_K(mnemo); + Operation_Rd16_K(BitCount(RK) < 4? mnemo: OPCODE_sbr); } CALLBACK(out_Callback) { @@ -676,7 +676,7 @@ CALLBACK(rjmp_Callback) { if(Target >= 0) { snprintf(cx->dis_comment, 255, "0x%02x", Target); } else { - snprintf(cx->dis_comment, 255, "-0x%02x - Illegal jump position -- specify flash size!", -Target); + snprintf(cx->dis_comment, 255, "-0x%02x - Illegal jump position?", -Target); } } else { snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, Get_Label_Name(Target, NULL)); @@ -716,10 +716,6 @@ CALLBACK(sbiw_Callback) { snprintf(cx->dis_comment, 255, "%d", RK); } -CALLBACK(sbr_Callback) { - Operation_Rd16_K(mnemo); -} - CALLBACK(sbrc_Callback) { Operation_r_b(mnemo); } diff --git a/src/disasm_callbacks_assembly.h b/src/disasm_callbacks_assembly.h index 25ae4ba9..6d682053 100644 --- a/src/disasm_callbacks_assembly.h +++ b/src/disasm_callbacks_assembly.h @@ -126,7 +126,6 @@ void sbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sbic_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sbis_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sbiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sbrc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sbrs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From 216b5e6ea9fbf4264494e74f05bb52b69a26a207 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 15:16:13 +0100 Subject: [PATCH 303/422] Consolidate initialisation and header files --- src/CMakeLists.txt | 3 - src/Makefile.am | 3 - src/disasm.c | 14 ++- src/disasm_callbacks_assembly.c | 4 - src/disasm_callbacks_assembly.h | 157 -------------------------------- src/disasm_jumpcall.c | 3 - src/disasm_jumpcall.h | 35 ------- src/disasm_private.h | 157 ++++++++++++++++++++++++++++++++ src/disasm_tagfile.c | 20 +--- src/disasm_tagfile.h | 42 --------- src/libavrdude.h | 2 +- src/term.c | 6 +- 12 files changed, 169 insertions(+), 277 deletions(-) delete mode 100644 src/disasm_callbacks_assembly.h delete mode 100644 src/disasm_jumpcall.h delete mode 100644 src/disasm_tagfile.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c8324ac2..82cddc05 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -184,11 +184,8 @@ add_library(libavrdude disasm.c disasm_private.h disasm_callbacks_assembly.c - disasm_callbacks_assembly.h disasm_jumpcall.c - disasm_jumpcall.h disasm_tagfile.c - disasm_tagfile.h dfu.c dfu.h dryrun.c diff --git a/src/Makefile.am b/src/Makefile.am index 7ee7d71d..1ea58c2d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,11 +122,8 @@ libavrdude_a_SOURCES = \ disasm.c \ disasm_private.h \ disasm_callbacks_assembly.c \ - disasm_callbacks_assembly.h \ disasm_jumpcall.c \ - disasm_jumpcall.h \ disasm_tagfile.c \ - disasm_tagfile.h \ dfu.c \ dfu.h \ dryrun.c \ diff --git a/src/disasm.c b/src/disasm.c index 660fa44d..2232109c 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -37,10 +37,6 @@ #include "libavrdude.h" #include "disasm_private.h" -#include "disasm_callbacks_assembly.h" -#include "disasm_jumpcall.h" -#include "disasm_tagfile.h" - static void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char *New_Opcode_String, AVR_opcode mnemo) { // Only register opcode if the part has it @@ -147,7 +143,7 @@ static int Get_Next_Opcode(const char *Bitstream) { return -1; } -void Disassemble(const char *Bitstream, int Read, int addr) { +int disasm(const char *Bitstream, int Read, int addr) { int Pos; int Opcode; int i; @@ -234,6 +230,8 @@ void Disassemble(const char *Bitstream, int Read, int addr) { Pos += 2; } } + + return 0; } static int Get_Specifity(const char *Opcode) { @@ -262,10 +260,10 @@ static int Comparison(const void *Element1, const void *Element2) { return -1; } -int disasm(const char *Bitstream, int Read, int addr) { +int disasm_init(const AVRPART *p) { if(cx->dis_opts.Tagfile) if(!Read_Tagfile(cx->dis_opts.Tagfile)) - return 0; + return -1; /* * 8 untreated opcodes and 20 "unofficial" ones @@ -449,6 +447,6 @@ int disasm(const char *Bitstream, int Read, int addr) { return -1; } - Disassemble(Bitstream, Read, addr); + disasm_init_regfile(p); return 0; } diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 7b57cf2f..8899c9f1 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -29,11 +29,7 @@ #include #include "libavrdude.h" - #include "disasm_private.h" -#include "disasm_callbacks_assembly.h" -#include "disasm_jumpcall.h" -#include "disasm_tagfile.h" // Return the number of bits set in Number static unsigned BitCount(unsigned n) { diff --git a/src/disasm_callbacks_assembly.h b/src/disasm_callbacks_assembly.h deleted file mode 100644 index 6d682053..00000000 --- a/src/disasm_callbacks_assembly.h +++ /dev/null @@ -1,157 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -void adc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void add_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void adiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void and_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void andi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void asr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void bclr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void bld_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brbc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brbs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brcc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brcs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void break_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void breq_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brge_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brhc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brhs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brid_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brie_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brlo_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brlt_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brmi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brne_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brpl_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brsh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brtc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brvc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brvs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void bset_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void bst_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void call_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cli_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cln_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clt_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clv_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clz_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void com_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpse_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void dec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void eicall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void eijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void elpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void elpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void elpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void eor_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void fmul_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void fmuls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void fmulsu_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void icall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void in_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void inc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void jmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldy1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldy2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldy3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldy4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldz1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lds_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lsr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void mov_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void movw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void mul_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void muls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void mulsu_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void neg_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void nop_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void or_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ori_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void out_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void pop_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void push_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void rcall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ret_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void reti_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void rjmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ror_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbci_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbic_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbis_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbrc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbrs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void seh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sei_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sen_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ser_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ses_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void set_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sev_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sez_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sleep_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void spm_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sty1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sty2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sty3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sty4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stz1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sub_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void subi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void swap_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void wdr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 3058a66c..06a9c026 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -31,10 +31,7 @@ #include "avrdude.h" #include "libavrdude.h" - #include "disasm_private.h" -#include "disasm_tagfile.h" -#include "disasm_jumpcall.h" void Display_JumpCalls() { int i; diff --git a/src/disasm_jumpcall.h b/src/disasm_jumpcall.h deleted file mode 100644 index 1e7a3b4c..00000000 --- a/src/disasm_jumpcall.h +++ /dev/null @@ -1,35 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -void Display_JumpCalls(); -void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall); -int JC_Comparison(const void *Element1, const void *Element2); -void Sort_JumpCalls(); -void Enumerate_Labels(); -const char *Get_Label_Name(int Destination, char **LabelComment); -void Print_JumpCalls(int Position); -int FixTargetAddress(int Address); diff --git a/src/disasm_private.h b/src/disasm_private.h index 2889b4e5..e989fa55 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -36,3 +36,160 @@ #define CALLBACK(name) void name(const char *Bitstream, int Position, AVR_opcode mnemo) +#define TYPE_BYTE 1 +#define TYPE_WORD 2 +#define TYPE_ASTRING 3 +#define TYPE_STRING 4 + +void disasm_init_regfile(const AVRPART *p); +int Read_Tagfile(const char *Filename); +int Tagfile_FindLabelAddress(int Address); +char *Tagfile_GetLabel(int TagIndex); +char *Tagfile_GetLabelComment(int TagIndex); +int Tagfile_FindPGMAddress(int Address); +const char *Tagfile_Resolve_Mem_Address(int Address); +int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); + +const char *Resolve_IO_Register(int Number); +void Emit_Used_IO_Registers(); + +void Display_JumpCalls(); +void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall); +int JC_Comparison(const void *Element1, const void *Element2); +void Sort_JumpCalls(); +void Enumerate_Labels(); +const char *Get_Label_Name(int Destination, char **LabelComment); +void Print_JumpCalls(int Position); +int FixTargetAddress(int Address); + +void adc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void add_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void adiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void and_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void andi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void asr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void bclr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void bld_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brbc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brbs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brcc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brcs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void break_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void breq_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brge_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brhc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brhs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brid_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brie_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brlo_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brlt_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brmi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brne_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brpl_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brsh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brtc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brvc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void brvs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void bset_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void bst_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void call_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cli_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cln_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clt_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clv_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void clz_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void com_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void cpse_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void dec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void eicall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void eijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void elpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void elpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void elpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void eor_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void fmul_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void fmuls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void fmulsu_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void icall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void in_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void inc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void jmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldy1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldy2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldy3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldy4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldz1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ldi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lds_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lsr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void mov_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void movw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void mul_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void muls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void mulsu_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void neg_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void nop_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void or_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ori_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void out_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void pop_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void push_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void rcall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ret_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void reti_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void rjmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ror_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbci_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbic_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbis_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbrc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sbrs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void seh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sei_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sen_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ser_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void ses_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void set_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sev_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sez_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sleep_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void spm_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sty1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sty2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sty3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sty4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stz1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void stz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sub_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void subi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void swap_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void wdr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); + diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index eed19e6f..d50c3e2b 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -33,22 +33,7 @@ #include "avrdude.h" #include "libavrdude.h" - #include "disasm_private.h" -#include "disasm_tagfile.h" - -/* -static void Display_Tagfile() { - int i; - printf("%d code labels:\n", cx->dis_CodeLabelN); - for(i = 0; i < cx->dis_CodeLabelN; i++) - printf("%d: 0x%x = %s\n", i, cx->dis_CodeLabels[i].Address, cx->dis_CodeLabels[i].Text); - - printf("%d PGM labels:\n", cx->dis_PGMLabelN); - for(i = 0; i < cx->dis_PGMLabelN; i++) - printf("%d: 0x%x = %d * %d\n", i, cx->dis_PGMLabels[i].Address, cx->dis_PGMLabels[i].Count, cx->dis_PGMLabels[i].Type); -} -*/ static int LineError(const char *Token, const char *Message, int LineNo) { if((Token == NULL) || (strlen(Token) == 0)) { @@ -241,9 +226,8 @@ static void Tagfile_SortLabels() { } int Read_Tagfile(const char *Filename) { - FILE *f; + FILE *f = fopen(Filename, "r"); - f = fopen(Filename, "r"); if(!f) { fprintf(stderr, "Error opening tagfile '%s': %s\n", Filename, strerror(errno)); return 0; @@ -462,7 +446,7 @@ static char *regname(const char *reg, int suf) { } // Initialise cx->dis_IORegisters and cx->dis_MemLabels from part register file -void initRegisters(const AVRPART *p) { +void disasm_init_regfile(const AVRPART *p) { int nr = 0, nio = 0, offset = 0; const Register_file *rf = avr_locate_register_file(p, &nr); diff --git a/src/disasm_tagfile.h b/src/disasm_tagfile.h deleted file mode 100644 index ddac58d1..00000000 --- a/src/disasm_tagfile.h +++ /dev/null @@ -1,42 +0,0 @@ - -/* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer - - This file is part of avrdisas. - - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ - -#define TYPE_BYTE 1 -#define TYPE_WORD 2 -#define TYPE_ASTRING 3 -#define TYPE_STRING 4 - -int Read_Tagfile(const char *Filename); -int Tagfile_FindLabelAddress(int Address); -char *Tagfile_GetLabel(int TagIndex); -char *Tagfile_GetLabelComment(int TagIndex); -int Tagfile_FindPGMAddress(int Address); -const char *Tagfile_Resolve_Mem_Address(int Address); -int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); - -const char *Resolve_IO_Register(int Number); -void Emit_Used_IO_Registers(); diff --git a/src/libavrdude.h b/src/libavrdude.h index 1c2b8f74..971acbdb 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1709,8 +1709,8 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); +int disasm_init(const AVRPART *p); int disasm(const char *buf, int len, int addr); -void initRegisters(const AVRPART *p); #ifdef __cplusplus } diff --git a/src/term.c b/src/term.c index 94682204..e34f4b66 100644 --- a/src/term.c +++ b/src/term.c @@ -332,7 +332,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, *baddr = 0; if(blen) *blen = 0; - return mmt_malloc(1); + return mmt_malloc(16); } if (len < 0) { pmsg_error("(%s) invalid effective length %d\n", cmd, len); @@ -349,7 +349,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, if (cx->term_rmem[i].len > maxsize) cx->term_rmem[i].len = maxsize; - uint8_t *buf = mmt_malloc(cx->term_rmem[i].len); + uint8_t *buf = mmt_malloc(cx->term_rmem[i].len + 16); // Add safety margin if(argc < 4 && verbose) term_out(">>> %s %s 0x%x 0x%x\n", cmd, cx->term_rmem[i].mem->desc, cx->term_rmem[i].addr, cx->term_rmem[i].len); @@ -477,7 +477,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.FlashSize = mem->size; cx->dis_opts.AVR_Level = get_avr_archlevel(p); cx->dis_opts.cycle_index = get_avr_cycle_index(p); - initRegisters(p); + disasm_init(p); cx->dis_initopts++; } cx->dis_opts.Pass = 1; From a16f4a4f89862f2a5e3d8d929b200be5bde406f3 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 16:31:11 +0100 Subject: [PATCH 304/422] Zap labels before reading tag file --- src/disasm.c | 4 - src/disasm_private.h | 2 - src/disasm_tagfile.c | 222 ++++++++++++++++++++++++------------------- src/libavrdude.h | 1 + src/term.c | 4 + 5 files changed, 131 insertions(+), 102 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 2232109c..2a864eb0 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -261,10 +261,6 @@ static int Comparison(const void *Element1, const void *Element2) { } int disasm_init(const AVRPART *p) { - if(cx->dis_opts.Tagfile) - if(!Read_Tagfile(cx->dis_opts.Tagfile)) - return -1; - /* * 8 untreated opcodes and 20 "unofficial" ones * diff --git a/src/disasm_private.h b/src/disasm_private.h index e989fa55..6e981a49 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -42,14 +42,12 @@ #define TYPE_STRING 4 void disasm_init_regfile(const AVRPART *p); -int Read_Tagfile(const char *Filename); int Tagfile_FindLabelAddress(int Address); char *Tagfile_GetLabel(int TagIndex); char *Tagfile_GetLabelComment(int TagIndex); int Tagfile_FindPGMAddress(int Address); const char *Tagfile_Resolve_Mem_Address(int Address); int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); - const char *Resolve_IO_Register(int Number); void Emit_Used_IO_Registers(); diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index d50c3e2b..2055ca3a 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -37,37 +37,55 @@ static int LineError(const char *Token, const char *Message, int LineNo) { if((Token == NULL) || (strlen(Token) == 0)) { - fprintf(stderr, "Error: %s in tagfile, line %d.\n", Message, LineNo); + pmsg_error("%s in tagfile, line %d\n", Message, LineNo); return 1; } return 0; } -static int ahtoi(const char *String) { - int Value; - size_t i, l; - - if(strlen(String) < 3) - return atoi(String); - if((String[0] != '0') || (String[1] != 'x')) - return atoi(String); - String += 2; - Value = 0; - l = strlen(String); - for(i = 0; i < l; i++) { - Value *= 16; - if((String[i] >= '0') && (String[i] <= '9')) - Value += String[i] - '0'; - else if((String[i] >= 'a') && (String[i] <= 'f')) - Value += String[i] - 'a' + 10; - else if((String[i] >= 'A') && (String[i] <= 'F')) - Value += String[i] - 'A' + 10; - else - return 0; +static void zap_IORegisters() { + if(cx->dis_IORegisters) { + for(int i = 0; i < cx->dis_IORegisterN; i++) + mmt_free(cx->dis_IORegisters[i].Name); + mmt_free(cx->dis_IORegisters); + cx->dis_IORegisters = NULL; } - return Value; + cx->dis_IORegisterN = 0; } +static void zap_CodeLabels() { + if(cx->dis_CodeLabels) { + for(int i = 0; i < cx->dis_CodeLabelN; i++) { + mmt_free(cx->dis_CodeLabels[i].Comment); + mmt_free(cx->dis_CodeLabels[i].Text); + } + mmt_free(cx->dis_CodeLabels); + cx->dis_CodeLabels = NULL; + } + cx->dis_CodeLabelN = 0; +} + +static void zap_PGMLabels() { + if(cx->dis_PGMLabels) { + for(int i = 0; i < cx->dis_PGMLabelN; i++) + mmt_free(cx->dis_PGMLabels[i].Comment); + mmt_free(cx->dis_PGMLabels); + cx->dis_PGMLabels = NULL; + } + cx->dis_PGMLabelN = 0; +} + +static void zap_MemLabels() { + if(cx->dis_MemLabels) { + for(int i = 0; i < cx->dis_MemLabelN; i++) + mmt_free(cx->dis_MemLabels[i].Comment); + mmt_free(cx->dis_MemLabels); + cx->dis_MemLabels = NULL; + } + cx->dis_MemLabelN = 0; +} + + static void Add_LabelTag(int Address, const char *LabelText, const char *LabelComment) { cx->dis_CodeLabelN++; @@ -97,47 +115,49 @@ static void Add_Mem_Tag(int Address, char Type, unsigned int Count, const char * cx->dis_MemLabels[cx->dis_MemLabelN - 1].Comment = Comment? mmt_strdup(Comment): NULL; } -static void Tagfile_Readline(char *Line, int LineNo) { - char *Token; - int Address; - char Type, Subtype; - int Count; +static int Tagfile_Readline(char *Line, int LineNo) { + char *Token, Type, Subtype; + int Address, Count; + const char *errptr; - if(Line[0] == '#') - return; - if(strlen(Line) <= 1) - return; + if(Line[0] == '#' || strlen(Line) <= 1) + return 0; - Token = strtok(Line, "\t\n"); + Token = strtok(Line, " \t\n"); if(LineError(Token, "nonempty line", LineNo)) - return; + return -1; + // Token now holds an address, determine if hex or dec - Address = ahtoi(Token); + Address = str_int(Token, STR_INT32, &errptr); + if(errptr) { + pmsg_error("address %s: %s\n", Token, errptr); + return -1; + } - Token = strtok(NULL, "\t\n"); + Token = strtok(NULL, " \t\n"); if(LineError(Token, "no second argument", LineNo)) - return; + return -1; if(strlen(Token) != 1) { LineError(NULL, "second argument too long", LineNo); - return; + return -1; } Type = Token[0]; - Token = strtok(NULL, "\t\n"); + Token = strtok(NULL, " \t\n"); if(LineError(Token, "no third argument", LineNo)) - return; + return -1; if(Type == 'L') { char *LabelName = Token; - Token = strtok(NULL, "\t\n"); + Token = strtok(NULL, " \t\n"); Add_LabelTag(Address, LabelName, Token); - return; + return 0; } if(LineError(Token, "no fourth argument", LineNo)) - return; + return -1; Subtype = Token[0]; // Either B(yte), W(ord), A(utoterminated string) or S(tring) @@ -159,28 +179,36 @@ static void Tagfile_Readline(char *Line, int LineNo) { } if(!Subtype) { LineError(NULL, "invalid type (expected one of L, B, W, A or S)", LineNo); - return; + return -1; } if((Type == 'M') && ((Subtype != TYPE_BYTE) && (Subtype != TYPE_WORD))) { LineError(NULL, "memory labels can only be of type B or W", LineNo); - return; + return -1; + } + + Token = strtok(NULL, " \t\n"); + Count = str_int(Token, STR_INT32, &errptr); + if(errptr) { + pmsg_error("count %s: %s\n", Token, errptr); + return -1; } - Token = strtok(NULL, "\t\n"); - Count = ahtoi(Token); if(Count < 1) { LineError(NULL, "invalid count given", LineNo); - return; + return -1; } - Token = strtok(NULL, "\t\n"); + Token = strtok(NULL, " \t\n"); if(Type == 'P') { Add_PGM_Tag(Address, Subtype, Count, Token); } else if(Type == 'M') { Add_Mem_Tag(Address, Subtype, Count, Token); } else { - fprintf(stderr, "Invalid tag type '%c'.\n", Type); + pmsg_error("invalid tag type %c\n", Type); + return -1; } + + return 0; } static int CodeLabelSort(const void *A, const void *B) { @@ -225,27 +253,37 @@ static void Tagfile_SortLabels() { qsort(cx->dis_MemLabels, cx->dis_MemLabelN, sizeof(Disasm_MemLabel), MemLabelSort); } -int Read_Tagfile(const char *Filename) { - FILE *f = fopen(Filename, "r"); +int disasm_init_tagfile(const AVRPART *p, const char *Filename) { + FILE *inf = fopen(Filename, "r"); + int LineNo = 1; + const char *errstr; - if(!f) { - fprintf(stderr, "Error opening tagfile '%s': %s\n", Filename, strerror(errno)); - return 0; + if(!inf) { + pmsg_ext_error("cannot open tagfile %s: %s\n", Filename, strerror(errno)); + return -1; } - { - char Buffer[256]; - int LineNo = 1; + zap_CodeLabels(); + zap_PGMLabels(); + zap_MemLabels(); + disasm_init_regfile(p); - while(fgets(Buffer, sizeof(Buffer), f) != NULL) { - Tagfile_Readline(Buffer, LineNo++); - } + for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) + if(Tagfile_Readline(buffer, LineNo++) < 0) + goto error; + + if(errstr) { + pmsg_error("read error in tag file %s: %s\n", Filename, errstr); + goto error; } - fclose(f); - + fclose(inf); Tagfile_SortLabels(); - return 1; + return 0; + +error: + fclose(inf); + return -1; } int Tagfile_FindLabelAddress(int Address) { @@ -302,12 +340,12 @@ const char *Tagfile_Resolve_Mem_Address(int Address) { } static int Tagfile_Process_Byte(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { - printf(".byte 0x%02x\n", Bitstream[Position] & 0xff); + term_out(".byte 0x%02x\n", Bitstream[Position] & 0xff); return 1; } static int Tagfile_Process_Word(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { - printf(".word 0x%02x%02x\n", Bitstream[Position + 1] & 0xff, Bitstream[Position] & 0xff); + term_out(".word 0x%02x%02x\n", Bitstream[Position + 1] & 0xff, Bitstream[Position] & 0xff); return 2; } @@ -316,28 +354,28 @@ static int Tagfile_Process_String(const char *Bitstream, int Position, int offse unsigned char c; unsigned int InString = 0; - printf("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); + term_out("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); i = 0; while((c = Bitstream[Position + i])) { if((c >= 32) && (c <= 127)) { if(!InString) - printf(".ascii \""); - printf("%c", c); + term_out(".ascii \""); + term_out("%c", c); InString = 1; } else { if(InString) - printf("\"\n"); - printf(".byte 0x%02x\n", c); + term_out("\"\n"); + term_out(".byte 0x%02x\n", c); InString = 0; } i++; } if(InString) - printf("\\0\"\n"); + term_out("\\0\"\n"); else - printf(".byte 0x00\n"); + term_out(".byte 0x00\n"); - printf("\n"); + term_out("\n"); return i + 1; } @@ -378,29 +416,29 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { break; } - printf("; Inline PGM data: %d ", cx->dis_PGMLabels[Index].Count); + term_out("; Inline PGM data: %d ", cx->dis_PGMLabels[Index].Count); switch (cx->dis_PGMLabels[Index].Type) { case TYPE_BYTE: - printf("byte"); + term_out("byte"); break; case TYPE_WORD: - printf("word"); + term_out("word"); break; case TYPE_ASTRING: - printf("autoaligned string"); + term_out("autoaligned string"); break; case TYPE_STRING: - printf("string"); + term_out("string"); break; } if(cx->dis_PGMLabels[Index].Count != 1) - printf("s"); - printf(" starting at 0x%x", Position + offset); + term_out("s"); + term_out(" starting at 0x%x", Position + offset); if(cx->dis_PGMLabels[Index].Comment != NULL) { - printf(" (%s)", cx->dis_PGMLabels[Index].Comment); + term_out(" (%s)", cx->dis_PGMLabels[Index].Comment); } - printf("\n"); + term_out("\n"); if((cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].Type == TYPE_STRING)) { if(cx->dis_PGMLabels[Index].Comment != NULL) { @@ -422,12 +460,12 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { if(Bitstream[Position + BytesAdvanced] != 0x00) fprintf(stderr, "Warning in autoalignment: expected zero but got 0x%0x padding. Ignored.\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); - printf(".byte 0x%02x ; String Autoalignment\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); + term_out(".byte 0x%02x ; String Autoalignment\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); BytesAdvanced++; } } - printf("\n"); + term_out("\n"); return BytesAdvanced; } @@ -451,16 +489,8 @@ void disasm_init_regfile(const AVRPART *p) { const Register_file *rf = avr_locate_register_file(p, &nr); if(rf) { - if(cx->dis_IORegisters) { - for(int i = 0; i < cx->dis_IORegisterN; i++) - mmt_free(cx->dis_IORegisters[i].Name); - mmt_free(cx->dis_IORegisters); - } - if(cx->dis_MemLabels) { - for(int i = 0; i < cx->dis_MemLabelN; i++) - mmt_free(cx->dis_MemLabels[i].Comment); - mmt_free(cx->dis_MemLabels); - } + zap_MemLabels(); + zap_IORegisters(); // Count how many entries are needed for(int i = 0; i< nr; i++) @@ -520,5 +550,5 @@ const char *Resolve_IO_Register(int Number) { void Emit_Used_IO_Registers() { for(int i = 0; i < cx->dis_IORegisterN; i++) if(cx->dis_IORegisters[i].Used) - printf(".equ %s, 0x%x\n", cx->dis_IORegisters[i].Name, cx->dis_IORegisters[i].Address); + term_out(".equ %s, 0x%x\n", cx->dis_IORegisters[i].Name, cx->dis_IORegisters[i].Address); } diff --git a/src/libavrdude.h b/src/libavrdude.h index 971acbdb..b501c32a 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1710,6 +1710,7 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); int disasm_init(const AVRPART *p); +int disasm_init_tagfile(const AVRPART *p, const char *file); int disasm(const char *buf, int len, int addr); #ifdef __cplusplus diff --git a/src/term.c b/src/term.c index e34f4b66..d99f7afb 100644 --- a/src/term.c +++ b/src/term.c @@ -482,6 +482,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c } cx->dis_opts.Pass = 1; + for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; if(*(q = argv[++ai]) != '-' || !q[1]) @@ -533,6 +534,9 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c return -1; } + if(cx->dis_opts.Tagfile) + if(disasm_init_tagfile(p, cx->dis_opts.Tagfile) < 0) + return -1; buf = readbuf(pgm, p, argc, argv, &mem, &addr, &len); From 3784b333cde8b005728a51a749961d2f7bb1623e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 17:15:05 +0100 Subject: [PATCH 305/422] Fix jumpcall list for repeated use --- src/disasm.c | 34 +++++++++--------- src/disasm_callbacks_assembly.c | 32 ++++++++--------- src/disasm_jumpcall.c | 61 ++++++++++++++++----------------- src/disasm_private.h | 4 --- src/disasm_tagfile.c | 2 +- src/libavrdude.h | 10 +++--- src/term.c | 13 +++---- 7 files changed, 73 insertions(+), 83 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 2a864eb0..649848c4 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -103,19 +103,19 @@ static int Match_Opcode(const char *Bitmask, const char *Bitstream) { Mask_Val = Get_From_Bitmask(Bitmask, Byte_Mask, Bit_Mask); Stream_Val = (Bitstream[Byte_Stream] >> Bit_Stream) & 0x01; - // printf("Extracting Bit %2d: Maske = (%d, %d) [%c], Stream = (%d, %d) [%d] ", i, Byte_Mask, Bit_Mask, Mask_Val, Byte_Stream, Bit_Stream, Stream_Val); + // term_out("Extracting Bit %2d: Maske = (%d, %d) [%c], Stream = (%d, %d) [%d] ", i, Byte_Mask, Bit_Mask, Mask_Val, Byte_Stream, Bit_Stream, Stream_Val); if((Mask_Val == '0') || (Mask_Val == '1')) { // This Bit is a identification Bit if(Mask_Val == '0') { if(Stream_Val == 1) { - // printf("\nMatch failed.\n") + // term_out("\nMatch failed.\n") return 0; } } else { if(Stream_Val == 0) { - // printf("\nMatch failed.\n") + // term_out("\nMatch failed.\n") return 0; } } @@ -124,10 +124,10 @@ static int Match_Opcode(const char *Bitmask, const char *Bitstream) { cx->dis_regs[(int) Mask_Val] <<= 1; cx->dis_regs[(int) Mask_Val] |= Stream_Val; - // printf("-> %d Stored [%x]", Stream_Val, cx->dis_regs[(int) Mask_Val]); + // term_out("-> %d Stored [%x]", Stream_Val, cx->dis_regs[(int) Mask_Val]); } - // printf("\n"); + // term_out("\n"); } return 1; } @@ -148,7 +148,7 @@ int disasm(const char *Bitstream, int Read, int addr) { int Opcode; int i; - cx->dis_opts.Pass = 1; + cx->dis_pass = 1; Pos = 0; if(cx->dis_opts.Process_Labels || cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC) { @@ -163,7 +163,7 @@ int disasm(const char *Bitstream, int Read, int addr) { } } Enumerate_Labels(); - cx->dis_opts.Pass = 2; + cx->dis_pass = 2; Pos = 0; } @@ -193,39 +193,39 @@ int disasm(const char *Bitstream, int Read, int addr) { } if(cx->dis_opts.Show_Addresses) - printf("%4x: ", Pos + addr); + term_out("%4x: ", Pos + addr); if(cx->dis_opts.Show_Cycles) - printf("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clock[cx->dis_opts.cycle_index]); + term_out("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clock[cx->dis_opts.cycle_index]); if(cx->dis_opts.Show_Opcodes) { // Now display the Opcode for(i = 0; i < (Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8; i++) - printf("%02x ", (unsigned char) (Bitstream[Pos + i])); + term_out("%02x ", (unsigned char) (Bitstream[Pos + i])); - printf(" "); + term_out(" "); // Missing spaces for(i = 0; i < 5 - ((Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8); i++) { - printf(" "); + term_out(" "); } } if(cx->dis_code[0] == 0) { // No code was generated? - printf("; - Not implemented opcode: %d -\n", cx->dis_op[Opcode].mnemo); + term_out("; - Not implemented opcode: %d -\n", cx->dis_op[Opcode].mnemo); } else { if((cx->dis_comment[0] == 0) || (!cx->dis_opts.Show_Comments)) { // No comment - printf("%s\n", cx->dis_code); + term_out("%s\n", cx->dis_code); } else { // Comment available - printf("%-23s ; %s\n", cx->dis_code, cx->dis_comment); + term_out("%-23s ; %s\n", cx->dis_code, cx->dis_comment); } } - printf("%s", cx->dis_after_code); + term_out("%s", cx->dis_after_code); Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; } else { - printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x\n", // @@@ show unoffical opcode what it might do + term_out(".word 0x%02x%02x ; Invalid opcode at 0x%04x\n", // @@@ show unoffical opcode what it might do ((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], Pos + addr); Pos += 2; } diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 8899c9f1..cab65494 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -31,6 +31,21 @@ #include "libavrdude.h" #include "disasm_private.h" + +// Wrap r/jmp around flash where possible +static int FixTargetAddress(int Address) { + int flashsz = cx->dis_opts.FlashSize; + + // Flash size is a power of two: flash wraps round + if(flashsz > 0 && !(flashsz & (flashsz - 1))) { + Address %= flashsz; + if(Address < 0) + Address += flashsz; + } + return Address; +} + + // Return the number of bits set in Number static unsigned BitCount(unsigned n) { unsigned ret; @@ -67,22 +82,6 @@ static void Operation_Rd16_K(AVR_opcode mnemo) { snprintf(cx->dis_comment, 255, "%d", RK); } -/**** -static void Operation_Rd_K(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); - snprintf(cx->dis_comment, 255, "%d", RK); -} - -static void Operation_RdW_K(AVR_opcode mnemo) { - if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 1, Rd, RK); - } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, RK); - } - snprintf(cx->dis_comment, 255, "%d", RK); -} -****/ - static void Operation_RdW_RrW(AVR_opcode mnemo) { if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", avr_opcodes[mnemo].opcode, (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); @@ -662,7 +661,6 @@ CALLBACK(rjmp_Callback) { Target = FixTargetAddress(Position + Offset + 2); Register_JumpCall(Position, Target, mnemo, 0); - if(cx->dis_opts.Process_Labels == 0) { if(Offset > 0) { snprintf(cx->dis_code, 255, "%-7s .+%d", avr_opcodes[mnemo].opcode, Offset); diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 06a9c026..87a404df 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -33,41 +33,38 @@ #include "libavrdude.h" #include "disasm_private.h" -void Display_JumpCalls() { - int i; - printf("%d jumps/calls found:\n", cx->dis_JumpCallN); - for(i = 0; i < cx->dis_JumpCallN; i++) { - printf("%3d: 0x%-4x -> 0x%-4x %s (%d)\n", i, (unsigned int) cx->dis_JumpCalls[i].From, (unsigned int) cx->dis_JumpCalls[i].To, - avr_opcodes[cx->dis_JumpCalls[i].Type].opcode, cx->dis_JumpCalls[i].FunctionCall); +void disasm_zap_JumpCalls() { + if(cx->dis_JumpCalls) { + mmt_free(cx->dis_JumpCalls); + cx->dis_JumpCalls = NULL; } -} - -int FixTargetAddress(int Address) { - int flashsz = cx->dis_opts.FlashSize; - - // Flash size is a power of two: flash wraps round - if(flashsz > 0 && !(flashsz & (flashsz - 1))) { - Address %= flashsz; - if(Address < 0) - Address += flashsz; - } - return Address; + cx->dis_JumpCallN = 0; } void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { - if((cx->dis_opts.Process_Labels == 1) && (cx->dis_opts.Pass == 1)) { + if((cx->dis_opts.Process_Labels == 1) && (cx->dis_pass == 1)) { + Disasm_JumpCall *jc = cx->dis_JumpCalls; + int N = cx->dis_JumpCallN; + + // Already entered this JC? + for(int i = 0; i < N; i++) + if(jc[i].From == From && jc[N].To == To && jc[N].Type == Type && jc[N].FunctionCall == FunctionCall) + return; + + jc = mmt_realloc(jc, sizeof(Disasm_JumpCall) * (N+1)); + jc[N].From = From; + jc[N].To = To; + jc[N].Type = Type; + jc[N].LabelNumber = 0; + jc[N].FunctionCall = FunctionCall; + + cx->dis_JumpCalls = jc; cx->dis_JumpCallN++; - cx->dis_JumpCalls = mmt_realloc(cx->dis_JumpCalls, sizeof(Disasm_JumpCall) * (cx->dis_JumpCallN)); - cx->dis_JumpCalls[cx->dis_JumpCallN - 1].From = From; - cx->dis_JumpCalls[cx->dis_JumpCallN - 1].To = To; - cx->dis_JumpCalls[cx->dis_JumpCallN - 1].Type = Type; - cx->dis_JumpCalls[cx->dis_JumpCallN - 1].LabelNumber = 0; - cx->dis_JumpCalls[cx->dis_JumpCallN - 1].FunctionCall = FunctionCall; } } -int JC_Comparison(const void *Element1, const void *Element2) { +static int JC_Comparison(const void *Element1, const void *Element2) { Disasm_JumpCall *JC1, *JC2; JC1 = (Disasm_JumpCall *) Element1; @@ -79,11 +76,11 @@ int JC_Comparison(const void *Element1, const void *Element2) { return -1; } -void Sort_JumpCalls() { +static void Sort_JumpCalls() { qsort(cx->dis_JumpCalls, cx->dis_JumpCallN, sizeof(Disasm_JumpCall), JC_Comparison); } -void Correct_Label_Types(void) { +static void Correct_Label_Types(void) { int i, j; int LastIdx = 0; int LastDest = cx->dis_JumpCalls[0].To; @@ -160,19 +157,19 @@ void Print_JumpCalls(int Position) { for(i = 0; i < cx->dis_JumpCallN; i++) { if((cx->dis_JumpCalls[i].To) == Position) { if(Match == 0) { - printf("\n"); + term_out("\n"); Match = 1; } - printf("; Referenced from offset 0x%02x by %s\n", cx->dis_JumpCalls[i].From, avr_opcodes[cx->dis_JumpCalls[i].Type].opcode); + term_out("; Referenced from offset 0x%02x by %s\n", cx->dis_JumpCalls[i].From, avr_opcodes[cx->dis_JumpCalls[i].Type].opcode); } } if(Match == 1) { char *LabelComment = NULL; const char *LabelName = Get_Label_Name(Position, &LabelComment); if(LabelComment == NULL) { - printf("%s:\n", LabelName); + term_out("%s:\n", LabelName); } else { - printf("%s: ; %s\n", LabelName, LabelComment); + term_out("%s: ; %s\n", LabelName, LabelComment); } } } diff --git a/src/disasm_private.h b/src/disasm_private.h index 6e981a49..4856942d 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -51,14 +51,10 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); const char *Resolve_IO_Register(int Number); void Emit_Used_IO_Registers(); -void Display_JumpCalls(); void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall); -int JC_Comparison(const void *Element1, const void *Element2); -void Sort_JumpCalls(); void Enumerate_Labels(); const char *Get_Label_Name(int Destination, char **LabelComment); void Print_JumpCalls(int Position); -int FixTargetAddress(int Address); void adc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void add_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index 2055ca3a..b73965cc 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -458,7 +458,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { if((BytesAdvanced % 2) != 0) { // Not yet aligned correctly if(Bitstream[Position + BytesAdvanced] != 0x00) - fprintf(stderr, "Warning in autoalignment: expected zero but got 0x%0x padding. Ignored.\n", + pmsg_warning("autoalignment expected zero but got 0x%0x padding; ignored\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); term_out(".byte 0x%02x ; String Autoalignment\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); BytesAdvanced++; diff --git a/src/libavrdude.h b/src/libavrdude.h index b501c32a..5b5c0a4a 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1459,12 +1459,9 @@ typedef struct { int Show_Opcodes; int Show_Comments; int Show_Cycles; - char Filename[256]; - char MCU[8]; - const char *Tagfile; + char *Tagfile; int CodeStyle; int Process_Labels; - int Pass; int FlashSize; int AVR_Level; AVR_cycle_index cycle_index; @@ -1475,7 +1472,7 @@ typedef struct { int To; int Type; unsigned int LabelNumber; - unsigned char FunctionCall; + int FunctionCall; } Disasm_JumpCall; typedef struct { @@ -1712,6 +1709,7 @@ char *avr_cc_buffer(size_t n); int disasm_init(const AVRPART *p); int disasm_init_tagfile(const AVRPART *p, const char *file); int disasm(const char *buf, int len, int addr); +void disasm_zap_JumpCalls(); #ifdef __cplusplus } @@ -1805,7 +1803,7 @@ typedef struct { int reccount; // Static variables from disasm*.c - int dis_initopts; + int dis_initopts, dis_pass; Disasm_options dis_opts; int dis_n_ops; Disasm_opcode dis_op[256]; // Must be 256 diff --git a/src/term.c b/src/term.c index d99f7afb..58a2fbaf 100644 --- a/src/term.c +++ b/src/term.c @@ -232,11 +232,12 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, if(cmd[1] == 'i') { msg_error("Options:\n" " -a show addresses, -A don't show addresses\n" - " -o show opcodes, -O don't show opcodes\n" + " -o show opcode bytes, -O don't show opcode bytes\n" " -c show comments, -C don't show comments\n" " -q show call cycles, -Q don't show call cycles\n" " -s use avr-gcc code style, -S use AVR instruction set code style\n" " -l preprocess jump/call, -L don't preprocess jump/call\n" + " -z zap list of jumps/calls\n" " -t= set the tagfile to be used\n" ); } @@ -467,8 +468,6 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.Show_Opcodes = 0; cx->dis_opts.Show_Comments = 1; cx->dis_opts.Show_Cycles = 0; - cx->dis_opts.Filename[0] = 0; - cx->dis_opts.MCU[0] = 0; cx->dis_opts.Tagfile = NULL; cx->dis_opts.CodeStyle = CODESTYLE_AVRGCC; // CODESTYLE_AVR_INSTRUCTION_SET cx->dis_opts.Process_Labels = 1; @@ -480,8 +479,6 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c disasm_init(p); cx->dis_initopts++; } - cx->dis_opts.Pass = 1; - for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; @@ -512,10 +509,14 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c case 'l': case 'L': cx->dis_opts.Process_Labels = !!islower(chr); break; + case 'z': + disasm_zap_JumpCalls(); + break; case 't': if(*++q == '=') q++; - cx->dis_opts.Tagfile = q; + mmt_free(cx->dis_opts.Tagfile); + cx->dis_opts.Tagfile = mmt_strdup(q); q = "x"; break; default: From e73e5de0976c0cdb985dac4ed3751bddba2378fa Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 19:03:57 +0100 Subject: [PATCH 306/422] Loosen condition for recognising existing label --- src/disasm_jumpcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 87a404df..1d816403 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -49,7 +49,7 @@ void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { // Already entered this JC? for(int i = 0; i < N; i++) - if(jc[i].From == From && jc[N].To == To && jc[N].Type == Type && jc[N].FunctionCall == FunctionCall) + if(jc[i].From == From && jc[N].To == To && jc[N].Type == Type) return; jc = mmt_realloc(jc, sizeof(Disasm_JumpCall) * (N+1)); From c8ffcfcbec442f0b6bc31e5e0e7cc53dcca12f9d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 19:04:29 +0100 Subject: [PATCH 307/422] Add des opcode --- src/disasm.c | 1 + src/disasm_callbacks_assembly.c | 8 ++++++++ src/disasm_private.h | 1 + 3 files changed, 10 insertions(+) diff --git a/src/disasm.c b/src/disasm.c index 649848c4..5856787d 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -346,6 +346,7 @@ int disasm_init(const AVRPART *p) { Register_Opcode(cpc_Callback, "0000 01rd dddd rrrr", OPCODE_cpc); Register_Opcode(cpi_Callback, "0011 KKKK dddd KKKK", OPCODE_cpi); Register_Opcode(cpse_Callback, "0001 00rd dddd rrrr", OPCODE_cpse); + Register_Opcode(des_Callback, "1001 0100 KKKK 1011", OPCODE_des); Register_Opcode(dec_Callback, "1001 010d dddd 1010", OPCODE_dec); Register_Opcode(eicall_Callback, "1001 0101 0001 1001", OPCODE_eicall); Register_Opcode(eijmp_Callback, "1001 0100 0001 1001", OPCODE_eijmp); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index cab65494..992bf318 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -156,6 +156,10 @@ static void Operation_s(AVR_opcode mnemo) { snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); } +static void Operation_K(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s %d", avr_opcodes[mnemo].opcode, RK); +} + static void Operation_k(AVR_opcode mnemo, int Position, const char *Pseudocode) { int Offset; int Target; @@ -404,6 +408,10 @@ CALLBACK(dec_Callback) { Operation_Rd(mnemo); } +CALLBACK(des_Callback) { + Operation_K(mnemo); +} + CALLBACK(eicall_Callback) { Operation_Simple(mnemo); } diff --git a/src/disasm_private.h b/src/disasm_private.h index 4856942d..d321b3bc 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -103,6 +103,7 @@ void cpc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void cpi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void cpse_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void dec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void des_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void eicall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void eijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void elpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From 1454b55a01914bdcb1035b1f559dbd06e74769c7 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 19:15:33 +0100 Subject: [PATCH 308/422] Add xch opcode --- src/avr_opcodes.c | 8 ++++---- src/disasm.c | 2 +- src/disasm_callbacks_assembly.c | 8 ++++++++ src/disasm_private.h | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 66f207cd..af441fdb 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -134,10 +134,10 @@ const AVR_opcode_data avr_opcodes[164] = { {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", {"2", "2", "2", "3"}, ""}, - {0xfe0f, 0x9204, 1, "1001 001r rrrr 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9205, 1, "1001 001r rrrr 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9206, 1, "1001 001r rrrr 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9207, 1, "1001 001r rrrr 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9204, 1, "1001 001d dddd 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9205, 1, "1001 001d dddd 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9206, 1, "1001 001d dddd 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9207, 1, "1001 001d dddd 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADD Rd, Rd"}, diff --git a/src/disasm.c b/src/disasm.c index 5856787d..d90d5caf 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -264,7 +264,6 @@ int disasm_init(const AVRPART *p) { /* * 8 untreated opcodes and 20 "unofficial" ones * - * OPCODE_des * OPCODE_xch * OPCODE_lac * OPCODE_las @@ -434,6 +433,7 @@ int disasm_init(const AVRPART *p) { Register_Opcode(subi_Callback, "0101 KKKK dddd KKKK", OPCODE_subi); Register_Opcode(swap_Callback, "1001 010d dddd 0010", OPCODE_swap); // Register_Opcode(tst_Callback, "0010 00dd dddd dddd", OPCODE_tst); // Implied by and + Register_Opcode(xch_Callback, "1001 001d dddd 0100", OPCODE_xch); Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 992bf318..95a93e0a 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -65,6 +65,10 @@ static void Operation_Rd(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd); } +static void Operation_Z_Rd(AVR_opcode mnemo) { + snprintf(cx->dis_code, 255, "%-7s Z, r%d", avr_opcodes[mnemo].opcode, Rd); +} + static void Operation_Rd16(AVR_opcode mnemo) { snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd + 16); } @@ -837,6 +841,10 @@ CALLBACK(swap_Callback) { Operation_Rd(mnemo); } +CALLBACK(xch_Callback) { + Operation_Z_Rd(mnemo); +} + CALLBACK(wdr_Callback) { Operation_Simple(mnemo); } diff --git a/src/disasm_private.h b/src/disasm_private.h index d321b3bc..c2b493f9 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -186,5 +186,6 @@ void sts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sub_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void subi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void swap_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void xch_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void wdr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From dc2f4df103b7b72ac3f6e91fc59bfd770ccdf0f1 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 19:20:20 +0100 Subject: [PATCH 309/422] Add lac opcode --- src/disasm.c | 1 + src/disasm_callbacks_assembly.c | 4 ++++ src/disasm_private.h | 1 + 3 files changed, 6 insertions(+) diff --git a/src/disasm.c b/src/disasm.c index d90d5caf..af4ce75c 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -361,6 +361,7 @@ int disasm_init(const AVRPART *p) { Register_Opcode(in_Callback, "1011 0AAd dddd AAAA", OPCODE_in); Register_Opcode(inc_Callback, "1001 010d dddd 0011", OPCODE_inc); Register_Opcode(jmp_Callback, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp); + Register_Opcode(lac_Callback, "1001 001d dddd 0110", OPCODE_lac); Register_Opcode(ldx1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); Register_Opcode(ldx2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); Register_Opcode(ldx3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 95a93e0a..0273b761 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -494,6 +494,10 @@ CALLBACK(jmp_Callback) { Register_JumpCall(Position, Pos, mnemo, 0); } +CALLBACK(lac_Callback) { + Operation_Z_Rd(mnemo); +} + CALLBACK(ldx1_Callback) { snprintf(cx->dis_code, 255, "%-7s r%d, X", avr_opcodes[mnemo].opcode, Rd); } diff --git a/src/disasm_private.h b/src/disasm_private.h index c2b493f9..05c9dc85 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -118,6 +118,7 @@ void ijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void in_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void inc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void jmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lac_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From 8d7cf774df9823c0bfe66b4bfd4b352c81cbd233 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 19:21:50 +0100 Subject: [PATCH 310/422] Add las opcode --- src/disasm.c | 1 + src/disasm_callbacks_assembly.c | 4 ++++ src/disasm_private.h | 1 + 3 files changed, 6 insertions(+) diff --git a/src/disasm.c b/src/disasm.c index af4ce75c..a000aa52 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -362,6 +362,7 @@ int disasm_init(const AVRPART *p) { Register_Opcode(inc_Callback, "1001 010d dddd 0011", OPCODE_inc); Register_Opcode(jmp_Callback, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp); Register_Opcode(lac_Callback, "1001 001d dddd 0110", OPCODE_lac); + Register_Opcode(las_Callback, "1001 001d dddd 0101", OPCODE_lac); Register_Opcode(ldx1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); Register_Opcode(ldx2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); Register_Opcode(ldx3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 0273b761..e662cfc3 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -498,6 +498,10 @@ CALLBACK(lac_Callback) { Operation_Z_Rd(mnemo); } +CALLBACK(las_Callback) { + Operation_Z_Rd(mnemo); +} + CALLBACK(ldx1_Callback) { snprintf(cx->dis_code, 255, "%-7s r%d, X", avr_opcodes[mnemo].opcode, Rd); } diff --git a/src/disasm_private.h b/src/disasm_private.h index 05c9dc85..da871699 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -119,6 +119,7 @@ void in_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void inc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void jmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void lac_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void las_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From 741b2ef1ef2f6d8413c9cd798945d4af23fb30f9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 19:23:13 +0100 Subject: [PATCH 311/422] Add lat opcode --- src/disasm.c | 3 ++- src/disasm_callbacks_assembly.c | 4 ++++ src/disasm_private.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/disasm.c b/src/disasm.c index a000aa52..cb7167be 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -362,7 +362,8 @@ int disasm_init(const AVRPART *p) { Register_Opcode(inc_Callback, "1001 010d dddd 0011", OPCODE_inc); Register_Opcode(jmp_Callback, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp); Register_Opcode(lac_Callback, "1001 001d dddd 0110", OPCODE_lac); - Register_Opcode(las_Callback, "1001 001d dddd 0101", OPCODE_lac); + Register_Opcode(las_Callback, "1001 001d dddd 0101", OPCODE_las); + Register_Opcode(lat_Callback, "1001 001d dddd 0111", OPCODE_lat); Register_Opcode(ldx1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); Register_Opcode(ldx2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); Register_Opcode(ldx3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index e662cfc3..5ce49603 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -502,6 +502,10 @@ CALLBACK(las_Callback) { Operation_Z_Rd(mnemo); } +CALLBACK(lat_Callback) { + Operation_Z_Rd(mnemo); +} + CALLBACK(ldx1_Callback) { snprintf(cx->dis_code, 255, "%-7s r%d, X", avr_opcodes[mnemo].opcode, Rd); } diff --git a/src/disasm_private.h b/src/disasm_private.h index da871699..15ba28cf 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -120,6 +120,7 @@ void inc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void jmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void lac_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void las_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lat_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From fe5a40b93c843b94b6057d0594b07a80b3097290 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 19:36:51 +0100 Subject: [PATCH 312/422] Add spm Z+ opcode --- src/disasm.c | 6 +----- src/disasm_callbacks_assembly.c | 4 ++++ src/disasm_private.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index cb7167be..8f4bd4e0 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -264,11 +264,6 @@ int disasm_init(const AVRPART *p) { /* * 8 untreated opcodes and 20 "unofficial" ones * - * OPCODE_xch - * OPCODE_lac - * OPCODE_las - * OPCODE_lat - * * OPCODE_lds_rc * OPCODE_spm_zz * OPCODE_sts_rc @@ -420,6 +415,7 @@ int disasm_init(const AVRPART *p) { Register_Opcode(sez_Callback, "1001 0100 0001 1000", OPCODE_sez); Register_Opcode(sleep_Callback, "1001 0101 1000 1000", OPCODE_sleep); Register_Opcode(spm_Callback, "1001 0101 1110 1000", OPCODE_spm); + Register_Opcode(spm_zz_Callback, "1001 0101 1111 1000", OPCODE_spm_zz); Register_Opcode(stx1_Callback, "1001 001r rrrr 1100", OPCODE_st_1); Register_Opcode(stx2_Callback, "1001 001r rrrr 1101", OPCODE_st_2); Register_Opcode(stx3_Callback, "1001 001r rrrr 1110", OPCODE_st_3); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 5ce49603..6e862956 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -786,6 +786,10 @@ CALLBACK(spm_Callback) { Operation_Simple(mnemo); } +CALLBACK(spm_zz_Callback) { + snprintf(cx->dis_code, 255, "%-7s Z+", avr_opcodes[mnemo].opcode); +} + CALLBACK(stx1_Callback) { snprintf(cx->dis_code, 255, "%-7s X, r%d", avr_opcodes[mnemo].opcode, Rr); } diff --git a/src/disasm_private.h b/src/disasm_private.h index 15ba28cf..cf86894a 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -174,6 +174,7 @@ void sev_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sez_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sleep_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void spm_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void spm_zz_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void stx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void stx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void stx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From a1050419f94f2a816a2f8e2fe4fa0b6535e6e32b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 20:02:32 +0100 Subject: [PATCH 313/422] Add lds command for reduced-core ATtiny --- src/disasm.c | 2 +- src/disasm_callbacks_assembly.c | 15 +++++++++++++++ src/disasm_private.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/disasm.c b/src/disasm.c index 8f4bd4e0..ccaa5a5a 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -265,7 +265,6 @@ int disasm_init(const AVRPART *p) { * 8 untreated opcodes and 20 "unofficial" ones * * OPCODE_lds_rc - * OPCODE_spm_zz * OPCODE_sts_rc * * OPCODE_x_bld @@ -372,6 +371,7 @@ int disasm_init(const AVRPART *p) { Register_Opcode(ldz4_Callback, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2); Register_Opcode(ldi_Callback, "1110 KKKK dddd KKKK", OPCODE_ldi); Register_Opcode(lds_Callback, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds); + Register_Opcode(lds_rc_Callback, "1010 0kkk dddd kkkk", OPCODE_lds_rc); Register_Opcode(lpm1_Callback, "1001 0101 1100 1000", OPCODE_lpm_1); Register_Opcode(lpm2_Callback, "1001 000d dddd 0100", OPCODE_lpm_2); Register_Opcode(lpm3_Callback, "1001 000d dddd 0101", OPCODE_lpm_3); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index 6e862956..a95c305b 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -565,6 +565,21 @@ CALLBACK(lds_Callback) { } } +CALLBACK(lds_rc_Callback) { + const char *MemAddress; + + /* + * ADDR[7:0] ← (/INST[8], INST[8], INST[10], INST[9], INST[3], INST[2], INST[1], INST[0]) + * ADDR[7:0] ← (/k[4], k[4], k[6], k[5], k[3], k[2], k[1], k[0]) + */ + int addr = (Rk & 0xf) | ((Rk >> 1) & 0x30) | ((Rk & 0x10) << 2) | (((Rk & 0x10) ^ 0x10) << 3); + + snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd+16, addr); + MemAddress = Tagfile_Resolve_Mem_Address(addr); + if(MemAddress) + snprintf(cx->dis_comment, 255, "%s", MemAddress); +} + CALLBACK(lpm1_Callback) { Operation_Simple(mnemo); } diff --git a/src/disasm_private.h b/src/disasm_private.h index cf86894a..fe7d409b 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -134,6 +134,7 @@ void ldz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void ldi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void lds_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void lds_rc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void lpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void lpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void lpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From a973a92023523a416d08b41ad433f605d785c49d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 20:11:10 +0100 Subject: [PATCH 314/422] Add sts command for reduced-core ATtiny --- src/disasm.c | 6 ++---- src/disasm_callbacks_assembly.c | 19 ++++++++++++++++--- src/disasm_private.h | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index ccaa5a5a..56acc960 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -262,10 +262,7 @@ static int Comparison(const void *Element1, const void *Element2) { int disasm_init(const AVRPART *p) { /* - * 8 untreated opcodes and 20 "unofficial" ones - * - * OPCODE_lds_rc - * OPCODE_sts_rc + * 20 unallocated codes * * OPCODE_x_bld * OPCODE_x_bst @@ -428,6 +425,7 @@ int disasm_init(const AVRPART *p) { Register_Opcode(stz3_Callback, "1001 001r rrrr 0010", OPCODE_st_9); Register_Opcode(stz4_Callback, "10q0 qq1r rrrr 0qqq", OPCODE_std_2); Register_Opcode(sts_Callback, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts); + Register_Opcode(sts_rc_Callback, "1010 1kkk dddd kkkk", OPCODE_sts_rc); Register_Opcode(sub_Callback, "0001 10rd dddd rrrr", OPCODE_sub); Register_Opcode(subi_Callback, "0101 KKKK dddd KKKK", OPCODE_subi); Register_Opcode(swap_Callback, "1001 010d dddd 0010", OPCODE_swap); diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index a95c305b..ce08727b 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -566,16 +566,15 @@ CALLBACK(lds_Callback) { } CALLBACK(lds_rc_Callback) { - const char *MemAddress; - /* + * Address is limited to 0x40...0xbf for the reduced-core (TPI part) * ADDR[7:0] ← (/INST[8], INST[8], INST[10], INST[9], INST[3], INST[2], INST[1], INST[0]) * ADDR[7:0] ← (/k[4], k[4], k[6], k[5], k[3], k[2], k[1], k[0]) */ int addr = (Rk & 0xf) | ((Rk >> 1) & 0x30) | ((Rk & 0x10) << 2) | (((Rk & 0x10) ^ 0x10) << 3); snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd+16, addr); - MemAddress = Tagfile_Resolve_Mem_Address(addr); + const char *MemAddress = Tagfile_Resolve_Mem_Address(addr); if(MemAddress) snprintf(cx->dis_comment, 255, "%s", MemAddress); } @@ -860,6 +859,20 @@ CALLBACK(sts_Callback) { } } +CALLBACK(sts_rc_Callback) { + /* + * Address is limited to 0x40...0xbf for the reduced-core (TPI part) + * ADDR[7:0] ← (/INST[8], INST[8], INST[10], INST[9], INST[3], INST[2], INST[1], INST[0]) + * ADDR[7:0] ← (/k[4], k[4], k[6], k[5], k[3], k[2], k[1], k[0]) + */ + int addr = (Rk & 0xf) | ((Rk >> 1) & 0x30) | ((Rk & 0x10) << 2) | (((Rk & 0x10) ^ 0x10) << 3); + + snprintf(cx->dis_code, 255, "%-7s 0x%02x, r%d", avr_opcodes[mnemo].opcode, addr, Rd+16); + const char *MemAddress = Tagfile_Resolve_Mem_Address(addr); + if(MemAddress) + snprintf(cx->dis_comment, 255, "%s", MemAddress); +} + CALLBACK(sub_Callback) { Operation_Rd_Rr(mnemo); } diff --git a/src/disasm_private.h b/src/disasm_private.h index fe7d409b..04bd3293 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -188,6 +188,7 @@ void stz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void stz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void stz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +void sts_rc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void sub_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void subi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void swap_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); From e636a0b4ceef465bcac94a0a9479375b254d6921 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 20:12:52 +0100 Subject: [PATCH 315/422] Fix normal lds operand order --- src/disasm_callbacks_assembly.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index ce08727b..fd736e8b 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -559,7 +559,6 @@ CALLBACK(lds_Callback) { snprintf(cx->dis_code, 255, "%-7s r%d, 0x%04x", avr_opcodes[mnemo].opcode, Rd, Rk); MemAddress = Tagfile_Resolve_Mem_Address(Rk); - snprintf(cx->dis_code, 255, "%-7s 0x%04x, r%d", avr_opcodes[mnemo].opcode, Rk, Rd); if(MemAddress) { snprintf(cx->dis_comment, 255, "%s", MemAddress); } From 22eb262c53719f62a4a634f9f27d39c6bcc5d896 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 20:24:59 +0100 Subject: [PATCH 316/422] Determine default disasm options --- src/term.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/term.c b/src/term.c index 58a2fbaf..5f63e5b8 100644 --- a/src/term.c +++ b/src/term.c @@ -231,14 +231,14 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, ); if(cmd[1] == 'i') { msg_error("Options:\n" - " -a show addresses, -A don't show addresses\n" - " -o show opcode bytes, -O don't show opcode bytes\n" - " -c show comments, -C don't show comments\n" - " -q show call cycles, -Q don't show call cycles\n" - " -s use avr-gcc code style, -S use AVR instruction set code style\n" - " -l preprocess jump/call, -L don't preprocess jump/call\n" - " -z zap list of jumps/calls\n" - " -t= set the tagfile to be used\n" + " -a show addresses (default), -A don't show addresses\n" + " -o show opcode bytes (default), -O don't show opcode bytes\n" + " -c show comments (default), -C don't show comments\n" + " -q show call cycles, -Q don't show call cycles (default)\n" + " -s use avr-gcc code style (default), -S use AVR inst set code style\n" + " -l preprocess jump/call (default), -L don't preprocess jump/call\n" + " -z zap list of jumps/calls before disassembly\n" + " -t= set the tagfile (zaps old tagfile contents)\n" ); } msg_error("\n" @@ -464,16 +464,15 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c int help = 0, invalid = 0, itemac = 1, chr; if(!cx->dis_initopts) { - cx->dis_opts.Show_Addresses = 0; - cx->dis_opts.Show_Opcodes = 0; + cx->dis_opts.Show_Addresses = 1; + cx->dis_opts.Show_Opcodes = 1; cx->dis_opts.Show_Comments = 1; cx->dis_opts.Show_Cycles = 0; cx->dis_opts.Tagfile = NULL; cx->dis_opts.CodeStyle = CODESTYLE_AVRGCC; // CODESTYLE_AVR_INSTRUCTION_SET cx->dis_opts.Process_Labels = 1; - cx->dis_opts.FlashSize = 0; - if((mem = avr_locate_flash(p))) - cx->dis_opts.FlashSize = mem->size; + AVRMEM *m = avr_locate_flash(p); + cx->dis_opts.FlashSize = m? m->size: 0; cx->dis_opts.AVR_Level = get_avr_archlevel(p); cx->dis_opts.cycle_index = get_avr_cycle_index(p); disasm_init(p); From 88ef47c7d12aba1b2a120828b025e80754dfb228 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 21:10:40 +0100 Subject: [PATCH 317/422] Label unallocated opcodes with OP_AVR_ILL --- src/avr_opcodes.c | 40 ++++++++++++++++++++-------------------- src/disasm.c | 2 +- src/libavrdude.h | 2 ++ src/term.c | 27 ++++++++++++++++++--------- 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index af441fdb..4e7521a3 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -176,24 +176,24 @@ const AVR_opcode_data avr_opcodes[164] = { {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OP_AVR1, OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", {"1", "1", "1", "1"}, ""}, // Unallocated codes - {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OP_AVR1, OPCODE_x_nop_1, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, - {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OP_AVR1, OPCODE_x_nop_2, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OP_AVR1, OPCODE_x_nop_3, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OP_AVR1, OPCODE_x_nop_4, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OP_AVR1, OPCODE_x_nop_5, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR1, OPCODE_x_nop_6, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR1, OPCODE_x_nop_7, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR2, OPCODE_x_icall, "x_icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, - {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_XL, OPCODE_x_eicall, "x_eicall", "EIND:Z", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, "xxx != 000"}, - {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR1, OPCODE_x_ret, "x_ret", "-", "alt Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, - {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR1, OPCODE_x_reti, "x_reti", "-", "alt Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, - {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR1, OPCODE_x_nop_8, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR1, OPCODE_x_nop_9, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR1, OPCODE_x_nop_a, "x_nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR2, OPCODE_x_ijmp, "x_ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, "xxx != 000"}, - {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_XL, OPCODE_x_eijmp, "x_eijmp", "EIND:Z", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, "xxx != 000"}, - {0xfe08, 0xf808, 1, "1111 100d dddd 1bbb", OP_AVR1, OPCODE_x_bld, "x_bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, - {0xfe08, 0xfa08, 1, "1111 101d dddd 1bbb", OP_AVR1, OPCODE_x_bst, "x_bst", "Rd, b", "alt Bit Store from Register to T", "T <-- Rd(b)", "T", {"1", "1", "1", "1"}, ""}, - {0xfe08, 0xfc08, 1, "1111 110r rrrr 1bbb", OP_AVR1, OPCODE_x_sbrc, "x_sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {0xfe08, 0xfe08, 1, "1111 111r rrrr 1bbb", OP_AVR1, OPCODE_x_sbrs, "x_sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OP_AVR_ILL, OPCODE_x_nop_1, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, + {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OP_AVR_ILL, OPCODE_x_nop_2, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OP_AVR_ILL, OPCODE_x_nop_3, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OP_AVR_ILL, OPCODE_x_nop_4, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OP_AVR_ILL, OPCODE_x_nop_5, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR_ILL, OPCODE_x_nop_6, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR_ILL, OPCODE_x_nop_7, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR_ILL, OPCODE_x_icall, "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, + {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_ILL, OPCODE_x_eicall, "u/eicall", "EIND:Z", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, "xxx != 000"}, + {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR_ILL, OPCODE_x_ret, "u/ret", "-", "alt Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, + {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR_ILL, OPCODE_x_reti, "u/reti", "-", "alt Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, + {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR_ILL, OPCODE_x_nop_8, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR_ILL, OPCODE_x_nop_9, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR_ILL, OPCODE_x_nop_a, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, + {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR_ILL, OPCODE_x_ijmp, "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, "xxx != 000"}, + {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_ILL, OPCODE_x_eijmp, "u/eijmp", "EIND:Z", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, "xxx != 000"}, + {0xfe08, 0xf808, 1, "1111 100d dddd 1bbb", OP_AVR_ILL, OPCODE_x_bld, "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, + {0xfe08, 0xfa08, 1, "1111 101d dddd 1bbb", OP_AVR_ILL, OPCODE_x_bst, "u/bst", "Rd, b", "alt Bit Store from Register to T", "T <-- Rd(b)", "T", {"1", "1", "1", "1"}, ""}, + {0xfe08, 0xfc08, 1, "1111 110r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_sbrc, "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {0xfe08, 0xfe08, 1, "1111 111r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_sbrs, "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, }; diff --git a/src/disasm.c b/src/disasm.c index 56acc960..d0185794 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -40,7 +40,7 @@ static void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char *New_Opcode_String, AVR_opcode mnemo) { // Only register opcode if the part has it - if(avr_opcodes[mnemo].avrlevel & cx->dis_opts.AVR_Level) { + if((avr_opcodes[mnemo].avrlevel & cx->dis_opts.AVR_Level) && cx->dis_n_ops < (int) sizeof cx->dis_op/sizeof*cx->dis_op) { cx->dis_op[cx->dis_n_ops].Opcode_String = mmt_strdup(New_Opcode_String); cx->dis_op[cx->dis_n_ops].mnemo = mnemo; cx->dis_op[cx->dis_n_ops].Callback = Callback; diff --git a/src/libavrdude.h b/src/libavrdude.h index 5b5c0a4a..3094196c 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1565,6 +1565,7 @@ typedef enum { OP_AVR_XL = 512, // AVR with flash > 128 kB (EIJMP, EICALL) OP_AVR_XM = 1024, // XMEGA only (DES, XCH, LAC, LAS, LAT) OP_AVR_XTM = 2048, // XMEGA and UPDI only (SPM Z+) + OP_AVR_ILL = 4096, // Unallocated (illegal) opcodes } AVR_archlevel; /* @@ -1585,6 +1586,7 @@ typedef enum { #define PART_AVR6 (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_L|OP_AVR_XL) #define PART_AVR_XT (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_XTM) #define PART_AVR_XM (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_XM|OP_AVR_XTM) +#define PART_ALL (PART_AVR_XM|OP_AVR_L|OP_AVR_XL) // All but RC (the latter conflicts) typedef struct { int mask, value, nwords; diff --git a/src/term.c b/src/term.c index 5f63e5b8..f31b4108 100644 --- a/src/term.c +++ b/src/term.c @@ -237,6 +237,8 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, " -q show call cycles, -Q don't show call cycles (default)\n" " -s use avr-gcc code style (default), -S use AVR inst set code style\n" " -l preprocess jump/call (default), -L don't preprocess jump/call\n" + " -d decode all opcodes (irrespective of part)\n" + " -D decode all opcodes, even unallocated illegal opcodes\n" " -z zap list of jumps/calls before disassembly\n" " -t= set the tagfile (zaps old tagfile contents)\n" ); @@ -471,14 +473,15 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.Tagfile = NULL; cx->dis_opts.CodeStyle = CODESTYLE_AVRGCC; // CODESTYLE_AVR_INSTRUCTION_SET cx->dis_opts.Process_Labels = 1; - AVRMEM *m = avr_locate_flash(p); - cx->dis_opts.FlashSize = m? m->size: 0; - cx->dis_opts.AVR_Level = get_avr_archlevel(p); - cx->dis_opts.cycle_index = get_avr_cycle_index(p); disasm_init(p); cx->dis_initopts++; } + mem = avr_locate_flash(p); + cx->dis_opts.FlashSize = mem? mem->size: 0; + cx->dis_opts.AVR_Level = get_avr_archlevel(p); + cx->dis_opts.cycle_index = get_avr_cycle_index(p); + for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; if(*(q = argv[++ai]) != '-' || !q[1]) @@ -491,26 +494,32 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c help++; break; case 'a': case 'A': - cx->dis_opts.Show_Addresses = !!islower(chr); + cx->dis_opts.Show_Addresses = islower(chr); break; case 'o': case 'O': - cx->dis_opts.Show_Opcodes = !!islower(chr); + cx->dis_opts.Show_Opcodes = islower(chr); break; case 'c': case 'C': - cx->dis_opts.Show_Comments = !!islower(chr); + cx->dis_opts.Show_Comments = islower(chr); break; case 'q': case 'Q': - cx->dis_opts.Show_Cycles = !!islower(chr); + cx->dis_opts.Show_Cycles = islower(chr); break; case 's': case 'S': cx->dis_opts.CodeStyle = islower(chr)? CODESTYLE_AVRGCC: CODESTYLE_AVR_INSTRUCTION_SET; break; case 'l': case 'L': - cx->dis_opts.Process_Labels = !!islower(chr); + cx->dis_opts.Process_Labels = islower(chr); break; case 'z': disasm_zap_JumpCalls(); break; + case 'd': + cx->dis_opts.AVR_Level = PART_ALL; + break; + case 'D': + cx->dis_opts.AVR_Level = PART_ALL | OP_AVR_ILL; + break; case 't': if(*++q == '=') q++; From 7dbab82a2b7d67aafcb8643fecab6d1b96bf324c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 23:15:03 +0100 Subject: [PATCH 318/422] Provide disasm -d for decoding of all opcodes - Irrespective of the part - Including all unallocated opcodes Unallocated opcodes disassemble as u/opcode, eg, for the famous 0xffff: 7ff2: ff ff u/sbrs r31, 7 ; 0x80 = 128 --- src/disasm.c | 85 +++++++++++++++++++++++++--------------------------- src/term.c | 16 +++++----- 2 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index d0185794..48c108a1 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -39,8 +39,7 @@ #include "disasm_private.h" static void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char *New_Opcode_String, AVR_opcode mnemo) { - // Only register opcode if the part has it - if((avr_opcodes[mnemo].avrlevel & cx->dis_opts.AVR_Level) && cx->dis_n_ops < (int) sizeof cx->dis_op/sizeof*cx->dis_op) { + if(cx->dis_n_ops < (int) (sizeof cx->dis_op/sizeof*cx->dis_op)) { cx->dis_op[cx->dis_n_ops].Opcode_String = mmt_strdup(New_Opcode_String); cx->dis_op[cx->dis_n_ops].mnemo = mnemo; cx->dis_op[cx->dis_n_ops].Callback = Callback; @@ -133,13 +132,10 @@ static int Match_Opcode(const char *Bitmask, const char *Bitstream) { } static int Get_Next_Opcode(const char *Bitstream) { - int i; - - for(i = 0; i < cx->dis_n_ops; i++) { - if(Match_Opcode(cx->dis_op[i].Opcode_String, Bitstream) == 1) { - return i; - } - } + for(int i = 0; i < cx->dis_n_ops; i++) + if(avr_opcodes[cx->dis_op[i].mnemo].avrlevel & cx->dis_opts.AVR_Level) + if(Match_Opcode(cx->dis_op[i].Opcode_String, Bitstream) == 1) + return i; return -1; } @@ -235,57 +231,36 @@ int disasm(const char *Bitstream, int Read, int addr) { } static int Get_Specifity(const char *Opcode) { - size_t i; int Specifity = 0; - for(i = 0; i < strlen(Opcode); i++) { + for(size_t i = 0; i < strlen(Opcode); i++) if((Opcode[i] == '0') || (Opcode[i] == '1')) Specifity++; - } + return Specifity; } +// Percolate higher specifity towards beginning of array but ensure illegal opcodes are last static int Comparison(const void *Element1, const void *Element2) { Disasm_opcode *OC1, *OC2; - int SP1, SP2; - + int SP1, SP2, illegal1, illegal2, diff; OC1 = (Disasm_opcode *) Element1; OC2 = (Disasm_opcode *) Element2; + illegal1 = avr_opcodes[OC1->mnemo].avrlevel == OP_AVR_ILL; + illegal2 = avr_opcodes[OC2->mnemo].avrlevel == OP_AVR_ILL; + if((diff = illegal1 - illegal2)) + return diff; SP1 = Get_Specifity(OC1->Opcode_String); SP2 = Get_Specifity(OC2->Opcode_String); - if(SP1 < SP2) - return 1; - else if(SP2 == SP1) - return 0; - return -1; + if((diff = SP1 - SP2)) + return -diff; + // Tie break by mnemonic + return OC1->mnemo - OC2->mnemo; } int disasm_init(const AVRPART *p) { - /* - * 20 unallocated codes - * - * OPCODE_x_bld - * OPCODE_x_bst - * OPCODE_x_eicall - * OPCODE_x_eijmp - * OPCODE_x_icall - * OPCODE_x_ijmp - * OPCODE_x_nop_1 - * OPCODE_x_nop_2 - * OPCODE_x_nop_3 - * OPCODE_x_nop_4 - * OPCODE_x_nop_5 - * OPCODE_x_nop_6 - * OPCODE_x_nop_7 - * OPCODE_x_nop_8 - * OPCODE_x_nop_9 - * OPCODE_x_nop_a - * OPCODE_x_ret - * OPCODE_x_reti - * OPCODE_x_sbrc - * OPCODE_x_sbrs - */ - + for(int i=0; idis_n_ops; i++) + mmt_free(cx->dis_op[i].Opcode_String); cx->dis_n_ops = 0; Register_Opcode(adc_Callback, "0001 11rd dddd rrrr", OPCODE_adc); @@ -433,6 +408,28 @@ int disasm_init(const AVRPART *p) { Register_Opcode(xch_Callback, "1001 001d dddd 0100", OPCODE_xch); Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); + // Also register unallocated opcodes + Register_Opcode(nop_Callback, "0000 0000 xxxx xxxx", OPCODE_x_nop_1); + Register_Opcode(nop_Callback, "1001 000x xxxx 0011", OPCODE_x_nop_2); + Register_Opcode(nop_Callback, "1001 000x xxxx 1000", OPCODE_x_nop_3); + Register_Opcode(nop_Callback, "1001 000x xxxx 1011", OPCODE_x_nop_4); + Register_Opcode(nop_Callback, "1001 001x xxxx 0011", OPCODE_x_nop_5); + Register_Opcode(nop_Callback, "1001 001x xxxx 1000", OPCODE_x_nop_6); + Register_Opcode(nop_Callback, "1001 001x xxxx 1011", OPCODE_x_nop_7); + Register_Opcode(icall_Callback, "1001 0101 xxx0 1001", OPCODE_x_icall); + Register_Opcode(eicall_Callback, "1001 0101 xxx1 1001", OPCODE_x_eicall); + Register_Opcode(ret_Callback, "1001 0101 0xx0 1000", OPCODE_x_ret); + Register_Opcode(reti_Callback, "1001 0101 0xx1 1000", OPCODE_x_reti); + Register_Opcode(nop_Callback, "1001 0101 1011 1000", OPCODE_x_nop_8); + Register_Opcode(nop_Callback, "1001 010x xxxx 0100", OPCODE_x_nop_9); + Register_Opcode(nop_Callback, "1001 0101 xxxx 1011", OPCODE_x_nop_a); + Register_Opcode(ijmp_Callback, "1001 0100 xxx0 1001", OPCODE_x_ijmp); + Register_Opcode(eijmp_Callback, "1001 0100 xxx1 1001", OPCODE_x_eijmp); + Register_Opcode(bld_Callback, "1111 100d dddd 1bbb", OPCODE_x_bld); + Register_Opcode(bst_Callback, "1111 101d dddd 1bbb", OPCODE_x_bst); + Register_Opcode(sbrc_Callback, "1111 110r rrrr 1bbb", OPCODE_x_sbrc); + Register_Opcode(sbrs_Callback, "1111 111r rrrr 1bbb", OPCODE_x_sbrs); + qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); for(size_t i = 0; i < sizeof avr_opcodes/sizeof*avr_opcodes; i++) diff --git a/src/term.c b/src/term.c index f31b4108..ab21db79 100644 --- a/src/term.c +++ b/src/term.c @@ -237,8 +237,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, " -q show call cycles, -Q don't show call cycles (default)\n" " -s use avr-gcc code style (default), -S use AVR inst set code style\n" " -l preprocess jump/call (default), -L don't preprocess jump/call\n" - " -d decode all opcodes (irrespective of part)\n" - " -D decode all opcodes, even unallocated illegal opcodes\n" + " -d decode all (even unallocated) opcodes; -D only those of the part\n" " -z zap list of jumps/calls before disassembly\n" " -t= set the tagfile (zaps old tagfile contents)\n" ); @@ -473,15 +472,14 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.Tagfile = NULL; cx->dis_opts.CodeStyle = CODESTYLE_AVRGCC; // CODESTYLE_AVR_INSTRUCTION_SET cx->dis_opts.Process_Labels = 1; + mem = avr_locate_flash(p); + cx->dis_opts.FlashSize = mem? mem->size: 0; + cx->dis_opts.AVR_Level = get_avr_archlevel(p); + cx->dis_opts.cycle_index = get_avr_cycle_index(p); disasm_init(p); cx->dis_initopts++; } - mem = avr_locate_flash(p); - cx->dis_opts.FlashSize = mem? mem->size: 0; - cx->dis_opts.AVR_Level = get_avr_archlevel(p); - cx->dis_opts.cycle_index = get_avr_cycle_index(p); - for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; if(*(q = argv[++ai]) != '-' || !q[1]) @@ -515,10 +513,10 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c disasm_zap_JumpCalls(); break; case 'd': - cx->dis_opts.AVR_Level = PART_ALL; + cx->dis_opts.AVR_Level = PART_ALL | OP_AVR_ILL; break; case 'D': - cx->dis_opts.AVR_Level = PART_ALL | OP_AVR_ILL; + cx->dis_opts.AVR_Level = get_avr_archlevel(p); break; case 't': if(*++q == '=') From ab08e1c1b474faf78fae154d90f917ee0f9280ea Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 23:39:25 +0100 Subject: [PATCH 319/422] Wrap round flash on disasm --- src/disasm.c | 28 ++++++++++++++++++++-------- src/disasm_private.h | 1 + src/disasm_tagfile.c | 8 ++++---- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 48c108a1..d621dda8 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -139,6 +139,19 @@ static int Get_Next_Opcode(const char *Bitstream) { return -1; } +int disasm_wrap(int addr) { + int flashsz = cx->dis_opts.FlashSize; + + if(flashsz > 0) { + while(addr >= flashsz) + addr -= flashsz; + while(addr < 0) + addr += flashsz; + } + + return addr; +} + int disasm(const char *Bitstream, int Read, int addr) { int Pos; int Opcode; @@ -154,7 +167,7 @@ int disasm(const char *Bitstream, int Read, int addr) { if(Opcode == -1) { Pos += 2; } else { - cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos + addr, cx->dis_op[Opcode].mnemo); + cx->dis_op[Opcode].Callback(Bitstream + Pos, disasm_wrap(Pos + addr), cx->dis_op[Opcode].mnemo); Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; } } @@ -182,14 +195,13 @@ int disasm(const char *Bitstream, int Read, int addr) { cx->dis_code[0] = 0; cx->dis_comment[0] = 0; cx->dis_after_code[0] = 0; - cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos + addr, cx->dis_op[Opcode].mnemo); + cx->dis_op[Opcode].Callback(Bitstream + Pos, disasm_wrap(Pos + addr), cx->dis_op[Opcode].mnemo); - if(cx->dis_opts.Process_Labels) { - Print_JumpCalls(Pos + addr); - } + if(cx->dis_opts.Process_Labels) + Print_JumpCalls(disasm_wrap(Pos + addr)); if(cx->dis_opts.Show_Addresses) - term_out("%4x: ", Pos + addr); + term_out("%4x: ", disasm_wrap(Pos + addr)); if(cx->dis_opts.Show_Cycles) term_out("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clock[cx->dis_opts.cycle_index]); @@ -221,8 +233,8 @@ int disasm(const char *Bitstream, int Read, int addr) { Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; } else { - term_out(".word 0x%02x%02x ; Invalid opcode at 0x%04x\n", // @@@ show unoffical opcode what it might do - ((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], Pos + addr); + term_out(".word 0x%02x%02x ; Invalid opcode at 0x%04x\n", + ((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], disasm_wrap(Pos + addr)); Pos += 2; } } diff --git a/src/disasm_private.h b/src/disasm_private.h index 04bd3293..017d2eff 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -42,6 +42,7 @@ #define TYPE_STRING 4 void disasm_init_regfile(const AVRPART *p); +int disasm_wrap(int addr); int Tagfile_FindLabelAddress(int Address); char *Tagfile_GetLabel(int TagIndex); char *Tagfile_GetLabelComment(int TagIndex); diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index b73965cc..5e53d37e 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -397,7 +397,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { int (*ProcessingFunction)(const char *, int, int, int, const char *) = NULL; char Buffer[32]; - Index = Tagfile_FindPGMAddress(Position + offset); + Index = Tagfile_FindPGMAddress(disasm_wrap(Position + offset)); if(Index == -1) return 0; @@ -433,7 +433,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { } if(cx->dis_PGMLabels[Index].Count != 1) term_out("s"); - term_out(" starting at 0x%x", Position + offset); + term_out(" starting at 0x%x", disasm_wrap(Position + offset)); if(cx->dis_PGMLabels[Index].Comment != NULL) { term_out(" (%s)", cx->dis_PGMLabels[Index].Comment); @@ -442,10 +442,10 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { if((cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].Type == TYPE_STRING)) { if(cx->dis_PGMLabels[Index].Comment != NULL) { - snprintf(Buffer, sizeof(Buffer), "%x_%s", Position + offset, cx->dis_PGMLabels[Index].Comment); + snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_PGMLabels[Index].Comment); Sanitize_String(Buffer); } else { - snprintf(Buffer, sizeof(Buffer), "%x", Position + offset); + snprintf(Buffer, sizeof(Buffer), "%x", disasm_wrap(Position + offset)); } } From 966f20b8583be6b72f3463403460933bf4082949 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 18 Jul 2024 23:48:55 +0100 Subject: [PATCH 320/422] Adapt AVRDUDE style for GPL 2.0 licence header --- src/disasm.c | 45 +++++++++++++++---------------- src/disasm_callbacks_assembly.c | 45 +++++++++++++++---------------- src/disasm_jumpcall.c | 45 +++++++++++++++---------------- src/disasm_private.h | 48 +++++++++++++++++---------------- src/disasm_tagfile.c | 45 +++++++++++++++---------------- 5 files changed, 113 insertions(+), 115 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index d621dda8..ccd0718a 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -1,29 +1,28 @@ - /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer + * AVRDUDE - A Downloader/Uploader for AVR device programmers + * + * This file was ported from + * avrdisas - A disassembler for AVR microcontroller units + * Copyright (C) 2007 Johannes Bauer + * + * Copyright (C) 2024 port by Stefan Rueger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - This file is part of avrdisas. +/* $Id$ */ - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ #include #include diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c index fd736e8b..c5156283 100644 --- a/src/disasm_callbacks_assembly.c +++ b/src/disasm_callbacks_assembly.c @@ -1,29 +1,28 @@ - /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer + * AVRDUDE - A Downloader/Uploader for AVR device programmers + * + * This file was ported from + * avrdisas - A disassembler for AVR microcontroller units + * Copyright (C) 2007 Johannes Bauer + * + * Copyright (C) 2024 port by Stefan Rueger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - This file is part of avrdisas. +/* $Id$ */ - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ #include #include diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 1d816403..23ca365a 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -1,29 +1,28 @@ - /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer + * AVRDUDE - A Downloader/Uploader for AVR device programmers + * + * This file was ported from + * avrdisas - A disassembler for AVR microcontroller units + * Copyright (C) 2007 Johannes Bauer + * + * Copyright (C) 2024 port by Stefan Rueger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - This file is part of avrdisas. +/* $Id$ */ - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ #include #include diff --git a/src/disasm_private.h b/src/disasm_private.h index 017d2eff..13af2c77 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -1,29 +1,30 @@ - /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer + * AVRDUDE - A Downloader/Uploader for AVR device programmers + * + * This file was ported from + * avrdisas - A disassembler for AVR microcontroller units + * Copyright (C) 2007 Johannes Bauer + * + * Copyright (C) 2024 port by Stefan Rueger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - This file is part of avrdisas. +/* $Id$ */ - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ +#ifndef disasm_private_h +#define disasm_private_h #define Rd (cx->dis_regs['d']) #define Rr (cx->dis_regs['r']) @@ -196,3 +197,4 @@ void swap_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void xch_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); void wdr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); +#endif diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index 5e53d37e..81e96dbc 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -1,29 +1,28 @@ - /* - avrdisas - A disassembler for AVR microcontroller units - Copyright (C) 2007 Johannes Bauer + * AVRDUDE - A Downloader/Uploader for AVR device programmers + * + * This file was ported from + * avrdisas - A disassembler for AVR microcontroller units + * Copyright (C) 2007 Johannes Bauer + * + * Copyright (C) 2024 port by Stefan Rueger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - This file is part of avrdisas. +/* $Id$ */ - avrdisas is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - avrdisas is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with avrdisas; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Johannes Bauer - Mussinanstr. 140 - 92318 Neumarkt/Opf. - JohannesBauer@gmx.de -*/ #include #include From 64aeb1203a54b3e6df4af79ffaac7f93164c3616 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 19 Jul 2024 00:01:47 +0100 Subject: [PATCH 321/422] Provide a bash script to generate disasm tag files --- tools/elf2tag | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 tools/elf2tag diff --git a/tools/elf2tag b/tools/elf2tag new file mode 100755 index 00000000..a0d27715 --- /dev/null +++ b/tools/elf2tag @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# Published under GNU General Public License, version 2 (GPL-2.0) +# Copyright (C) 2007 Johannes Bauer +# Copyright (C) 2024 Small modifications by Stefan Rueger + +progname=$(basename "$0") +if [ "$1" == "" ]; then +cat <.elf +Function: output a tag file suitable for the terminal disasm -t= command +Options: none +END +exit 1 +fi + +echo "# Automatically generated tagfile via ${progname} ${1}" +avr-objdump -d "$1" | grep '<.*>:' | awk '{ + ADDR = strtonum("0x" $1); + printf("0x%04x L %s\n", ADDR, substr($2, 2, length($2) - 3)); +}' +echo +avr-nm "$1" | grep '^0080' | sort | grep -Ev '_(_bss_start|_data_end|_data_start|_bss_end|edata|DATA_REGION_ORIGIN)' | awk ' +{ + ADDR = strtonum("0x" $1) - strtonum("0x800000"); + if (LAST != "") { + STARTADDR = LAST; + ENDADDR = ADDR - 1; + SYMBOL = LASTSYM; + SIZE = ENDADDR - STARTADDR + 1; + if (SIZE == 1) { + printf("0x%04x M B 1 %s\n", STARTADDR, SYMBOL); + } else if (SIZE == 2) { + printf("0x%04x M W 1 %s\n", STARTADDR, SYMBOL); + } else { + printf("0x%04x M B %d %s\n", STARTADDR, SIZE, SYMBOL); + } + + } + LAST = ADDR; + LASTSYM = $3; +}' From ce391927ad81f7ff067ad4838b775e99bb79ecf5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 19 Jul 2024 14:38:20 +0100 Subject: [PATCH 322/422] Encode register constraints for tst, clr, lsl and rol --- src/avr_opcodes.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 4e7521a3..f6aa9b90 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -41,8 +41,8 @@ const AVR_opcode_data avr_opcodes[164] = { {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ANDI Rd, (0xFF - K)"}, {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x2000, 1, "0010 00dd dddd dddd", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for AND Rd, Rd"}, - {0xfc00, 0x2400, 1, "0010 01dd dddd dddd", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for EOR Rd, Rd"}, + {0xfc00, 0x2000, 1, "0010 00d= dddd ====", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for AND Rd, Rd"}, + {0xfc00, 0x2400, 1, "0010 01d= dddd ====", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for EOR Rd, Rd"}, {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for LDI Rd, 0xFF; d = 16...31"}, {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", {"2", "2", "2", "n/a"}, ""}, {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..31"}, @@ -130,8 +130,8 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OP_AVR_L, OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OP_AVR25, OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", {"-", "-", "-", "-"}, ""}, {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OP_AVR_XTM, OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", {"n/a", "-", "-", "n/a"}, ""}, - {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In From I/O Location", "Rd <-- I/O(A)", "None", {"1", "1", "1", "1"}, ""}, - {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out To I/O Location", "I/O(A) <-- Rr", "None", {"1", "1", "1", "1"}, ""}, + {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In from I/O Location", "Rd <-- I/O(A)", "None", {"1", "1", "1", "1"}, ""}, + {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out to I/O Location", "I/O(A) <-- Rr", "None", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", {"2", "2", "2", "3"}, ""}, {0xfe0f, 0x9204, 1, "1001 001d dddd 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, @@ -140,9 +140,9 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfe0f, 0x9207, 1, "1001 001d dddd 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions - {0xfc00, 0x0c00, 1, "0000 11dd dddd dddd", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADD Rd, Rd"}, + {0xfc00, 0x0c00, 1, "0000 11d= dddd ====", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADD Rd, Rd"}, {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OP_AVR1, OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x1c00, 1, "0001 11dd dddd dddd", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADC Rd, Rd"}, + {0xfc00, 0x1c00, 1, "0001 11d= dddd ====", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADC Rd, Rd"}, {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OP_AVR1, OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OP_AVR1, OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OP_AVR1, OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", {"1", "1", "1", "1"}, ""}, From f23a430b2e69ea11dc8c0b402c114f0c1d71de92 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 19 Jul 2024 17:02:01 +0100 Subject: [PATCH 323/422] Improve Rd/Rr modelling in avr_opcodes.c --- src/avr_opcodes.c | 120 +++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index f6aa9b90..99285e31 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -26,30 +26,30 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OP_AVR1, OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OP_AVR2nRC, OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OP_AVR1, OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OP_AVR1, OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OP_AVR1, OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d = 16..31"}, {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OP_AVR1, OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OP_AVR1, OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d=16..31"}, + {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OP_AVR1, OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d = 16..31"}, {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OP_AVR2nRC, OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OP_AVR1, OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", {"1", "1", "1", "1"}, "d = 16..31"}, {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OP_AVR1, OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", {"1", "1", "1", "1"}, "d = 16..31"}, {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OP_AVR1, OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ORI Rd, K"}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ANDI Rd, (0xFF - K)"}, + {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for andi Rd, (0xFF - K); d = 16..31"}, {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x2000, 1, "0010 00d= dddd ====", OP_AVR1, OPCODE_tst, "tst", "Rd", "Test for Zero or Minus", "Rd <-- Rd & Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for AND Rd, Rd"}, - {0xfc00, 0x2400, 1, "0010 01d= dddd ====", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for EOR Rd, Rd"}, - {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for LDI Rd, 0xFF; d = 16...31"}, + {0xfc00, 0x2000, 1, "0010 00r= rrrr ====", OP_AVR1, OPCODE_tst, "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, + {0xfc00, 0x2400, 1, "0010 01d= dddd ====", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, + {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for ldi Rd, 0xFF; d = 16..31"}, {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", {"2", "2", "2", "n/a"}, ""}, - {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..31"}, - {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r=16..23"}, - {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OP_AVR4, OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, - {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OP_AVR4, OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, - {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", {"2", "2", "2", "n/a"}, "r, d = 16..23"}, + {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..31"}, + {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, + {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OP_AVR4, OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, + {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OP_AVR4, OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, + {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OP_AVR_XM, OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", {"n/a", "1/2", "n/a", "n/a"}, ""}, // Branch Instructions @@ -71,54 +71,54 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OP_AVR1, OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OP_AVR1, OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OP_AVR1, OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 0, k (C Carry)"}, - {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OP_AVR1, OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 1, k (Z Zero)"}, - {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OP_AVR1, OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 2, k (N Negative)"}, - {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OP_AVR1, OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OP_AVR1, OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 4, k (S Sign)"}, - {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OP_AVR1, OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 5, k (H Half carry)"}, - {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OP_AVR1, OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 6, k (T Transfer bit)"}, - {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OP_AVR1, OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBS 7, k (I Interrupt enable)"}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, + {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, + {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OP_AVR1, OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 1, k (Z Zero)"}, + {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OP_AVR1, OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 2, k (N Negative)"}, + {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OP_AVR1, OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OP_AVR1, OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 4, k (S Sign)"}, + {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OP_AVR1, OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 5, k (H Half carry)"}, + {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OP_AVR1, OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 6, k (T Transfer bit)"}, + {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OP_AVR1, OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 7, k (I Interrupt enable)"}, {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OP_AVR1, OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 0, k (C Carry)"}, - {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OP_AVR1, OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 1, k (Z Zero)"}, - {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OP_AVR1, OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 2, k (N Negative)"}, - {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OP_AVR1, OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OP_AVR1, OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 4, k (S Sign)"}, - {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OP_AVR1, OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 5, k (H Half carry)"}, - {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OP_AVR1, OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 6, k (T Transfer bit)"}, - {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OP_AVR1, OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for BRBC 7, k (I Interrupt enable)"}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, + {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, + {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OP_AVR1, OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 1, k (Z Zero)"}, + {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OP_AVR1, OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 2, k (N Negative)"}, + {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OP_AVR1, OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 3, k (V Overflow in two's complement)"}, + {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OP_AVR1, OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 4, k (S Sign)"}, + {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OP_AVR1, OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 5, k (H Half carry)"}, + {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OP_AVR1, OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 6, k (T Transfer bit)"}, + {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OP_AVR1, OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 7, k (I Interrupt enable)"}, {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OP_AVR1, OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, // Data Transfer Instructions {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OP_AVR1, OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", {"1", "1", "1", "1"}, ""}, - {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", {"1", "1", "1", "n/a"}, ""}, - {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", {"1", "1", "1", "1"}, "d=16..31"}, + {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", {"1", "1", "1", "n/a"}, "d, r in {0, 2, ..., 30}"}, + {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", {"1", "1", "1", "1"}, "d = 16..31"}, {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"2", "3", "3", "2"}, ""}, {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts)"}, {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OP_AVR2, OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", {"2", "2", "2", "1/2"}, ""}, {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OP_AVR2, OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", {"2", "2", "2", "2/3"}, ""}, {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OP_AVR2, OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", {"2", "3", "2", "2/3"}, ""}, - {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OP_AVR2, OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", {"2", "2", "2", "1/2"}, "alias for LDD Rd, Y+0"}, + {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OP_AVR2, OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Y+0"}, {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OP_AVR2, OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", {"2", "2", "2", "2/3"}, ""}, {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OP_AVR2, OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", {"2", "3", "2", "2/3"}, ""}, {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OP_AVR2nRC, OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", {"2", "3", "2", "n/a"}, ""}, - {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OP_AVR1, OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", {"2", "2", "2", "1/2"}, "alias for LDD Rd,Z+0"}, + {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OP_AVR1, OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", {"2", "2", "2", "1/2"}, "alias for ldd Rd,Z+0"}, {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OP_AVR1, OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"2", "2", "2", "2/3"}, ""}, {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OP_AVR1, OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", {"2", "3", "2", "2/3"}, ""}, {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OP_AVR2nRC, OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", {"2", "3", "2", "n/a"}, ""}, - {0xfe0f, 0x9200, 2, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", {"2", "2", "2", "1"}, ""}, - {0xf800, 0xa800, 1, "1010 1kkk dddd kkkk", OP_AVR_RC, OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rd", "None", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts)"}, + {0xfe0f, 0x9200, 2, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "None", {"2", "2", "2", "1"}, ""}, + {0xf800, 0xa800, 1, "1010 1kkk rrrr kkkk", OP_AVR_RC, OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "None", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts)"}, {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OP_AVR2, OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OP_AVR2, OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OP_AVR2, OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, - {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OP_AVR2, OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for STD Y+0, Rr"}, + {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OP_AVR2, OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for std Y+0, Rr"}, {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OP_AVR2, OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OP_AVR2, OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OP_AVR2nRC, OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, - {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OP_AVR1, OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for STD Z+0, Rr"}, + {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OP_AVR1, OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for std Z+0, Rr"}, {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OP_AVR1, OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OP_AVR1, OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", {"2", "2", "1", "1"}, ""}, {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OP_AVR2nRC, OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, @@ -132,7 +132,7 @@ const AVR_opcode_data avr_opcodes[164] = { {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OP_AVR_XTM, OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", {"n/a", "-", "-", "n/a"}, ""}, {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In from I/O Location", "Rd <-- I/O(A)", "None", {"1", "1", "1", "1"}, ""}, {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out to I/O Location", "I/O(A) <-- Rr", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x920f, 1, "1001 001d dddd 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", {"2", "1", "1", "1"}, ""}, + {0xfe0f, 0x920f, 1, "1001 001r rrrr 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", {"2", "2", "2", "3"}, ""}, {0xfe0f, 0x9204, 1, "1001 001d dddd 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, {0xfe0f, 0x9205, 1, "1001 001d dddd 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, @@ -140,9 +140,9 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfe0f, 0x9207, 1, "1001 001d dddd 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions - {0xfc00, 0x0c00, 1, "0000 11d= dddd ====", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADD Rd, Rd"}, + {0xfc00, 0x0c00, 1, "0000 11d= dddd ====", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for add Rd, Rd"}, {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OP_AVR1, OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x1c00, 1, "0001 11d= dddd ====", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for ADC Rd, Rd"}, + {0xfc00, 0x1c00, 1, "0001 11d= dddd ====", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for adc Rd, Rd"}, {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OP_AVR1, OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OP_AVR1, OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OP_AVR1, OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", {"1", "1", "1", "1"}, ""}, @@ -150,24 +150,24 @@ const AVR_opcode_data avr_opcodes[164] = { {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OP_AVR1, OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OP_AVR1, OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", {"2", "1", "1", "1"}, ""}, {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OP_AVR1, OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", {"2", "1", "1", "1"}, ""}, - {0xfe08, 0xfa00, 1, "1111 101d dddd 0bbb", OP_AVR1, OPCODE_bst, "bst", "Rd, b", "Bit Store from Register to T", "T <-- Rd(b)", "T", {"1", "1", "1", "1"}, ""}, + {0xfe08, 0xfa00, 1, "1111 101r rrrr 0bbb", OP_AVR1, OPCODE_bst, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", {"1", "1", "1", "1"}, ""}, {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OP_AVR1, OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, - {0xffff, 0x9408, 1, "1001 0100 0000 1000", OP_AVR1, OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", {"1", "1", "1", "1"}, "alias for BSET 0"}, - {0xffff, 0x9488, 1, "1001 0100 1000 1000", OP_AVR1, OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", {"1", "1", "1", "1"}, "alias for BCLR 0"}, - {0xffff, 0x9428, 1, "1001 0100 0010 1000", OP_AVR1, OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", {"1", "1", "1", "1"}, "alias for BSET 2"}, - {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OP_AVR1, OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", {"1", "1", "1", "1"}, "alias for BCLR 2"}, - {0xffff, 0x9418, 1, "1001 0100 0001 1000", OP_AVR1, OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", {"1", "1", "1", "1"}, "alias for BSET 1"}, - {0xffff, 0x9498, 1, "1001 0100 1001 1000", OP_AVR1, OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", {"1", "1", "1", "1"}, "alias for BCLR 1"}, - {0xffff, 0x9478, 1, "1001 0100 0111 1000", OP_AVR1, OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", {"1", "1", "1", "1"}, "alias for BSET 7"}, - {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OP_AVR1, OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", {"1", "1", "1", "1"}, "alias for BCLR 7"}, - {0xffff, 0x9448, 1, "1001 0100 0100 1000", OP_AVR1, OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", {"1", "1", "1", "1"}, "alias for BSET 4"}, - {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OP_AVR1, OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", {"1", "1", "1", "1"}, "alias for BCLR 4"}, - {0xffff, 0x9438, 1, "1001 0100 0011 1000", OP_AVR1, OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", {"1", "1", "1", "1"}, "alias for BSET 3"}, - {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OP_AVR1, OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", {"1", "1", "1", "1"}, "alias for BCLR 3"}, - {0xffff, 0x9468, 1, "1001 0100 0110 1000", OP_AVR1, OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", {"1", "1", "1", "1"}, "alias for BSET 6"}, - {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OP_AVR1, OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", {"1", "1", "1", "1"}, "alias for BCLR 6"}, - {0xffff, 0x9458, 1, "1001 0100 0101 1000", OP_AVR1, OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", {"1", "1", "1", "1"}, "alias for BSET 5"}, - {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OP_AVR1, OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", {"1", "1", "1", "1"}, "alias for BCLR 5"}, + {0xffff, 0x9408, 1, "1001 0100 0000 1000", OP_AVR1, OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", {"1", "1", "1", "1"}, "alias for bset 0"}, + {0xffff, 0x9488, 1, "1001 0100 1000 1000", OP_AVR1, OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", {"1", "1", "1", "1"}, "alias for bclr 0"}, + {0xffff, 0x9428, 1, "1001 0100 0010 1000", OP_AVR1, OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", {"1", "1", "1", "1"}, "alias for bset 2"}, + {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OP_AVR1, OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", {"1", "1", "1", "1"}, "alias for bclr 2"}, + {0xffff, 0x9418, 1, "1001 0100 0001 1000", OP_AVR1, OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", {"1", "1", "1", "1"}, "alias for bset 1"}, + {0xffff, 0x9498, 1, "1001 0100 1001 1000", OP_AVR1, OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", {"1", "1", "1", "1"}, "alias for bclr 1"}, + {0xffff, 0x9478, 1, "1001 0100 0111 1000", OP_AVR1, OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", {"1", "1", "1", "1"}, "alias for bset 7"}, + {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OP_AVR1, OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", {"1", "1", "1", "1"}, "alias for bclr 7"}, + {0xffff, 0x9448, 1, "1001 0100 0100 1000", OP_AVR1, OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", {"1", "1", "1", "1"}, "alias for bset 4"}, + {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OP_AVR1, OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", {"1", "1", "1", "1"}, "alias for bclr 4"}, + {0xffff, 0x9438, 1, "1001 0100 0011 1000", OP_AVR1, OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", {"1", "1", "1", "1"}, "alias for bset 3"}, + {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OP_AVR1, OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", {"1", "1", "1", "1"}, "alias for bclr 3"}, + {0xffff, 0x9468, 1, "1001 0100 0110 1000", OP_AVR1, OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", {"1", "1", "1", "1"}, "alias for bset 6"}, + {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OP_AVR1, OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", {"1", "1", "1", "1"}, "alias for bclr 6"}, + {0xffff, 0x9458, 1, "1001 0100 0101 1000", OP_AVR1, OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", {"1", "1", "1", "1"}, "alias for bset 5"}, + {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OP_AVR1, OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", {"1", "1", "1", "1"}, "alias for bclr 5"}, // MCU Control Instructions {0xffff, 0x9598, 1, "1001 0101 1001 1000", OP_AVR1, OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", {"-", "-", "-", "-"}, "not available on all parts"}, @@ -193,7 +193,7 @@ const AVR_opcode_data avr_opcodes[164] = { {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR_ILL, OPCODE_x_ijmp, "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, "xxx != 000"}, {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_ILL, OPCODE_x_eijmp, "u/eijmp", "EIND:Z", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, "xxx != 000"}, {0xfe08, 0xf808, 1, "1111 100d dddd 1bbb", OP_AVR_ILL, OPCODE_x_bld, "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, - {0xfe08, 0xfa08, 1, "1111 101d dddd 1bbb", OP_AVR_ILL, OPCODE_x_bst, "u/bst", "Rd, b", "alt Bit Store from Register to T", "T <-- Rd(b)", "T", {"1", "1", "1", "1"}, ""}, + {0xfe08, 0xfa08, 1, "1111 101r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_bst, "u/bst", "Rr, b", "alt Bit Store from Register to T", "T <-- Rr(b)", "T", {"1", "1", "1", "1"}, ""}, {0xfe08, 0xfc08, 1, "1111 110r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_sbrc, "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, {0xfe08, 0xfe08, 1, "1111 111r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_sbrs, "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, }; From 8941e0d636c546db03b2a795aa21781ef14bc1e3 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 19 Jul 2024 17:40:09 +0100 Subject: [PATCH 324/422] Give weird address the letter a for reduced-core lds/sts --- src/avr_opcodes.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 99285e31..fa2fea97 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -35,15 +35,15 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OP_AVR1, OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", {"1", "1", "1", "1"}, "d = 16..31"}, {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OP_AVR1, OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- $FF-Rd", "Z,C,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- $00-Rd", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- 0xff - Rd", "Z,C,N,V,S", {"1", "1", "1", "1"}, ""}, + {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- 0x00 - Rd", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & ($FFh-K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for andi Rd, (0xFF - K); d = 16..31"}, + {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for andi Rd, (0xff - K); d = 16..31"}, {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, {0xfc00, 0x2000, 1, "0010 00r= rrrr ====", OP_AVR1, OPCODE_tst, "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, {0xfc00, 0x2400, 1, "0010 01d= dddd ====", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, - {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- $FF", "None", {"1", "1", "1", "1"}, "alias for ldi Rd, 0xFF; d = 16..31"}, + {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- 0xff", "None", {"1", "1", "1", "1"}, "alias for ldi Rd, 0xff; d = 16..31"}, {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", {"2", "2", "2", "n/a"}, ""}, {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..31"}, {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, @@ -97,7 +97,7 @@ const AVR_opcode_data avr_opcodes[164] = { {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", {"1", "1", "1", "n/a"}, "d, r in {0, 2, ..., 30}"}, {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", {"1", "1", "1", "1"}, "d = 16..31"}, {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"2", "3", "3", "2"}, ""}, - {0xf800, 0xa000, 1, "1010 0kkk dddd kkkk", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts)"}, + {0xf800, 0xa000, 1, "1010 0aaa dddd aaaa", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "None", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OP_AVR2, OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", {"2", "2", "2", "1/2"}, ""}, {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OP_AVR2, OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", {"2", "2", "2", "2/3"}, ""}, {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OP_AVR2, OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", {"2", "3", "2", "2/3"}, ""}, @@ -110,7 +110,7 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OP_AVR1, OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", {"2", "3", "2", "2/3"}, ""}, {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OP_AVR2nRC, OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", {"2", "3", "2", "n/a"}, ""}, {0xfe0f, 0x9200, 2, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "None", {"2", "2", "2", "1"}, ""}, - {0xf800, 0xa800, 1, "1010 1kkk rrrr kkkk", OP_AVR_RC, OPCODE_sts_rc, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "None", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts)"}, + {0xf800, 0xa800, 1, "1010 1aaa rrrr aaaa", OP_AVR_RC, OPCODE_sts_rc, "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "None", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OP_AVR2, OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OP_AVR2, OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", {"2", "1", "1", "1"}, ""}, {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OP_AVR2, OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, @@ -136,7 +136,7 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", {"2", "2", "2", "3"}, ""}, {0xfe0f, 0x9204, 1, "1001 001d dddd 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, {0xfe0f, 0x9205, 1, "1001 001d dddd 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9206, 1, "1001 001d dddd 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- ($FF - Rd) & (Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {0xfe0f, 0x9206, 1, "1001 001d dddd 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- (0xff - Rd) & (Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, {0xfe0f, 0x9207, 1, "1001 001d dddd 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions From 68c700c4f5f326f1d9c3fc5e8dde3d7c620e0b8c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 19 Jul 2024 20:37:23 +0100 Subject: [PATCH 325/422] Correct ijmp/eijmp operand in avr_opcodes.c --- src/avr_opcodes.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index fa2fea97..31407f9e 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -52,14 +52,14 @@ const AVR_opcode_data avr_opcodes[164] = { {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OP_AVR_XM, OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", {"n/a", "1/2", "n/a", "n/a"}, ""}, - // Branch Instructions + // Branch Instructions (and compare) {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OP_AVR1, OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", {"2", "2", "2", "2"}, ""}, {0xffff, 0x9409, 1, "1001 0100 0000 1001", OP_AVR2, OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, ""}, - {0xffff, 0x9419, 1, "1001 0100 0001 1001", OP_AVR_XL, OPCODE_eijmp, "eijmp", "EIND:Z", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, ""}, + {0xffff, 0x9419, 1, "1001 0100 0001 1001", OP_AVR_XL, OPCODE_eijmp, "eijmp", "-", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, ""}, {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", {"3", "3", "3", "n/a"}, ""}, {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OP_AVR1, OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", {"3/4", "2/3", "2/3", "3"}, ""}, {0xffff, 0x9509, 1, "1001 0101 0000 1001", OP_AVR2, OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, ""}, - {0xffff, 0x9519, 1, "1001 0101 0001 1001", OP_AVR_XL, OPCODE_eicall, "eicall", "EIND:Z", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, ""}, + {0xffff, 0x9519, 1, "1001 0101 0001 1001", OP_AVR_XL, OPCODE_eicall, "eicall", "-", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, ""}, {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", {"4/5", "3/4", "3/4", "n/a"}, ""}, {0xffff, 0x9508, 1, "1001 0101 0000 1000", OP_AVR1, OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, ""}, {0xffff, 0x9518, 1, "1001 0101 0001 1000", OP_AVR1, OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, ""}, @@ -184,14 +184,14 @@ const AVR_opcode_data avr_opcodes[164] = { {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR_ILL, OPCODE_x_nop_6, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR_ILL, OPCODE_x_nop_7, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR_ILL, OPCODE_x_icall, "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, - {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_ILL, OPCODE_x_eicall, "u/eicall", "EIND:Z", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, "xxx != 000"}, + {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_ILL, OPCODE_x_eicall, "u/eicall", "-", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, "xxx != 000"}, {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR_ILL, OPCODE_x_ret, "u/ret", "-", "alt Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR_ILL, OPCODE_x_reti, "u/reti", "-", "alt Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR_ILL, OPCODE_x_nop_8, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR_ILL, OPCODE_x_nop_9, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR_ILL, OPCODE_x_nop_a, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR_ILL, OPCODE_x_ijmp, "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, "xxx != 000"}, - {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_ILL, OPCODE_x_eijmp, "u/eijmp", "EIND:Z", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, "xxx != 000"}, + {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_ILL, OPCODE_x_eijmp, "u/eijmp", "-", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, "xxx != 000"}, {0xfe08, 0xf808, 1, "1111 100d dddd 1bbb", OP_AVR_ILL, OPCODE_x_bld, "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, {0xfe08, 0xfa08, 1, "1111 101r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_bst, "u/bst", "Rr, b", "alt Bit Store from Register to T", "T <-- Rr(b)", "T", {"1", "1", "1", "1"}, ""}, {0xfe08, 0xfc08, 1, "1111 110r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_sbrc, "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, From 9f439b714a0f23776e5e3657531ac98131b5a8ee Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 20 Jul 2024 13:11:36 +0100 Subject: [PATCH 326/422] Introduce opcode type in avr_opcodes.c --- src/avr_opcodes.c | 656 ++++++++++++++++++++++++++++++++++------------ src/libavrdude.h | 37 ++- 2 files changed, 524 insertions(+), 169 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 31407f9e..674b81e4 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -22,178 +22,506 @@ const AVR_opcode_data avr_opcodes[164] = { // Arithmetic and Logic Instructions - {0xfc00, 0x0c00, 1, "0000 11rd dddd rrrr", OP_AVR1, OPCODE_add, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd+Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x1c00, 1, "0001 11rd dddd rrrr", OP_AVR1, OPCODE_adc, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd+Rr+C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xff00, 0x9600, 1, "1001 0110 KKdd KKKK", OP_AVR2nRC, OPCODE_adiw, "adiw", "Rd, K", "Add Immediate to Word", "Rd <-- Rd+1:Rd+K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, - {0xfc00, 0x1800, 1, "0001 10rd dddd rrrr", OP_AVR1, OPCODE_sub, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd-Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x5000, 1, "0101 KKKK dddd KKKK", OP_AVR1, OPCODE_subi, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd-K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d = 16..31"}, - {0xfc00, 0x0800, 1, "0000 10rd dddd rrrr", OP_AVR1, OPCODE_sbc, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd-Rr-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x4000, 1, "0100 KKKK dddd KKKK", OP_AVR1, OPCODE_sbci, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd-K-C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d = 16..31"}, - {0xff00, 0x9700, 1, "1001 0111 KKdd KKKK", OP_AVR2nRC, OPCODE_sbiw, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd-K", "Z,C,N,V,S", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, - {0xfc00, 0x2000, 1, "0010 00rd dddd rrrr", OP_AVR1, OPCODE_and, "and", "Rd, Rr", "Logical AND", "Rd <-- Rd & Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_andi, "andi", "Rd, K", "Logical AND with Immediate", "Rd <-- Rd & K", "Z,N,V,S", {"1", "1", "1", "1"}, "d = 16..31"}, - {0xfc00, 0x2800, 1, "0010 10rd dddd rrrr", OP_AVR1, OPCODE_or, "or", "Rd, Rr", "Logical OR", "Rd <-- Rd|Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_ori, "ori", "Rd, K", "Logical OR with Immediate", "Rd <-- Rd|K", "Z,N,V,S", {"1", "1", "1", "1"}, "d = 16..31"}, - {0xfc00, 0x2400, 1, "0010 01rd dddd rrrr", OP_AVR1, OPCODE_eor, "eor", "Rd, Rr", "Exclusive OR", "Rd <-- Rd^Rr", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9400, 1, "1001 010d dddd 0000", OP_AVR1, OPCODE_com, "com", "Rd", "One's Complement", "Rd <-- 0xff - Rd", "Z,C,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9401, 1, "1001 010d dddd 0001", OP_AVR1, OPCODE_neg, "neg", "Rd", "Two's Complement", "Rd <-- 0x00 - Rd", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x6000, 1, "0110 KKKK dddd KKKK", OP_AVR1, OPCODE_sbr, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, - {0xf000, 0x7000, 1, "0111 KKKK dddd KKKK", OP_AVR1, OPCODE_cbr, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for andi Rd, (0xff - K); d = 16..31"}, - {0xfe0f, 0x9403, 1, "1001 010d dddd 0011", OP_AVR1, OPCODE_inc, "inc", "Rd", "Increment", "Rd <-- Rd+1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x940a, 1, "1001 010d dddd 1010", OP_AVR1, OPCODE_dec, "dec", "Rd", "Decrement", "Rd <-- Rd-1", "Z,N,V,S", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x2000, 1, "0010 00r= rrrr ====", OP_AVR1, OPCODE_tst, "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, - {0xfc00, 0x2400, 1, "0010 01d= dddd ====", OP_AVR1, OPCODE_clr, "clr", "Rd", "Clear Register", "Rd <-- Rd xor Rd", "Z,N,V,S", {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, - {0xff0f, 0xef0f, 1, "1110 1111 dddd 1111", OP_AVR1, OPCODE_ser, "ser", "Rd", "Set Register", "Rd <-- 0xff", "None", {"1", "1", "1", "1"}, "alias for ldi Rd, 0xff; d = 16..31"}, - {0xfc00, 0x9c00, 1, "1001 11rd dddd rrrr", OP_AVR4, OPCODE_mul, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", {"2", "2", "2", "n/a"}, ""}, - {0xff00, 0x0200, 1, "0000 0010 dddd rrrr", OP_AVR4, OPCODE_muls, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..31"}, - {0xff88, 0x0300, 1, "0000 0011 0ddd 0rrr", OP_AVR4, OPCODE_mulsu, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, - {0xff88, 0x0308, 1, "0000 0011 0ddd 1rrr", OP_AVR4, OPCODE_fmul, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, - {0xff88, 0x0380, 1, "0000 0011 1ddd 0rrr", OP_AVR4, OPCODE_fmuls, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, - {0xff88, 0x0388, 1, "0000 0011 1ddd 1rrr", OP_AVR4, OPCODE_fmulsu, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, - {0xff0f, 0x940b, 1, "1001 0100 KKKK 1011", OP_AVR_XM, OPCODE_des, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", {"n/a", "1/2", "n/a", "n/a"}, ""}, + {OPCODE_add, 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11rd dddd rrrr", OTY_ALBI|OTY_RALL, + "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd + Rr", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, ""}, + {OPCODE_adc, 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, + "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd + Rr + C", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, ""}, + {OPCODE_adiw, 0xff00, 0x9600, 1, OP_AVR2nRC, "1001 0110 KKdd KKKK", OTY_ALBI|OTY_RW24, + "adiw", "Rd, K", "Add Immediate to Word", "Rd+1:Rd <-- Rd+1:Rd + K", "Z,C,N,V,S", + {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, + {OPCODE_sub, 0xfc00, 0x1800, 1, OP_AVR1, "0001 10rd dddd rrrr", OTY_ALBI|OTY_RALL, + "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd - Rr", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, ""}, + {OPCODE_subi, 0xf000, 0x5000, 1, OP_AVR1, "0101 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd - K", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, "d = 16..31"}, + {OPCODE_sbc, 0xfc00, 0x0800, 1, OP_AVR1, "0000 10rd dddd rrrr", OTY_ALBI|OTY_RALL, + "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd - Rr - C", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, ""}, + {OPCODE_sbci, 0xf000, 0x4000, 1, OP_AVR1, "0100 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd - K - C", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, "d = 16..31"}, + {OPCODE_sbiw, 0xff00, 0x9700, 1, OP_AVR2nRC, "1001 0111 KKdd KKKK", OTY_ALBI|OTY_RW24, + "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd - K", "Z,C,N,V,S", + {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, + {OPCODE_and, 0xfc00, 0x2000, 1, OP_AVR1, "0010 00rd dddd rrrr", OTY_ALBI|OTY_RALL, + "and", "Rd, Rr", "Logical And", "Rd <-- Rd & Rr", "Z,N,V,S", + {"1", "1", "1", "1"}, ""}, + {OPCODE_andi, 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + "andi", "Rd, K", "Logical And with Immediate", "Rd <-- Rd & K", "Z,N,V,S", + {"1", "1", "1", "1"}, "d = 16..31"}, + {OPCODE_or, 0xfc00, 0x2800, 1, OP_AVR1, "0010 10rd dddd rrrr", OTY_ALBI|OTY_RALL, + "or", "Rd, Rr", "Logical Or", "Rd <-- Rd | Rr", "Z,N,V,S", + {"1", "1", "1", "1"}, ""}, + {OPCODE_ori, 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + "ori", "Rd, K", "Logical Or with Immediate", "Rd <-- Rd | K", "Z,N,V,S", + {"1", "1", "1", "1"}, "d = 16..31"}, + {OPCODE_eor, 0xfc00, 0x2400, 1, OP_AVR1, "0010 01rd dddd rrrr", OTY_ALBI|OTY_RALL, + "eor", "Rd, Rr", "Exclusive or", "Rd <-- Rd ^ Rr", "Z,N,V,S", + {"1", "1", "1", "1"}, ""}, + {OPCODE_com, 0xfe0f, 0x9400, 1, OP_AVR1, "1001 010d dddd 0000", OTY_ALBI|OTY_RALL, + "com", "Rd", "One's Complement", "Rd <-- 0xff - Rd", "Z,C,N,V,S", + {"1", "1", "1", "1"}, ""}, + {OPCODE_neg, 0xfe0f, 0x9401, 1, OP_AVR1, "1001 010d dddd 0001", OTY_ALBI|OTY_RALL, + "neg", "Rd", "Two's Complement", "Rd <-- 0x00 - Rd", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, ""}, + {OPCODE_sbr, 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, + "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", + {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, + {OPCODE_cbr, 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, + "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "Z,N,V,S", + {"1", "1", "1", "1"}, "alias for andi Rd, (0xff - K); d = 16..31"}, + {OPCODE_inc, 0xfe0f, 0x9403, 1, OP_AVR1, "1001 010d dddd 0011", OTY_ALBI|OTY_RALL, + "inc", "Rd", "Increment", "Rd <-- Rd + 1", "Z,N,V,S", + {"1", "1", "1", "1"}, ""}, + {OPCODE_dec, 0xfe0f, 0x940a, 1, OP_AVR1, "1001 010d dddd 1010", OTY_ALBI|OTY_RALL, + "dec", "Rd", "Decrement", "Rd <-- Rd - 1", "Z,N,V,S", + {"1", "1", "1", "1"}, ""}, + {OPCODE_tst, 0xfc00, 0x2000, 1, OP_AVR1, "0010 00r= rrrr ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "Z,N,V,S", + {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, + {OPCODE_clr, 0xfc00, 0x2400, 1, OP_AVR1, "0010 01d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + "clr", "Rd", "Clear Register", "Rd <-- Rd ^ Rd", "Z,N,V,S", + {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, + {OPCODE_ser, 0xff0f, 0xef0f, 1, OP_AVR1, "1110 1111 dddd 1111", OTY_ALBI|OTY_RUPP, + "ser", "Rd", "Set Register", "Rd <-- 0xff", "None", + {"1", "1", "1", "1"}, "alias for ldi Rd, 0xff; d = 16..31"}, + {OPCODE_mul, 0xfc00, 0x9c00, 1, OP_AVR4, "1001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, + "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", + {"2", "2", "2", "n/a"}, ""}, + {OPCODE_muls, 0xff00, 0x0200, 1, OP_AVR4, "0000 0010 dddd rrrr", OTY_ALBI|OTY_RUPP, + "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", + {"2", "2", "2", "n/a"}, "d, r = 16..31"}, + {OPCODE_mulsu, 0xff88, 0x0300, 1, OP_AVR4, "0000 0011 0ddd 0rrr", OTY_ALBI|OTY_RUPP, + "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", + {"2", "2", "2", "n/a"}, "d, r = 16..23"}, + {OPCODE_fmul, 0xff88, 0x0308, 1, OP_AVR4, "0000 0011 0ddd 1rrr", OTY_ALBI|OTY_RUPP, + "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", + {"2", "2", "2", "n/a"}, "d, r = 16..23"}, + {OPCODE_fmuls, 0xff88, 0x0380, 1, OP_AVR4, "0000 0011 1ddd 0rrr", OTY_ALBI|OTY_RUPP, + "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", + {"2", "2", "2", "n/a"}, "d, r = 16..23"}, + {OPCODE_fmulsu, 0xff88, 0x0388, 1, OP_AVR4, "0000 0011 1ddd 1rrr", OTY_ALBI|OTY_RUPP, + "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", + {"2", "2", "2", "n/a"}, "d, r = 16..23"}, + {OPCODE_des, 0xff0f, 0x940b, 1, OP_AVR_XM, "1001 0100 KKKK 1011", OTY_ALBI, + "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", + {"n/a", "1/2", "n/a", "n/a"}, ""}, // Branch Instructions (and compare) - {0xf000, 0xc000, 1, "1100 kkkk kkkk kkkk", OP_AVR1, OPCODE_rjmp, "rjmp", "k", "Relative Jump", "PC <-- PC+k+1", "None", {"2", "2", "2", "2"}, ""}, - {0xffff, 0x9409, 1, "1001 0100 0000 1001", OP_AVR2, OPCODE_ijmp, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, ""}, - {0xffff, 0x9419, 1, "1001 0100 0001 1001", OP_AVR_XL, OPCODE_eijmp, "eijmp", "-", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, ""}, - {0xfe0e, 0x940c, 2, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_jmp, "jmp", "k", "Jump", "PC <-- k", "None", {"3", "3", "3", "n/a"}, ""}, - {0xf000, 0xd000, 1, "1101 kkkk kkkk kkkk", OP_AVR1, OPCODE_rcall, "rcall", "k", "Relative Call Subroutine", "PC <-- PC+k+1", "None", {"3/4", "2/3", "2/3", "3"}, ""}, - {0xffff, 0x9509, 1, "1001 0101 0000 1001", OP_AVR2, OPCODE_icall, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, ""}, - {0xffff, 0x9519, 1, "1001 0101 0001 1001", OP_AVR_XL, OPCODE_eicall, "eicall", "-", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, ""}, - {0xfe0e, 0x940e, 2, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OP_AVR_M, OPCODE_call, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP-2", "None", {"4/5", "3/4", "3/4", "n/a"}, ""}, - {0xffff, 0x9508, 1, "1001 0101 0000 1000", OP_AVR1, OPCODE_ret, "ret", "-", "Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, ""}, - {0xffff, 0x9518, 1, "1001 0101 0001 1000", OP_AVR1, OPCODE_reti, "reti", "-", "Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, ""}, - {0xfc00, 0x1000, 1, "0001 00rd dddd rrrr", OP_AVR1, OPCODE_cpse, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {0xfc00, 0x1400, 1, "0001 01rd dddd rrrr", OP_AVR1, OPCODE_cp, "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x0400, 1, "0000 01rd dddd rrrr", OP_AVR1, OPCODE_cpc, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, ""}, - {0xf000, 0x3000, 1, "0011 KKKK dddd KKKK", OP_AVR1, OPCODE_cpi, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", {"1", "1", "1", "1"}, "d = 16..31"}, - {0xfe08, 0xfc00, 1, "1111 110r rrrr 0bbb", OP_AVR1, OPCODE_sbrc, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {0xfe08, 0xfe00, 1, "1111 111r rrrr 0bbb", OP_AVR1, OPCODE_sbrs, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {0xff00, 0x9900, 1, "1001 1001 AAAA Abbb", OP_AVR1, OPCODE_sbic, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, - {0xff00, 0x9b00, 1, "1001 1011 AAAA Abbb", OP_AVR1, OPCODE_sbis, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1)PC <-- PC+2or3", "None", {"1-3", "2-4", "1-3", "1/2"}, ""}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brcs, "brcs", "k", "Branch if Carry Set", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, - {0xfc07, 0xf000, 1, "1111 00kk kkkk k000", OP_AVR1, OPCODE_brlo, "brlo", "k", "Branch if Lower", "if(C=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, - {0xfc07, 0xf001, 1, "1111 00kk kkkk k001", OP_AVR1, OPCODE_breq, "breq", "k", "Branch if Equal", "if(Z=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 1, k (Z Zero)"}, - {0xfc07, 0xf002, 1, "1111 00kk kkkk k010", OP_AVR1, OPCODE_brmi, "brmi", "k", "Branch if Minus", "if(N=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 2, k (N Negative)"}, - {0xfc07, 0xf003, 1, "1111 00kk kkkk k011", OP_AVR1, OPCODE_brvs, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf004, 1, "1111 00kk kkkk k100", OP_AVR1, OPCODE_brlt, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 4, k (S Sign)"}, - {0xfc07, 0xf005, 1, "1111 00kk kkkk k101", OP_AVR1, OPCODE_brhs, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 5, k (H Half carry)"}, - {0xfc07, 0xf006, 1, "1111 00kk kkkk k110", OP_AVR1, OPCODE_brts, "brts", "k", "Branch if T Flag Set", "if(T=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 6, k (T Transfer bit)"}, - {0xfc07, 0xf007, 1, "1111 00kk kkkk k111", OP_AVR1, OPCODE_brie, "brie", "k", "Branch if Interrupt Enabled", "if(I=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 7, k (I Interrupt enable)"}, - {0xfc00, 0xf000, 1, "1111 00kk kkkk ksss", OP_AVR1, OPCODE_brbs, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brcc, "brcc", "k", "Branch if Carry Cleared", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, - {0xfc07, 0xf400, 1, "1111 01kk kkkk k000", OP_AVR1, OPCODE_brsh, "brsh", "k", "Branch if Same or Higher", "if(C=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, - {0xfc07, 0xf401, 1, "1111 01kk kkkk k001", OP_AVR1, OPCODE_brne, "brne", "k", "Branch if Not Equal", "if(Z=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 1, k (Z Zero)"}, - {0xfc07, 0xf402, 1, "1111 01kk kkkk k010", OP_AVR1, OPCODE_brpl, "brpl", "k", "Branch if Plus", "if(N=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 2, k (N Negative)"}, - {0xfc07, 0xf403, 1, "1111 01kk kkkk k011", OP_AVR1, OPCODE_brvc, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 3, k (V Overflow in two's complement)"}, - {0xfc07, 0xf404, 1, "1111 01kk kkkk k100", OP_AVR1, OPCODE_brge, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 4, k (S Sign)"}, - {0xfc07, 0xf405, 1, "1111 01kk kkkk k101", OP_AVR1, OPCODE_brhc, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 5, k (H Half carry)"}, - {0xfc07, 0xf406, 1, "1111 01kk kkkk k110", OP_AVR1, OPCODE_brtc, "brtc", "k", "Branch if T Flag Cleared", "if(T=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 6, k (T Transfer bit)"}, - {0xfc07, 0xf407, 1, "1111 01kk kkkk k111", OP_AVR1, OPCODE_brid, "brid", "k", "Branch if Interrupt Disabled", "if(I=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 7, k (I Interrupt enable)"}, - {0xfc00, 0xf400, 1, "1111 01kk kkkk ksss", OP_AVR1, OPCODE_brbc, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0)thenPC <-- PC+k+1", "None", {"1/2", "1/2", "1/2", "1/2"}, ""}, + {OPCODE_rjmp, 0xf000, 0xc000, 1, OP_AVR1, "1100 kkkk kkkk kkkk", OTY_RJMI, + "rjmp", "k", "Relative Jump", "PC <-- PC + k + 1", "None", + {"2", "2", "2", "2"}, ""}, + {OPCODE_ijmp, 0xffff, 0x9409, 1, OP_AVR2, "1001 0100 0000 1001", OTY_JMPI, + "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", + {"2", "2", "2", "2"}, ""}, + {OPCODE_eijmp, 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, + "eijmp", "-", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", + {"2", "2", "2", "n/a"}, ""}, + {OPCODE_jmp, 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, + "jmp", "k", "Jump", "PC <-- k", "None", + {"3", "3", "3", "n/a"}, ""}, + {OPCODE_rcall, 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, + "rcall", "k", "Relative Call Subroutine", "PC <-- PC + k + 1", "None", + {"3/4", "2/3", "2/3", "3"}, ""}, + {OPCODE_icall, 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPX, + "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", + {"3/4", "2/3", "2/3", "3"}, ""}, + {OPCODE_eicall, 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, + "eicall", "-", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", + {"4", "3", "3", "n/a"}, ""}, + {OPCODE_call, 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, + "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "None", + {"4/5", "3/4", "3/4", "n/a"}, ""}, + {OPCODE_ret, 0xffff, 0x9508, 1, OP_AVR1, "1001 0101 0000 1000", OTY_JMPX, + "ret", "-", "Subroutine Return", "PC <-- STACK", "None", + {"4/5", "4/5", "4/5", "6"}, ""}, + {OPCODE_reti, 0xffff, 0x9518, 1, OP_AVR1, "1001 0101 0001 1000", OTY_JMPX, + "reti", "-", "Interrupt Return", "PC <-- STACK", "I", + {"4/5", "4/5", "4/5", "6"}, ""}, + {OPCODE_cpse, 0xfc00, 0x1000, 1, OP_AVR1, "0001 00rd dddd rrrr", OTY_SKPI|OTY_RALL, + "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr) PC <-- PC + 2/3", "None", + {"1-3", "1-3", "1-3", "1/2"}, ""}, + {OPCODE_cp, 0xfc00, 0x1400, 1, OP_AVR1, "0001 01rd dddd rrrr", OTY_ALBI|OTY_RALL, + "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, ""}, + {OPCODE_cpc, 0xfc00, 0x0400, 1, OP_AVR1, "0000 01rd dddd rrrr", OTY_ALBI|OTY_RALL, + "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, ""}, + {OPCODE_cpi, 0xf000, 0x3000, 1, OP_AVR1, "0011 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", + {"1", "1", "1", "1"}, "d = 16..31"}, + {OPCODE_sbrc, 0xfe08, 0xfc00, 1, OP_AVR1, "1111 110r rrrr 0bbb", OTY_SKPI|OTY_RALL, + "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "None", + {"1-3", "1-3", "1-3", "1/2"}, ""}, + {OPCODE_sbrs, 0xfe08, 0xfe00, 1, OP_AVR1, "1111 111r rrrr 0bbb", OTY_SKPI|OTY_RALL, + "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "None", + {"1-3", "1-3", "1-3", "1/2"}, ""}, + {OPCODE_sbic, 0xff00, 0x9900, 1, OP_AVR1, "1001 1001 AAAA Abbb", OTY_SKPX, + "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0) PC <-- PC + 2/3", "None", + {"1-3", "2-4", "1-3", "1/2"}, ""}, + {OPCODE_sbis, 0xff00, 0x9b00, 1, OP_AVR1, "1001 1011 AAAA Abbb", OTY_SKPX, + "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1) PC <-- PC + 2/3", "None", + {"1-3", "2-4", "1-3", "1/2"}, ""}, + {OPCODE_brcs, 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI, + "brcs", "k", "Branch if Carry Set", "if(C=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, + {OPCODE_brlo, 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI|OTY_ALIAS, + "brlo", "k", "Branch if Lower", "if(C=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, + {OPCODE_breq, 0xfc07, 0xf001, 1, OP_AVR1, "1111 00kk kkkk k001", OTY_BRAI, + "breq", "k", "Branch if Equal", "if(Z=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 1, k (Z Zero)"}, + {OPCODE_brmi, 0xfc07, 0xf002, 1, OP_AVR1, "1111 00kk kkkk k010", OTY_BRAI, + "brmi", "k", "Branch if Minus", "if(N=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 2, k (N Negative)"}, + {OPCODE_brvs, 0xfc07, 0xf003, 1, OP_AVR1, "1111 00kk kkkk k011", OTY_BRAI, + "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 3, k (V Overflow in two's complement)"}, + {OPCODE_brlt, 0xfc07, 0xf004, 1, OP_AVR1, "1111 00kk kkkk k100", OTY_BRAI, + "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 4, k (S Sign)"}, + {OPCODE_brhs, 0xfc07, 0xf005, 1, OP_AVR1, "1111 00kk kkkk k101", OTY_BRAI, + "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 5, k (H Half carry)"}, + {OPCODE_brts, 0xfc07, 0xf006, 1, OP_AVR1, "1111 00kk kkkk k110", OTY_BRAI, + "brts", "k", "Branch if T Flag Set", "if(T=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 6, k (T Transfer bit)"}, + {OPCODE_brie, 0xfc07, 0xf007, 1, OP_AVR1, "1111 00kk kkkk k111", OTY_BRAI, + "brie", "k", "Branch if Interrupt Enabled", "if(I=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 7, k (I Interrupt enable)"}, + {OPCODE_brbs, 0xfc00, 0xf000, 1, OP_AVR1, "1111 00kk kkkk ksss", OTY_BRAI, + "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, ""}, + {OPCODE_brcc, 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI, + "brcc", "k", "Branch if Carry Cleared", "if(C=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, + {OPCODE_brsh, 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI|OTY_ALIAS, + "brsh", "k", "Branch if Same or Higher", "if(C=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, + {OPCODE_brne, 0xfc07, 0xf401, 1, OP_AVR1, "1111 01kk kkkk k001", OTY_BRAI, + "brne", "k", "Branch if Not Equal", "if(Z=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 1, k (Z Zero)"}, + {OPCODE_brpl, 0xfc07, 0xf402, 1, OP_AVR1, "1111 01kk kkkk k010", OTY_BRAI, + "brpl", "k", "Branch if Plus", "if(N=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 2, k (N Negative)"}, + {OPCODE_brvc, 0xfc07, 0xf403, 1, OP_AVR1, "1111 01kk kkkk k011", OTY_BRAI, + "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 3, k (V Overflow in two's complement)"}, + {OPCODE_brge, 0xfc07, 0xf404, 1, OP_AVR1, "1111 01kk kkkk k100", OTY_BRAI, + "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 4, k (S Sign)"}, + {OPCODE_brhc, 0xfc07, 0xf405, 1, OP_AVR1, "1111 01kk kkkk k101", OTY_BRAI, + "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 5, k (H Half carry)"}, + {OPCODE_brtc, 0xfc07, 0xf406, 1, OP_AVR1, "1111 01kk kkkk k110", OTY_BRAI, + "brtc", "k", "Branch if T Flag Cleared", "if(T=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 6, k (T Transfer bit)"}, + {OPCODE_brid, 0xfc07, 0xf407, 1, OP_AVR1, "1111 01kk kkkk k111", OTY_BRAI, + "brid", "k", "Branch if Interrupt Disabled", "if(I=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 7, k (I Interrupt enable)"}, + {OPCODE_brbc, 0xfc00, 0xf400, 1, OP_AVR1, "1111 01kk kkkk ksss", OTY_BRAI, + "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0) then PC <-- PC + k + 1", "None", + {"1/2", "1/2", "1/2", "1/2"}, ""}, // Data Transfer Instructions - {0xfc00, 0x2c00, 1, "0010 11rd dddd rrrr", OP_AVR1, OPCODE_mov, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", {"1", "1", "1", "1"}, ""}, - {0xff00, 0x0100, 1, "0000 0001 dddd rrrr", OP_AVR25, OPCODE_movw, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", {"1", "1", "1", "n/a"}, "d, r in {0, 2, ..., 30}"}, - {0xf000, 0xe000, 1, "1110 KKKK dddd KKKK", OP_AVR1, OPCODE_ldi, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", {"1", "1", "1", "1"}, "d = 16..31"}, - {0xfe0f, 0x9000, 2, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_lds, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", {"2", "3", "3", "2"}, ""}, - {0xf800, 0xa000, 1, "1010 0aaa dddd aaaa", OP_AVR_RC, OPCODE_lds_rc, "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "None", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, - {0xfe0f, 0x900c, 1, "1001 000d dddd 1100", OP_AVR2, OPCODE_ld_1, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", {"2", "2", "2", "1/2"}, ""}, - {0xfe0f, 0x900d, 1, "1001 000d dddd 1101", OP_AVR2, OPCODE_ld_2, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X) X <-- X+1", "None", {"2", "2", "2", "2/3"}, ""}, - {0xfe0f, 0x900e, 1, "1001 000d dddd 1110", OP_AVR2, OPCODE_ld_3, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X-1, <-- X-1 Rd <-- (X) <-- (X)", "None", {"2", "3", "2", "2/3"}, ""}, - {0xfe0f, 0x8008, 1, "1000 000d dddd 1000", OP_AVR2, OPCODE_ld_4, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Y+0"}, - {0xfe0f, 0x9009, 1, "1001 000d dddd 1001", OP_AVR2, OPCODE_ld_5, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y) Y <-- Y+1", "None", {"2", "2", "2", "2/3"}, ""}, - {0xfe0f, 0x900a, 1, "1001 000d dddd 1010", OP_AVR2, OPCODE_ld_6, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y-1 Rd <-- (Y)", "None", {"2", "3", "2", "2/3"}, ""}, - {0xd208, 0x8008, 1, "10q0 qq0d dddd 1qqq", OP_AVR2nRC, OPCODE_ldd_1, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", {"2", "3", "2", "n/a"}, ""}, - {0xfe0f, 0x8000, 1, "1000 000d dddd 0000", OP_AVR1, OPCODE_ld_7, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", {"2", "2", "2", "1/2"}, "alias for ldd Rd,Z+0"}, - {0xfe0f, 0x9001, 1, "1001 000d dddd 0001", OP_AVR1, OPCODE_ld_8, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"2", "2", "2", "2/3"}, ""}, - {0xfe0f, 0x9002, 1, "1001 000d dddd 0010", OP_AVR1, OPCODE_ld_9, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z-1, Rd <-- (Z)", "None", {"2", "3", "2", "2/3"}, ""}, - {0xd208, 0x8000, 1, "10q0 qq0d dddd 0qqq", OP_AVR2nRC, OPCODE_ldd_2, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", {"2", "3", "2", "n/a"}, ""}, - {0xfe0f, 0x9200, 2, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OP_AVR2nRC, OPCODE_sts, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "None", {"2", "2", "2", "1"}, ""}, - {0xf800, 0xa800, 1, "1010 1aaa rrrr aaaa", OP_AVR_RC, OPCODE_sts_rc, "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "None", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, - {0xfe0f, 0x920c, 1, "1001 001r rrrr 1100", OP_AVR2, OPCODE_st_1, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x920d, 1, "1001 001r rrrr 1101", OP_AVR2, OPCODE_st_2, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X+1", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x920e, 1, "1001 001r rrrr 1110", OP_AVR2, OPCODE_st_3, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X-1, (X) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, - {0xfe0f, 0x8208, 1, "1000 001r rrrr 1000", OP_AVR2, OPCODE_st_4, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for std Y+0, Rr"}, - {0xfe0f, 0x9209, 1, "1001 001r rrrr 1001", OP_AVR2, OPCODE_st_5, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y+1", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x920a, 1, "1001 001r rrrr 1010", OP_AVR2, OPCODE_st_6, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y-1, (Y) <-- Rr", "None", {"2", "2", "1", "1"}, ""}, - {0xd208, 0x8208, 1, "10q0 qq1r rrrr 1qqq", OP_AVR2nRC, OPCODE_std_1, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, - {0xfe0f, 0x8200, 1, "1000 001r rrrr 0000", OP_AVR1, OPCODE_st_7, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", {"2", "1", "1", "1"}, "alias for std Z+0, Rr"}, - {0xfe0f, 0x9201, 1, "1001 001r rrrr 0001", OP_AVR1, OPCODE_st_8, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr Z <-- Z+1", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x9202, 1, "1001 001r rrrr 0010", OP_AVR1, OPCODE_st_9, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z-1", "None", {"2", "2", "1", "1"}, ""}, - {0xd208, 0x8200, 1, "10q0 qq1r rrrr 0qqq", OP_AVR2nRC, OPCODE_std_2, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", {"2", "2", "1", "n/a"}, ""}, - {0xffff, 0x95c8, 1, "1001 0101 1100 1000", OP_AVR1nRC, OPCODE_lpm_1, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", {"3", "3", "3", "n/a"}, ""}, - {0xfe0f, 0x9004, 1, "1001 000d dddd 0100", OP_AVR25, OPCODE_lpm_2, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", {"3", "3", "3", "n/a"}, ""}, - {0xfe0f, 0x9005, 1, "1001 000d dddd 0101", OP_AVR25, OPCODE_lpm_3, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, - {0xffff, 0x95d8, 1, "1001 0101 1101 1000", OP_AVR_L, OPCODE_elpm_1, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", {"3", "3", "3", "n/a"}, ""}, - {0xfe0f, 0x9006, 1, "1001 000d dddd 0110", OP_AVR_L, OPCODE_elpm_2, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", {"3", "3", "3", "n/a"}, ""}, - {0xfe0f, 0x9007, 1, "1001 000d dddd 0111", OP_AVR_L, OPCODE_elpm_3, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z+1", "None", {"3", "3", "3", "n/a"}, ""}, - {0xffff, 0x95e8, 1, "1001 0101 1110 1000", OP_AVR25, OPCODE_spm, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", {"-", "-", "-", "-"}, ""}, - {0xffff, 0x95f8, 1, "1001 0101 1111 1000", OP_AVR_XTM, OPCODE_spm_zz, "spm", "Z+", "Store Program Memory and Post- Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z+2", "None", {"n/a", "-", "-", "n/a"}, ""}, - {0xf800, 0xb000, 1, "1011 0AAd dddd AAAA", OP_AVR1, OPCODE_in, "in", "Rd, A", "In from I/O Location", "Rd <-- I/O(A)", "None", {"1", "1", "1", "1"}, ""}, - {0xf800, 0xb800, 1, "1011 1AAr rrrr AAAA", OP_AVR1, OPCODE_out, "out", "A, Rr", "Out to I/O Location", "I/O(A) <-- Rr", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x920f, 1, "1001 001r rrrr 1111", OP_AVR2, OPCODE_push, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", {"2", "1", "1", "1"}, ""}, - {0xfe0f, 0x900f, 1, "1001 000d dddd 1111", OP_AVR2, OPCODE_pop, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", {"2", "2", "2", "3"}, ""}, - {0xfe0f, 0x9204, 1, "1001 001d dddd 0100", OP_AVR_XM, OPCODE_xch, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9205, 1, "1001 001d dddd 0101", OP_AVR_XM, OPCODE_las, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd|(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9206, 1, "1001 001d dddd 0110", OP_AVR_XM, OPCODE_lac, "lac", "Z, Rd", "Load and Clear", "(Z) <-- (0xff - Rd) & (Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, - {0xfe0f, 0x9207, 1, "1001 001d dddd 0111", OP_AVR_XM, OPCODE_lat, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd^(Z), Rd <-- (Z)", "None", {"n/a", "1", "n/a", "n/a"}, ""}, + {OPCODE_mov, 0xfc00, 0x2c00, 1, OP_AVR1, "0010 11rd dddd rrrr", OTY_XFRI|OTY_RALL, + "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_movw, 0xff00, 0x0100, 1, OP_AVR25, "0000 0001 dddd rrrr", OTY_XFRI|OTY_REVN, + "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", + {"1", "1", "1", "n/a"}, "d, r in {0, 2, ..., 30}"}, + {OPCODE_ldi, 0xf000, 0xe000, 1, OP_AVR1, "1110 KKKK dddd KKKK", OTY_XFRI|OTY_RUPP, + "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", + {"1", "1", "1", "1"}, "d = 16..31"}, + {OPCODE_lds, 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, + "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", + {"2", "3", "3", "2"}, ""}, + {OPCODE_lds_rc, 0xf800, 0xa000, 1, OP_AVR_RC, "1010 0aaa dddd aaaa", OTY_XFRX|OTY_RUPP, + "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "None", + {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, + {OPCODE_ld_1, 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, + "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", + {"2", "2", "2", "1/2"}, ""}, + {OPCODE_ld_2, 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL, + "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X), X <-- X + 1", "None", + {"2", "2", "2", "2/3"}, ""}, + {OPCODE_ld_3, 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL, + "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X - 1, Rd <-- (X)", "None", + {"2", "3", "2", "2/3"}, ""}, + {OPCODE_ld_4, 0xfe0f, 0x8008, 1, OP_AVR2, "1000 000d dddd 1000", OTY_XFRX|OTY_RALL, + "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", + {"2", "2", "2", "1/2"}, "alias for ldd Rd, Y+0"}, + {OPCODE_ld_5, 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL, + "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y), Y <-- Y + 1", "None", + {"2", "2", "2", "2/3"}, ""}, + {OPCODE_ld_6, 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL, + "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y - 1 Rd <-- (Y)", "None", + {"2", "3", "2", "2/3"}, ""}, + {OPCODE_ldd_1, 0xd208, 0x8008, 1, OP_AVR2nRC, "10q0 qq0d dddd 1qqq", OTY_XFRX|OTY_RALL, + "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", + {"2", "3", "2", "n/a"}, ""}, + {OPCODE_ld_7, 0xfe0f, 0x8000, 1, OP_AVR1, "1000 000d dddd 0000", OTY_XFRX|OTY_RALL, + "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", + {"2", "2", "2", "1/2"}, "alias for ldd Rd, Z+0"}, + {OPCODE_ld_8, 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL, + "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z + 1", "None", + {"2", "2", "2", "2/3"}, ""}, + {OPCODE_ld_9, 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL, + "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z - 1, Rd <-- (Z)", "None", + {"2", "3", "2", "2/3"}, ""}, + {OPCODE_ldd_2, 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, + "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", + {"2", "3", "2", "n/a"}, ""}, + {OPCODE_sts, 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, + "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "None", + {"2", "2", "2", "1"}, ""}, + {OPCODE_sts_rc, 0xf800, 0xa800, 1, OP_AVR_RC, "1010 1aaa rrrr aaaa", OTY_XFRX|OTY_RUPP, + "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "None", + {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, + {OPCODE_st_1, 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, + "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", + {"2", "1", "1", "1"}, ""}, + {OPCODE_st_2, 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL, + "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X + 1", "None", + {"2", "1", "1", "1"}, ""}, + {OPCODE_st_3, 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL, + "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X - 1, (X) <-- Rr", "None", + {"2", "2", "1", "1"}, ""}, + {OPCODE_st_4, 0xfe0f, 0x8208, 1, OP_AVR2, "1000 001r rrrr 1000", OTY_XFRX|OTY_RALL, + "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", + {"2", "1", "1", "1"}, "alias for std Y+0, Rr"}, + {OPCODE_st_5, 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL, + "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y + 1", "None", + {"2", "1", "1", "1"}, ""}, + {OPCODE_st_6, 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL, + "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y - 1, (Y) <-- Rr", "None", + {"2", "2", "1", "1"}, ""}, + {OPCODE_std_1, 0xd208, 0x8208, 1, OP_AVR2nRC, "10q0 qq1r rrrr 1qqq", OTY_XFRX|OTY_RALL, + "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", + {"2", "2", "1", "n/a"}, ""}, + {OPCODE_st_7, 0xfe0f, 0x8200, 1, OP_AVR1, "1000 001r rrrr 0000", OTY_XFRX|OTY_RALL, + "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", + {"2", "1", "1", "1"}, "alias for std Z+0, Rr"}, + {OPCODE_st_8, 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL, + "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr, Z <-- Z + 1", "None", + {"2", "1", "1", "1"}, ""}, + {OPCODE_st_9, 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL, + "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z - 1, (Z) <-- Rr", "None", + {"2", "2", "1", "1"}, ""}, + {OPCODE_std_2, 0xd208, 0x8200, 1, OP_AVR2nRC, "10q0 qq1r rrrr 0qqq", OTY_XFRX|OTY_RALL, + "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", + {"2", "2", "1", "n/a"}, ""}, + {OPCODE_lpm_1, 0xffff, 0x95c8, 1, OP_AVR1nRC, "1001 0101 1100 1000", OTY_XFRX, + "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", + {"3", "3", "3", "n/a"}, ""}, + {OPCODE_lpm_2, 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, + "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", + {"3", "3", "3", "n/a"}, ""}, + {OPCODE_lpm_3, 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL, + "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z + 1", "None", + {"3", "3", "3", "n/a"}, ""}, + {OPCODE_elpm_1, 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, + "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", + {"3", "3", "3", "n/a"}, ""}, + {OPCODE_elpm_2, 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, + "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", + {"3", "3", "3", "n/a"}, ""}, + {OPCODE_elpm_3, 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL, + "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "None", + {"3", "3", "3", "n/a"}, ""}, + {OPCODE_spm, 0xffff, 0x95e8, 1, OP_AVR25, "1001 0101 1110 1000", OTY_XFRX, + "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", + {"-", "-", "-", "-"}, ""}, + {OPCODE_spm_zz, 0xffff, 0x95f8, 1, OP_AVR_XTM, "1001 0101 1111 1000", OTY_XFRX, + "spm", "Z+", "Store Program Memory and Post-Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z + 2", "None", + {"n/a", "-", "-", "n/a"}, ""}, + {OPCODE_in, 0xf800, 0xb000, 1, OP_AVR1, "1011 0AAd dddd AAAA", OTY_XFRX|OTY_RALL, + "in", "Rd, A", "In from I/O Location", "Rd <-- I/O(A)", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_out, 0xf800, 0xb800, 1, OP_AVR1, "1011 1AAr rrrr AAAA", OTY_XFRX|OTY_RALL, + "out", "A, Rr", "Out to I/O Location", "I/O(A) <-- Rr", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_push, 0xfe0f, 0x920f, 1, OP_AVR2, "1001 001r rrrr 1111", OTY_XFRX|OTY_RALL, + "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", + {"2", "1", "1", "1"}, ""}, + {OPCODE_pop, 0xfe0f, 0x900f, 1, OP_AVR2, "1001 000d dddd 1111", OTY_XFRX|OTY_RALL, + "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", + {"2", "2", "2", "3"}, ""}, + {OPCODE_xch, 0xfe0f, 0x9204, 1, OP_AVR_XM, "1001 001d dddd 0100", OTY_XFRX|OTY_RALL, + "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", + {"n/a", "1", "n/a", "n/a"}, ""}, + {OPCODE_las, 0xfe0f, 0x9205, 1, OP_AVR_XM, "1001 001d dddd 0101", OTY_ALBX|OTY_RALL, + "las", "Z, Rd", "Load and Set", "(Z) <-- Rd | (Z), Rd <-- (Z)", "None", + {"n/a", "1", "n/a", "n/a"}, ""}, + {OPCODE_lac, 0xfe0f, 0x9206, 1, OP_AVR_XM, "1001 001d dddd 0110", OTY_ALBX|OTY_RALL, + "lac", "Z, Rd", "Load and Clear", "(Z) <-- (0xff - Rd) & (Z), Rd <-- (Z)", "None", + {"n/a", "1", "n/a", "n/a"}, ""}, + {OPCODE_lat, 0xfe0f, 0x9207, 1, OP_AVR_XM, "1001 001d dddd 0111", OTY_ALBX|OTY_RALL, + "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd ^ (Z), Rd <-- (Z)", "None", + {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions - {0xfc00, 0x0c00, 1, "0000 11d= dddd ====", OP_AVR1, OPCODE_lsl, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for add Rd, Rd"}, - {0xfe0f, 0x9406, 1, "1001 010d dddd 0110", OP_AVR1, OPCODE_lsr, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, - {0xfc00, 0x1c00, 1, "0001 11d= dddd ====", OP_AVR1, OPCODE_rol, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", {"1", "1", "1", "1"}, "alias for adc Rd, Rd"}, - {0xfe0f, 0x9407, 1, "1001 010d dddd 0111", OP_AVR1, OPCODE_ror, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9405, 1, "1001 010d dddd 0101", OP_AVR1, OPCODE_asr, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9402, 1, "1001 010d dddd 0010", OP_AVR1, OPCODE_swap, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", {"1", "1", "1", "1"}, ""}, - {0xff8f, 0x9408, 1, "1001 0100 0sss 1000", OP_AVR1, OPCODE_bset, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", {"1", "1", "1", "1"}, ""}, - {0xff8f, 0x9488, 1, "1001 0100 1sss 1000", OP_AVR1, OPCODE_bclr, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, - {0xff00, 0x9a00, 1, "1001 1010 AAAA Abbb", OP_AVR1, OPCODE_sbi, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", {"2", "1", "1", "1"}, ""}, - {0xff00, 0x9800, 1, "1001 1000 AAAA Abbb", OP_AVR1, OPCODE_cbi, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", {"2", "1", "1", "1"}, ""}, - {0xfe08, 0xfa00, 1, "1111 101r rrrr 0bbb", OP_AVR1, OPCODE_bst, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", {"1", "1", "1", "1"}, ""}, - {0xfe08, 0xf800, 1, "1111 100d dddd 0bbb", OP_AVR1, OPCODE_bld, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, - {0xffff, 0x9408, 1, "1001 0100 0000 1000", OP_AVR1, OPCODE_sec, "sec", "-", "Set Carry", "C <-- 1", "C", {"1", "1", "1", "1"}, "alias for bset 0"}, - {0xffff, 0x9488, 1, "1001 0100 1000 1000", OP_AVR1, OPCODE_clc, "clc", "-", "Clear Carry", "C <-- 0", "C", {"1", "1", "1", "1"}, "alias for bclr 0"}, - {0xffff, 0x9428, 1, "1001 0100 0010 1000", OP_AVR1, OPCODE_sen, "sen", "-", "Set Negative Flag", "N <-- 1", "N", {"1", "1", "1", "1"}, "alias for bset 2"}, - {0xffff, 0x94a8, 1, "1001 0100 1010 1000", OP_AVR1, OPCODE_cln, "cln", "-", "Clear Negative Flag", "N <-- 0", "N", {"1", "1", "1", "1"}, "alias for bclr 2"}, - {0xffff, 0x9418, 1, "1001 0100 0001 1000", OP_AVR1, OPCODE_sez, "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", {"1", "1", "1", "1"}, "alias for bset 1"}, - {0xffff, 0x9498, 1, "1001 0100 1001 1000", OP_AVR1, OPCODE_clz, "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", {"1", "1", "1", "1"}, "alias for bclr 1"}, - {0xffff, 0x9478, 1, "1001 0100 0111 1000", OP_AVR1, OPCODE_sei, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", {"1", "1", "1", "1"}, "alias for bset 7"}, - {0xffff, 0x94f8, 1, "1001 0100 1111 1000", OP_AVR1, OPCODE_cli, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", {"1", "1", "1", "1"}, "alias for bclr 7"}, - {0xffff, 0x9448, 1, "1001 0100 0100 1000", OP_AVR1, OPCODE_ses, "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", {"1", "1", "1", "1"}, "alias for bset 4"}, - {0xffff, 0x94c8, 1, "1001 0100 1100 1000", OP_AVR1, OPCODE_cls, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", {"1", "1", "1", "1"}, "alias for bclr 4"}, - {0xffff, 0x9438, 1, "1001 0100 0011 1000", OP_AVR1, OPCODE_sev, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", {"1", "1", "1", "1"}, "alias for bset 3"}, - {0xffff, 0x94b8, 1, "1001 0100 1011 1000", OP_AVR1, OPCODE_clv, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", {"1", "1", "1", "1"}, "alias for bclr 3"}, - {0xffff, 0x9468, 1, "1001 0100 0110 1000", OP_AVR1, OPCODE_set, "set", "-", "Set T in SREG", "T <-- 1", "T", {"1", "1", "1", "1"}, "alias for bset 6"}, - {0xffff, 0x94e8, 1, "1001 0100 1110 1000", OP_AVR1, OPCODE_clt, "clt", "-", "Clear T in SREG", "T <-- 0", "T", {"1", "1", "1", "1"}, "alias for bclr 6"}, - {0xffff, 0x9458, 1, "1001 0100 0101 1000", OP_AVR1, OPCODE_seh, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", {"1", "1", "1", "1"}, "alias for bset 5"}, - {0xffff, 0x94d8, 1, "1001 0100 1101 1000", OP_AVR1, OPCODE_clh, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", {"1", "1", "1", "1"}, "alias for bclr 5"}, + {OPCODE_lsl, 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", + {"1", "1", "1", "1"}, "alias for add Rd, Rd"}, + {OPCODE_lsr, 0xfe0f, 0x9406, 1, OP_AVR1, "1001 010d dddd 0110", OTY_ALBI|OTY_RALL, + "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", + {"1", "1", "1", "1"}, ""}, + {OPCODE_rol, 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", + {"1", "1", "1", "1"}, "alias for adc Rd, Rd"}, + {OPCODE_ror, 0xfe0f, 0x9407, 1, OP_AVR1, "1001 010d dddd 0111", OTY_ALBI|OTY_RALL, + "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", + {"1", "1", "1", "1"}, ""}, + {OPCODE_asr, 0xfe0f, 0x9405, 1, OP_AVR1, "1001 010d dddd 0101", OTY_ALBI|OTY_RALL, + "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", + {"1", "1", "1", "1"}, ""}, + {OPCODE_swap, 0xfe0f, 0x9402, 1, OP_AVR1, "1001 010d dddd 0010", OTY_ALBI|OTY_RALL, + "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_bset, 0xff8f, 0x9408, 1, OP_AVR1, "1001 0100 0sss 1000", OTY_ALBX, + "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", + {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, + {OPCODE_bclr, 0xff8f, 0x9488, 1, OP_AVR1, "1001 0100 1sss 1000", OTY_ALBI, + "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", + {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, + {OPCODE_sbi, 0xff00, 0x9a00, 1, OP_AVR1, "1001 1010 AAAA Abbb", OTY_ALBX, + "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", + {"2", "1", "1", "1"}, ""}, + {OPCODE_cbi, 0xff00, 0x9800, 1, OP_AVR1, "1001 1000 AAAA Abbb", OTY_ALBX, + "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", + {"2", "1", "1", "1"}, ""}, + {OPCODE_bst, 0xfe08, 0xfa00, 1, OP_AVR1, "1111 101r rrrr 0bbb", OTY_ALBI|OTY_RALL, + "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", + {"1", "1", "1", "1"}, ""}, + {OPCODE_bld, 0xfe08, 0xf800, 1, OP_AVR1, "1111 100d dddd 0bbb", OTY_ALBI|OTY_RALL, + "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_sec, 0xffff, 0x9408, 1, OP_AVR1, "1001 0100 0000 1000", OTY_ALBI, + "sec", "-", "Set Carry", "C <-- 1", "C", + {"1", "1", "1", "1"}, "alias for bset 0"}, + {OPCODE_clc, 0xffff, 0x9488, 1, OP_AVR1, "1001 0100 1000 1000", OTY_ALBI, + "clc", "-", "Clear Carry", "C <-- 0", "C", + {"1", "1", "1", "1"}, "alias for bclr 0"}, + {OPCODE_sen, 0xffff, 0x9428, 1, OP_AVR1, "1001 0100 0010 1000", OTY_ALBI, + "sen", "-", "Set Negative Flag", "N <-- 1", "N", + {"1", "1", "1", "1"}, "alias for bset 2"}, + {OPCODE_cln, 0xffff, 0x94a8, 1, OP_AVR1, "1001 0100 1010 1000", OTY_ALBI, + "cln", "-", "Clear Negative Flag", "N <-- 0", "N", + {"1", "1", "1", "1"}, "alias for bclr 2"}, + {OPCODE_sez, 0xffff, 0x9418, 1, OP_AVR1, "1001 0100 0001 1000", OTY_ALBI, + "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", + {"1", "1", "1", "1"}, "alias for bset 1"}, + {OPCODE_clz, 0xffff, 0x9498, 1, OP_AVR1, "1001 0100 1001 1000", OTY_ALBI, + "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", + {"1", "1", "1", "1"}, "alias for bclr 1"}, + {OPCODE_sei, 0xffff, 0x9478, 1, OP_AVR1, "1001 0100 0111 1000", OTY_ALBX, + "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", + {"1", "1", "1", "1"}, "alias for bset 7"}, + {OPCODE_cli, 0xffff, 0x94f8, 1, OP_AVR1, "1001 0100 1111 1000", OTY_ALBI, + "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", + {"1", "1", "1", "1"}, "alias for bclr 7"}, + {OPCODE_ses, 0xffff, 0x9448, 1, OP_AVR1, "1001 0100 0100 1000", OTY_ALBI, + "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", + {"1", "1", "1", "1"}, "alias for bset 4"}, + {OPCODE_cls, 0xffff, 0x94c8, 1, OP_AVR1, "1001 0100 1100 1000", OTY_ALBI, + "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", + {"1", "1", "1", "1"}, "alias for bclr 4"}, + {OPCODE_sev, 0xffff, 0x9438, 1, OP_AVR1, "1001 0100 0011 1000", OTY_ALBI, + "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", + {"1", "1", "1", "1"}, "alias for bset 3"}, + {OPCODE_clv, 0xffff, 0x94b8, 1, OP_AVR1, "1001 0100 1011 1000", OTY_ALBI, + "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", + {"1", "1", "1", "1"}, "alias for bclr 3"}, + {OPCODE_set, 0xffff, 0x9468, 1, OP_AVR1, "1001 0100 0110 1000", OTY_ALBI, + "set", "-", "Set T in SREG", "T <-- 1", "T", + {"1", "1", "1", "1"}, "alias for bset 6"}, + {OPCODE_clt, 0xffff, 0x94e8, 1, OP_AVR1, "1001 0100 1110 1000", OTY_ALBI, + "clt", "-", "Clear T in SREG", "T <-- 0", "T", + {"1", "1", "1", "1"}, "alias for bclr 6"}, + {OPCODE_seh, 0xffff, 0x9458, 1, OP_AVR1, "1001 0100 0101 1000", OTY_ALBI, + "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", + {"1", "1", "1", "1"}, "alias for bset 5"}, + {OPCODE_clh, 0xffff, 0x94d8, 1, OP_AVR1, "1001 0100 1101 1000", OTY_ALBI, + "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", + {"1", "1", "1", "1"}, "alias for bclr 5"}, // MCU Control Instructions - {0xffff, 0x9598, 1, "1001 0101 1001 1000", OP_AVR1, OPCODE_break, "break", "-", "Break", "(cf documentation)", "None", {"-", "-", "-", "-"}, "not available on all parts"}, - {0xffff, 0x0000, 1, "0000 0000 0000 0000", OP_AVR1, OPCODE_nop, "nop", "-", "No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xffff, 0x9588, 1, "1001 0101 1000 1000", OP_AVR1, OPCODE_sleep, "sleep", "-", "Sleep", "(cf documentation)", "None", {"-", "-", "-", "-"}, ""}, - {0xffff, 0x95a8, 1, "1001 0101 1010 1000", OP_AVR1, OPCODE_wdr, "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", {"1", "1", "1", "1"}, ""}, + {OPCODE_break, 0xffff, 0x9598, 1, OP_AVR1, "1001 0101 1001 1000", OTY_MCUX, + "break", "-", "Break", "(cf documentation)", "None", + {"-", "-", "-", "-"}, "not available on all parts"}, + {OPCODE_nop, 0xffff, 0x0000, 1, OP_AVR1, "0000 0000 0000 0000", OTY_MCUI, + "nop", "-", "No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_sleep, 0xffff, 0x9588, 1, OP_AVR1, "1001 0101 1000 1000", OTY_MCUX, + "sleep", "-", "Sleep", "(cf documentation)", "None", + {"-", "-", "-", "-"}, ""}, + {OPCODE_wdr, 0xffff, 0x95a8, 1, OP_AVR1, "1001 0101 1010 1000", OTY_MCUI, + "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", + {"1", "1", "1", "1"}, ""}, // Unallocated codes - {0xff00, 0x0000, 1, "0000 0000 xxxx xxxx", OP_AVR_ILL, OPCODE_x_nop_1, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, - {0xfe0f, 0x9003, 1, "1001 000x xxxx 0011", OP_AVR_ILL, OPCODE_x_nop_2, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9008, 1, "1001 000x xxxx 1000", OP_AVR_ILL, OPCODE_x_nop_3, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x900b, 1, "1001 000x xxxx 1011", OP_AVR_ILL, OPCODE_x_nop_4, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9203, 1, "1001 001x xxxx 0011", OP_AVR_ILL, OPCODE_x_nop_5, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9208, 1, "1001 001x xxxx 1000", OP_AVR_ILL, OPCODE_x_nop_6, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x920b, 1, "1001 001x xxxx 1011", OP_AVR_ILL, OPCODE_x_nop_7, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xff1f, 0x9509, 1, "1001 0101 xxx0 1001", OP_AVR_ILL, OPCODE_x_icall, "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, - {0xff1f, 0x9519, 1, "1001 0101 xxx1 1001", OP_AVR_ILL, OPCODE_x_eicall, "u/eicall", "-", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"4", "3", "3", "n/a"}, "xxx != 000"}, - {0xff9f, 0x9508, 1, "1001 0101 0xx0 1000", OP_AVR_ILL, OPCODE_x_ret, "u/ret", "-", "alt Subroutine Return", "PC <-- STACK", "None", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, - {0xff9f, 0x9518, 1, "1001 0101 0xx1 1000", OP_AVR_ILL, OPCODE_x_reti, "u/reti", "-", "alt Interrupt Return", "PC <-- STACK", "I", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, - {0xffff, 0x95b8, 1, "1001 0101 1011 1000", OP_AVR_ILL, OPCODE_x_nop_8, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xfe0f, 0x9404, 1, "1001 010x xxxx 0100", OP_AVR_ILL, OPCODE_x_nop_9, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xff0f, 0x950b, 1, "1001 0101 xxxx 1011", OP_AVR_ILL, OPCODE_x_nop_a, "u/nop", "-", "alt No Operation", "-", "None", {"1", "1", "1", "1"}, ""}, - {0xff1f, 0x9409, 1, "1001 0100 xxx0 1001", OP_AVR_ILL, OPCODE_x_ijmp, "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", {"2", "2", "2", "2"}, "xxx != 000"}, - {0xff1f, 0x9419, 1, "1001 0100 xxx1 1001", OP_AVR_ILL, OPCODE_x_eijmp, "u/eijmp", "-", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", {"2", "2", "2", "n/a"}, "xxx != 000"}, - {0xfe08, 0xf808, 1, "1111 100d dddd 1bbb", OP_AVR_ILL, OPCODE_x_bld, "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "None", {"1", "1", "1", "1"}, ""}, - {0xfe08, 0xfa08, 1, "1111 101r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_bst, "u/bst", "Rr, b", "alt Bit Store from Register to T", "T <-- Rr(b)", "T", {"1", "1", "1", "1"}, ""}, - {0xfe08, 0xfc08, 1, "1111 110r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_sbrc, "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {0xfe08, 0xfe08, 1, "1111 111r rrrr 1bbb", OP_AVR_ILL, OPCODE_x_sbrs, "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1)PC <-- PC+2or3", "None", {"1-3", "1-3", "1-3", "1/2"}, ""}, + {OPCODE_x_nop_1, 0xff00, 0x0000, 1, OP_AVR_ILL, "0000 0000 xxxx xxxx", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, + {OPCODE_x_nop_2, 0xfe0f, 0x9003, 1, OP_AVR_ILL, "1001 000x xxxx 0011", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_nop_3, 0xfe0f, 0x9008, 1, OP_AVR_ILL, "1001 000x xxxx 1000", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_nop_4, 0xfe0f, 0x900b, 1, OP_AVR_ILL, "1001 000x xxxx 1011", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_nop_5, 0xfe0f, 0x9203, 1, OP_AVR_ILL, "1001 001x xxxx 0011", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_nop_6, 0xfe0f, 0x9208, 1, OP_AVR_ILL, "1001 001x xxxx 1000", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_nop_7, 0xfe0f, 0x920b, 1, OP_AVR_ILL, "1001 001x xxxx 1011", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_icall, 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPX, + "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", + {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, + {OPCODE_x_eicall, 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, + "u/eicall", "-", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", + {"4", "3", "3", "n/a"}, "xxx != 000"}, + {OPCODE_x_ret, 0xff9f, 0x9508, 1, OP_AVR_ILL, "1001 0101 0xx0 1000", OTY_JMPX, + "u/ret", "-", "alt Subroutine Return", "PC <-- STACK", "None", + {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, + {OPCODE_x_reti, 0xff9f, 0x9518, 1, OP_AVR_ILL, "1001 0101 0xx1 1000", OTY_JMPX, + "u/reti", "-", "alt Interrupt Return", "PC <-- STACK", "I", + {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, + {OPCODE_x_nop_8, 0xffff, 0x95b8, 1, OP_AVR_ILL, "1001 0101 1011 1000", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_nop_9, 0xfe0f, 0x9404, 1, OP_AVR_ILL, "1001 010x xxxx 0100", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_nop_a, 0xff0f, 0x950b, 1, OP_AVR_ILL, "1001 0101 xxxx 1011", OTY_MCUI, + "u/nop", "-", "alt No Operation", "-", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_ijmp, 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI, + "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", + {"2", "2", "2", "2"}, "xxx != 000"}, + {OPCODE_x_eijmp, 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPI, + "u/eijmp", "-", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", + {"2", "2", "2", "n/a"}, "xxx != 000"}, + {OPCODE_x_bld, 0xfe08, 0xf808, 1, OP_AVR_ILL, "1111 100d dddd 1bbb", OTY_ALBI|OTY_RALL, + "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "None", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_bst, 0xfe08, 0xfa08, 1, OP_AVR_ILL, "1111 101r rrrr 1bbb", OTY_ALBI|OTY_RALL, + "u/bst", "Rr, b", "alt Bit Store from Register to T", "T <-- Rr(b)", "T", + {"1", "1", "1", "1"}, ""}, + {OPCODE_x_sbrc, 0xfe08, 0xfc08, 1, OP_AVR_ILL, "1111 110r rrrr 1bbb", OTY_SKPI|OTY_RALL, + "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "None", + {"1-3", "1-3", "1-3", "1/2"}, ""}, + {OPCODE_x_sbrs, 0xfe08, 0xfe08, 1, OP_AVR_ILL, "1111 111r rrrr 1bbb", OTY_SKPI|OTY_RALL, + "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "None", + {"1-3", "1-3", "1-3", "1/2"}, ""}, }; diff --git a/src/libavrdude.h b/src/libavrdude.h index 3094196c..740310e0 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1588,18 +1588,45 @@ typedef enum { #define PART_AVR_XM (OP_AVR1|OP_AVR1nRC|OP_AVR2|OP_AVR2nRC|OP_AVR25|OP_AVR4|OP_AVR_M|OP_AVR_XM|OP_AVR_XTM) #define PART_ALL (PART_AVR_XM|OP_AVR_L|OP_AVR_XL) // All but RC (the latter conflicts) +// Opcode types +#define OTY_RMASK 7 // Register formula mask +#define OTY_RNONE 0 // No registers addressed in this opcode +#define OTY_RALL 1 // Opcode can use all 32 registers (both Rd, Rr) +#define OTY_REVN 2 // Opcode only uses even registers (Rd *= 2, Rr *= 2) +#define OTY_RUPP 3 // Opcode only uses upper registers (Rd += 16, Rr += 16) +#define OTY_RW24 4 // Opcode only uses r24, r26, r28, r30 (Rd = Rd *2 + 24) + +#define OTY_EXTERNAL 0x010 // Opcode might r/w either I/O region or memory +#define OTY_ALBI 0x020 // Arithmetic, logic or bitwise operation +#define OTY_ALBX 0x030 // Arithmetic, logic or bitwise operation (external) +#define OTY_XFRI 0x040 // Data transfer (only affecting registers) +#define OTY_XFRX 0x050 // Data transfer (between external I/O or memory and regs) +#define OTY_JMPI 0x080 // Jump to potentially anywhere in flash (jmp, ijmp, eijmp) +#define OTY_JMPX 0x090 // Jump to potentially anywhere in flash (calls and ret/i) +#define OTY_RJMI 0x100 // Relative jump rjmp, range [-4094, 4096] bytes +#define OTY_RJMX 0x110 // Relative call rcall, range [-4094, 4096] bytes +#define OTY_BRAI 0x200 // Conditional branch, range [-126, 128] bytes +#define OTY_SKPI 0x400 // Conditional skip, range [0, 4] bytes (cpse, sbrc, sbrs) +#define OTY_SKPX 0x410 // Conditional skip, range [0, 4] bytes (sbic, sbis) +#define OTY_MCUI 0x800 // nop and wdr +#define OTY_MCUX 0x810 // sleep and break + +#define OTY_ALIAS 0x1000 // Opcode is a strict alias for another one, eg, sbr == ori +#define OTY_CONSTRAINT 0x2000 // Opcode has constraints: Rr == Rd (tst, clr, lsl, rol) + typedef struct { - int mask, value, nwords; - const char *opcode_bits; // Eg, "0000 11rd dddd rrrr" - AVR_archlevel avrlevel; // Eg, OP_AVR1 AVR_opcode mnemo; // OPCODE_add, ... + int mask, value, nwords; + AVR_archlevel avrlevel; // Eg, OP_AVR1 + const char *bits; // Eg, "0000 11rd dddd rrrr" + int type; // Eg, OTY_ALBI|OTY_RALL const char *opcode, // "add" *operands, // "Rd, Rr" *description, // "Add without Carry" - *operation, // "Rd ← Rd+Rr" + *operation, // "Rd <-- Rd + Rr" *flags, // "Z,C,N,V,S,H" - *clock[OP_AVR_cycle_N], // Timing tables for AVRe, AVRxm, AVRxt and AVRrc + *clock[OP_AVR_cycle_N], // Timings for AVRe, AVRxm, AVRxt and AVRrc *remarks; } AVR_opcode_data; From 294f74ce4344b0aded92f79cc6c6f039bd3b5256 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 20 Jul 2024 13:39:48 +0100 Subject: [PATCH 327/422] Reformat affected SREG flags in avr_opcodes.c --- src/avr_opcodes.c | 328 +++++++++++++++++++++++----------------------- 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 674b81e4..42bc5cf3 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -23,505 +23,505 @@ const AVR_opcode_data avr_opcodes[164] = { // Arithmetic and Logic Instructions {OPCODE_add, 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11rd dddd rrrr", OTY_ALBI|OTY_RALL, - "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd + Rr", "Z,C,N,V,S,H", + "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd + Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_adc, 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, - "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd + Rr + C", "Z,C,N,V,S,H", + "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd + Rr + C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_adiw, 0xff00, 0x9600, 1, OP_AVR2nRC, "1001 0110 KKdd KKKK", OTY_ALBI|OTY_RW24, - "adiw", "Rd, K", "Add Immediate to Word", "Rd+1:Rd <-- Rd+1:Rd + K", "Z,C,N,V,S", + "adiw", "Rd, K", "Add Immediate to Word", "Rd+1:Rd <-- Rd+1:Rd + K", "---SVNZC", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, {OPCODE_sub, 0xfc00, 0x1800, 1, OP_AVR1, "0001 10rd dddd rrrr", OTY_ALBI|OTY_RALL, - "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd - Rr", "Z,C,N,V,S,H", + "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd - Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_subi, 0xf000, 0x5000, 1, OP_AVR1, "0101 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd - K", "Z,C,N,V,S,H", + "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd - K", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, {OPCODE_sbc, 0xfc00, 0x0800, 1, OP_AVR1, "0000 10rd dddd rrrr", OTY_ALBI|OTY_RALL, - "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd - Rr - C", "Z,C,N,V,S,H", + "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd - Rr - C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_sbci, 0xf000, 0x4000, 1, OP_AVR1, "0100 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd - K - C", "Z,C,N,V,S,H", + "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd - K - C", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, {OPCODE_sbiw, 0xff00, 0x9700, 1, OP_AVR2nRC, "1001 0111 KKdd KKKK", OTY_ALBI|OTY_RW24, - "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd - K", "Z,C,N,V,S", + "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd - K", "---SVNZC", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, {OPCODE_and, 0xfc00, 0x2000, 1, OP_AVR1, "0010 00rd dddd rrrr", OTY_ALBI|OTY_RALL, - "and", "Rd, Rr", "Logical And", "Rd <-- Rd & Rr", "Z,N,V,S", + "and", "Rd, Rr", "Logical And", "Rd <-- Rd & Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OPCODE_andi, 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "andi", "Rd, K", "Logical And with Immediate", "Rd <-- Rd & K", "Z,N,V,S", + "andi", "Rd, K", "Logical And with Immediate", "Rd <-- Rd & K", "---SVNZ-", {"1", "1", "1", "1"}, "d = 16..31"}, {OPCODE_or, 0xfc00, 0x2800, 1, OP_AVR1, "0010 10rd dddd rrrr", OTY_ALBI|OTY_RALL, - "or", "Rd, Rr", "Logical Or", "Rd <-- Rd | Rr", "Z,N,V,S", + "or", "Rd, Rr", "Logical Or", "Rd <-- Rd | Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OPCODE_ori, 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "ori", "Rd, K", "Logical Or with Immediate", "Rd <-- Rd | K", "Z,N,V,S", + "ori", "Rd, K", "Logical Or with Immediate", "Rd <-- Rd | K", "---SVNZ-", {"1", "1", "1", "1"}, "d = 16..31"}, {OPCODE_eor, 0xfc00, 0x2400, 1, OP_AVR1, "0010 01rd dddd rrrr", OTY_ALBI|OTY_RALL, - "eor", "Rd, Rr", "Exclusive or", "Rd <-- Rd ^ Rr", "Z,N,V,S", + "eor", "Rd, Rr", "Exclusive or", "Rd <-- Rd ^ Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OPCODE_com, 0xfe0f, 0x9400, 1, OP_AVR1, "1001 010d dddd 0000", OTY_ALBI|OTY_RALL, - "com", "Rd", "One's Complement", "Rd <-- 0xff - Rd", "Z,C,N,V,S", + "com", "Rd", "One's Complement", "Rd <-- 0xff - Rd", "---SVNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_neg, 0xfe0f, 0x9401, 1, OP_AVR1, "1001 010d dddd 0001", OTY_ALBI|OTY_RALL, - "neg", "Rd", "Two's Complement", "Rd <-- 0x00 - Rd", "Z,C,N,V,S,H", + "neg", "Rd", "Two's Complement", "Rd <-- 0x00 - Rd", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_sbr, 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, - "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "Z,N,V,S", + "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "---SVNZ-", {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, {OPCODE_cbr, 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, - "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "Z,N,V,S", + "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "---SVNZ-", {"1", "1", "1", "1"}, "alias for andi Rd, (0xff - K); d = 16..31"}, {OPCODE_inc, 0xfe0f, 0x9403, 1, OP_AVR1, "1001 010d dddd 0011", OTY_ALBI|OTY_RALL, - "inc", "Rd", "Increment", "Rd <-- Rd + 1", "Z,N,V,S", + "inc", "Rd", "Increment", "Rd <-- Rd + 1", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OPCODE_dec, 0xfe0f, 0x940a, 1, OP_AVR1, "1001 010d dddd 1010", OTY_ALBI|OTY_RALL, - "dec", "Rd", "Decrement", "Rd <-- Rd - 1", "Z,N,V,S", + "dec", "Rd", "Decrement", "Rd <-- Rd - 1", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OPCODE_tst, 0xfc00, 0x2000, 1, OP_AVR1, "0010 00r= rrrr ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "Z,N,V,S", + "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "---SVNZ-", {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, {OPCODE_clr, 0xfc00, 0x2400, 1, OP_AVR1, "0010 01d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "clr", "Rd", "Clear Register", "Rd <-- Rd ^ Rd", "Z,N,V,S", + "clr", "Rd", "Clear Register", "Rd <-- Rd ^ Rd", "---SVNZ-", {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, {OPCODE_ser, 0xff0f, 0xef0f, 1, OP_AVR1, "1110 1111 dddd 1111", OTY_ALBI|OTY_RUPP, - "ser", "Rd", "Set Register", "Rd <-- 0xff", "None", + "ser", "Rd", "Set Register", "Rd <-- 0xff", "--------", {"1", "1", "1", "1"}, "alias for ldi Rd, 0xff; d = 16..31"}, {OPCODE_mul, 0xfc00, 0x9c00, 1, OP_AVR4, "1001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, - "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "Z,C", + "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "------ZC", {"2", "2", "2", "n/a"}, ""}, {OPCODE_muls, 0xff00, 0x0200, 1, OP_AVR4, "0000 0010 dddd rrrr", OTY_ALBI|OTY_RUPP, - "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "Z,C", + "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..31"}, {OPCODE_mulsu, 0xff88, 0x0300, 1, OP_AVR4, "0000 0011 0ddd 0rrr", OTY_ALBI|OTY_RUPP, - "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "Z,C", + "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {OPCODE_fmul, 0xff88, 0x0308, 1, OP_AVR4, "0000 0011 0ddd 1rrr", OTY_ALBI|OTY_RUPP, - "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "Z,C", + "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {OPCODE_fmuls, 0xff88, 0x0380, 1, OP_AVR4, "0000 0011 1ddd 0rrr", OTY_ALBI|OTY_RUPP, - "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "Z,C", + "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {OPCODE_fmulsu, 0xff88, 0x0388, 1, OP_AVR4, "0000 0011 1ddd 1rrr", OTY_ALBI|OTY_RUPP, - "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "Z,C", + "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {OPCODE_des, 0xff0f, 0x940b, 1, OP_AVR_XM, "1001 0100 KKKK 1011", OTY_ALBI, - "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "-", + "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "--------", {"n/a", "1/2", "n/a", "n/a"}, ""}, // Branch Instructions (and compare) {OPCODE_rjmp, 0xf000, 0xc000, 1, OP_AVR1, "1100 kkkk kkkk kkkk", OTY_RJMI, - "rjmp", "k", "Relative Jump", "PC <-- PC + k + 1", "None", + "rjmp", "k", "Relative Jump", "PC <-- PC + k + 1", "--------", {"2", "2", "2", "2"}, ""}, {OPCODE_ijmp, 0xffff, 0x9409, 1, OP_AVR2, "1001 0100 0000 1001", OTY_JMPI, - "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", + "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, ""}, {OPCODE_eijmp, 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, - "eijmp", "-", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", + "eijmp", "-", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, ""}, {OPCODE_jmp, 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, - "jmp", "k", "Jump", "PC <-- k", "None", + "jmp", "k", "Jump", "PC <-- k", "--------", {"3", "3", "3", "n/a"}, ""}, {OPCODE_rcall, 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, - "rcall", "k", "Relative Call Subroutine", "PC <-- PC + k + 1", "None", + "rcall", "k", "Relative Call Subroutine", "PC <-- PC + k + 1", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, {OPCODE_icall, 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPX, - "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", + "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, {OPCODE_eicall, 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, - "eicall", "-", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", + "eicall", "-", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, ""}, {OPCODE_call, 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, - "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "None", + "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "--------", {"4/5", "3/4", "3/4", "n/a"}, ""}, {OPCODE_ret, 0xffff, 0x9508, 1, OP_AVR1, "1001 0101 0000 1000", OTY_JMPX, - "ret", "-", "Subroutine Return", "PC <-- STACK", "None", + "ret", "-", "Subroutine Return", "PC <-- STACK", "--------", {"4/5", "4/5", "4/5", "6"}, ""}, {OPCODE_reti, 0xffff, 0x9518, 1, OP_AVR1, "1001 0101 0001 1000", OTY_JMPX, - "reti", "-", "Interrupt Return", "PC <-- STACK", "I", + "reti", "-", "Interrupt Return", "PC <-- STACK", "I-------", {"4/5", "4/5", "4/5", "6"}, ""}, {OPCODE_cpse, 0xfc00, 0x1000, 1, OP_AVR1, "0001 00rd dddd rrrr", OTY_SKPI|OTY_RALL, - "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr) PC <-- PC + 2/3", "None", + "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, {OPCODE_cp, 0xfc00, 0x1400, 1, OP_AVR1, "0001 01rd dddd rrrr", OTY_ALBI|OTY_RALL, - "cp", "Rd, Rr", "Compare", "Rd - Rr", "Z,C,N,V,S,H", + "cp", "Rd, Rr", "Compare", "Rd - Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_cpc, 0xfc00, 0x0400, 1, OP_AVR1, "0000 01rd dddd rrrr", OTY_ALBI|OTY_RALL, - "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "Z,C,N,V,S,H", + "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_cpi, 0xf000, 0x3000, 1, OP_AVR1, "0011 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "Z,C,N,V,S,H", + "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, {OPCODE_sbrc, 0xfe08, 0xfc00, 1, OP_AVR1, "1111 110r rrrr 0bbb", OTY_SKPI|OTY_RALL, - "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "None", + "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, {OPCODE_sbrs, 0xfe08, 0xfe00, 1, OP_AVR1, "1111 111r rrrr 0bbb", OTY_SKPI|OTY_RALL, - "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "None", + "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, {OPCODE_sbic, 0xff00, 0x9900, 1, OP_AVR1, "1001 1001 AAAA Abbb", OTY_SKPX, - "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0) PC <-- PC + 2/3", "None", + "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0) PC <-- PC + 2/3", "--------", {"1-3", "2-4", "1-3", "1/2"}, ""}, {OPCODE_sbis, 0xff00, 0x9b00, 1, OP_AVR1, "1001 1011 AAAA Abbb", OTY_SKPX, - "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1) PC <-- PC + 2/3", "None", + "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1) PC <-- PC + 2/3", "--------", {"1-3", "2-4", "1-3", "1/2"}, ""}, {OPCODE_brcs, 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI, - "brcs", "k", "Branch if Carry Set", "if(C=1) then PC <-- PC + k + 1", "None", + "brcs", "k", "Branch if Carry Set", "if(C=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, {OPCODE_brlo, 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI|OTY_ALIAS, - "brlo", "k", "Branch if Lower", "if(C=1) then PC <-- PC + k + 1", "None", + "brlo", "k", "Branch if Lower", "if(C=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, {OPCODE_breq, 0xfc07, 0xf001, 1, OP_AVR1, "1111 00kk kkkk k001", OTY_BRAI, - "breq", "k", "Branch if Equal", "if(Z=1) then PC <-- PC + k + 1", "None", + "breq", "k", "Branch if Equal", "if(Z=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 1, k (Z Zero)"}, {OPCODE_brmi, 0xfc07, 0xf002, 1, OP_AVR1, "1111 00kk kkkk k010", OTY_BRAI, - "brmi", "k", "Branch if Minus", "if(N=1) then PC <-- PC + k + 1", "None", + "brmi", "k", "Branch if Minus", "if(N=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 2, k (N Negative)"}, {OPCODE_brvs, 0xfc07, 0xf003, 1, OP_AVR1, "1111 00kk kkkk k011", OTY_BRAI, - "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1) then PC <-- PC + k + 1", "None", + "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 3, k (V Overflow in two's complement)"}, {OPCODE_brlt, 0xfc07, 0xf004, 1, OP_AVR1, "1111 00kk kkkk k100", OTY_BRAI, - "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1) then PC <-- PC + k + 1", "None", + "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 4, k (S Sign)"}, {OPCODE_brhs, 0xfc07, 0xf005, 1, OP_AVR1, "1111 00kk kkkk k101", OTY_BRAI, - "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1) then PC <-- PC + k + 1", "None", + "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 5, k (H Half carry)"}, {OPCODE_brts, 0xfc07, 0xf006, 1, OP_AVR1, "1111 00kk kkkk k110", OTY_BRAI, - "brts", "k", "Branch if T Flag Set", "if(T=1) then PC <-- PC + k + 1", "None", + "brts", "k", "Branch if T Flag Set", "if(T=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 6, k (T Transfer bit)"}, {OPCODE_brie, 0xfc07, 0xf007, 1, OP_AVR1, "1111 00kk kkkk k111", OTY_BRAI, - "brie", "k", "Branch if Interrupt Enabled", "if(I=1) then PC <-- PC + k + 1", "None", + "brie", "k", "Branch if Interrupt Enabled", "if(I=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 7, k (I Interrupt enable)"}, {OPCODE_brbs, 0xfc00, 0xf000, 1, OP_AVR1, "1111 00kk kkkk ksss", OTY_BRAI, - "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1) then PC <-- PC + k + 1", "None", + "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, ""}, {OPCODE_brcc, 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI, - "brcc", "k", "Branch if Carry Cleared", "if(C=0) then PC <-- PC + k + 1", "None", + "brcc", "k", "Branch if Carry Cleared", "if(C=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, {OPCODE_brsh, 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI|OTY_ALIAS, - "brsh", "k", "Branch if Same or Higher", "if(C=0) then PC <-- PC + k + 1", "None", + "brsh", "k", "Branch if Same or Higher", "if(C=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, {OPCODE_brne, 0xfc07, 0xf401, 1, OP_AVR1, "1111 01kk kkkk k001", OTY_BRAI, - "brne", "k", "Branch if Not Equal", "if(Z=0) then PC <-- PC + k + 1", "None", + "brne", "k", "Branch if Not Equal", "if(Z=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 1, k (Z Zero)"}, {OPCODE_brpl, 0xfc07, 0xf402, 1, OP_AVR1, "1111 01kk kkkk k010", OTY_BRAI, - "brpl", "k", "Branch if Plus", "if(N=0) then PC <-- PC + k + 1", "None", + "brpl", "k", "Branch if Plus", "if(N=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 2, k (N Negative)"}, {OPCODE_brvc, 0xfc07, 0xf403, 1, OP_AVR1, "1111 01kk kkkk k011", OTY_BRAI, - "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0) then PC <-- PC + k + 1", "None", + "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 3, k (V Overflow in two's complement)"}, {OPCODE_brge, 0xfc07, 0xf404, 1, OP_AVR1, "1111 01kk kkkk k100", OTY_BRAI, - "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0) then PC <-- PC + k + 1", "None", + "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 4, k (S Sign)"}, {OPCODE_brhc, 0xfc07, 0xf405, 1, OP_AVR1, "1111 01kk kkkk k101", OTY_BRAI, - "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0) then PC <-- PC + k + 1", "None", + "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 5, k (H Half carry)"}, {OPCODE_brtc, 0xfc07, 0xf406, 1, OP_AVR1, "1111 01kk kkkk k110", OTY_BRAI, - "brtc", "k", "Branch if T Flag Cleared", "if(T=0) then PC <-- PC + k + 1", "None", + "brtc", "k", "Branch if T Flag Cleared", "if(T=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 6, k (T Transfer bit)"}, {OPCODE_brid, 0xfc07, 0xf407, 1, OP_AVR1, "1111 01kk kkkk k111", OTY_BRAI, - "brid", "k", "Branch if Interrupt Disabled", "if(I=0) then PC <-- PC + k + 1", "None", + "brid", "k", "Branch if Interrupt Disabled", "if(I=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 7, k (I Interrupt enable)"}, {OPCODE_brbc, 0xfc00, 0xf400, 1, OP_AVR1, "1111 01kk kkkk ksss", OTY_BRAI, - "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0) then PC <-- PC + k + 1", "None", + "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, ""}, // Data Transfer Instructions {OPCODE_mov, 0xfc00, 0x2c00, 1, OP_AVR1, "0010 11rd dddd rrrr", OTY_XFRI|OTY_RALL, - "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "None", + "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_movw, 0xff00, 0x0100, 1, OP_AVR25, "0000 0001 dddd rrrr", OTY_XFRI|OTY_REVN, - "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "None", + "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "--------", {"1", "1", "1", "n/a"}, "d, r in {0, 2, ..., 30}"}, {OPCODE_ldi, 0xf000, 0xe000, 1, OP_AVR1, "1110 KKKK dddd KKKK", OTY_XFRI|OTY_RUPP, - "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "None", + "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "--------", {"1", "1", "1", "1"}, "d = 16..31"}, {OPCODE_lds, 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, - "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "None", + "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "--------", {"2", "3", "3", "2"}, ""}, {OPCODE_lds_rc, 0xf800, 0xa000, 1, OP_AVR_RC, "1010 0aaa dddd aaaa", OTY_XFRX|OTY_RUPP, - "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "None", + "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "--------", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, {OPCODE_ld_1, 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, - "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "None", + "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "--------", {"2", "2", "2", "1/2"}, ""}, {OPCODE_ld_2, 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL, - "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X), X <-- X + 1", "None", + "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X), X <-- X + 1", "--------", {"2", "2", "2", "2/3"}, ""}, {OPCODE_ld_3, 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL, - "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X - 1, Rd <-- (X)", "None", + "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X - 1, Rd <-- (X)", "--------", {"2", "3", "2", "2/3"}, ""}, {OPCODE_ld_4, 0xfe0f, 0x8008, 1, OP_AVR2, "1000 000d dddd 1000", OTY_XFRX|OTY_RALL, - "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "None", + "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Y+0"}, {OPCODE_ld_5, 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL, - "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y), Y <-- Y + 1", "None", + "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y), Y <-- Y + 1", "--------", {"2", "2", "2", "2/3"}, ""}, {OPCODE_ld_6, 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL, - "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y - 1 Rd <-- (Y)", "None", + "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y - 1 Rd <-- (Y)", "--------", {"2", "3", "2", "2/3"}, ""}, {OPCODE_ldd_1, 0xd208, 0x8008, 1, OP_AVR2nRC, "10q0 qq0d dddd 1qqq", OTY_XFRX|OTY_RALL, - "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "None", + "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "--------", {"2", "3", "2", "n/a"}, ""}, {OPCODE_ld_7, 0xfe0f, 0x8000, 1, OP_AVR1, "1000 000d dddd 0000", OTY_XFRX|OTY_RALL, - "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "None", + "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Z+0"}, {OPCODE_ld_8, 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL, - "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z + 1", "None", + "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"2", "2", "2", "2/3"}, ""}, {OPCODE_ld_9, 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL, - "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z - 1, Rd <-- (Z)", "None", + "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z - 1, Rd <-- (Z)", "--------", {"2", "3", "2", "2/3"}, ""}, {OPCODE_ldd_2, 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, - "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "None", + "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "--------", {"2", "3", "2", "n/a"}, ""}, {OPCODE_sts, 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, - "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "None", + "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "--------", {"2", "2", "2", "1"}, ""}, {OPCODE_sts_rc, 0xf800, 0xa800, 1, OP_AVR_RC, "1010 1aaa rrrr aaaa", OTY_XFRX|OTY_RUPP, - "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "None", + "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "--------", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, {OPCODE_st_1, 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, - "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "None", + "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "--------", {"2", "1", "1", "1"}, ""}, {OPCODE_st_2, 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL, - "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X + 1", "None", + "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X + 1", "--------", {"2", "1", "1", "1"}, ""}, {OPCODE_st_3, 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL, - "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X - 1, (X) <-- Rr", "None", + "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X - 1, (X) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OPCODE_st_4, 0xfe0f, 0x8208, 1, OP_AVR2, "1000 001r rrrr 1000", OTY_XFRX|OTY_RALL, - "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "None", + "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Y+0, Rr"}, {OPCODE_st_5, 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL, - "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y + 1", "None", + "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y + 1", "--------", {"2", "1", "1", "1"}, ""}, {OPCODE_st_6, 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL, - "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y - 1, (Y) <-- Rr", "None", + "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y - 1, (Y) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OPCODE_std_1, 0xd208, 0x8208, 1, OP_AVR2nRC, "10q0 qq1r rrrr 1qqq", OTY_XFRX|OTY_RALL, - "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "None", + "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, {OPCODE_st_7, 0xfe0f, 0x8200, 1, OP_AVR1, "1000 001r rrrr 0000", OTY_XFRX|OTY_RALL, - "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "None", + "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Z+0, Rr"}, {OPCODE_st_8, 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL, - "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr, Z <-- Z + 1", "None", + "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr, Z <-- Z + 1", "--------", {"2", "1", "1", "1"}, ""}, {OPCODE_st_9, 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL, - "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z - 1, (Z) <-- Rr", "None", + "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z - 1, (Z) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OPCODE_std_2, 0xd208, 0x8200, 1, OP_AVR2nRC, "10q0 qq1r rrrr 0qqq", OTY_XFRX|OTY_RALL, - "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "None", + "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, {OPCODE_lpm_1, 0xffff, 0x95c8, 1, OP_AVR1nRC, "1001 0101 1100 1000", OTY_XFRX, - "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "None", + "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OPCODE_lpm_2, 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, - "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "None", + "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OPCODE_lpm_3, 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL, - "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z + 1", "None", + "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OPCODE_elpm_1, 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, - "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "None", + "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OPCODE_elpm_2, 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, - "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "None", + "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OPCODE_elpm_3, 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL, - "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "None", + "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OPCODE_spm, 0xffff, 0x95e8, 1, OP_AVR25, "1001 0101 1110 1000", OTY_XFRX, - "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "None", + "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "--------", {"-", "-", "-", "-"}, ""}, {OPCODE_spm_zz, 0xffff, 0x95f8, 1, OP_AVR_XTM, "1001 0101 1111 1000", OTY_XFRX, - "spm", "Z+", "Store Program Memory and Post-Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z + 2", "None", + "spm", "Z+", "Store Program Memory and Post-Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z + 2", "--------", {"n/a", "-", "-", "n/a"}, ""}, {OPCODE_in, 0xf800, 0xb000, 1, OP_AVR1, "1011 0AAd dddd AAAA", OTY_XFRX|OTY_RALL, - "in", "Rd, A", "In from I/O Location", "Rd <-- I/O(A)", "None", + "in", "Rd, A", "In from I/O Location", "Rd <-- I/O(A)", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_out, 0xf800, 0xb800, 1, OP_AVR1, "1011 1AAr rrrr AAAA", OTY_XFRX|OTY_RALL, - "out", "A, Rr", "Out to I/O Location", "I/O(A) <-- Rr", "None", + "out", "A, Rr", "Out to I/O Location", "I/O(A) <-- Rr", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_push, 0xfe0f, 0x920f, 1, OP_AVR2, "1001 001r rrrr 1111", OTY_XFRX|OTY_RALL, - "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "None", + "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "--------", {"2", "1", "1", "1"}, ""}, {OPCODE_pop, 0xfe0f, 0x900f, 1, OP_AVR2, "1001 000d dddd 1111", OTY_XFRX|OTY_RALL, - "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "None", + "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "--------", {"2", "2", "2", "3"}, ""}, {OPCODE_xch, 0xfe0f, 0x9204, 1, OP_AVR_XM, "1001 001d dddd 0100", OTY_XFRX|OTY_RALL, - "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "None", + "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, {OPCODE_las, 0xfe0f, 0x9205, 1, OP_AVR_XM, "1001 001d dddd 0101", OTY_ALBX|OTY_RALL, - "las", "Z, Rd", "Load and Set", "(Z) <-- Rd | (Z), Rd <-- (Z)", "None", + "las", "Z, Rd", "Load and Set", "(Z) <-- Rd | (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, {OPCODE_lac, 0xfe0f, 0x9206, 1, OP_AVR_XM, "1001 001d dddd 0110", OTY_ALBX|OTY_RALL, - "lac", "Z, Rd", "Load and Clear", "(Z) <-- (0xff - Rd) & (Z), Rd <-- (Z)", "None", + "lac", "Z, Rd", "Load and Clear", "(Z) <-- (0xff - Rd) & (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, {OPCODE_lat, 0xfe0f, 0x9207, 1, OP_AVR_XM, "1001 001d dddd 0111", OTY_ALBX|OTY_RALL, - "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd ^ (Z), Rd <-- (Z)", "None", + "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd ^ (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions {OPCODE_lsl, 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "Z,C,N,V,H", + "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "--H-VNZC", {"1", "1", "1", "1"}, "alias for add Rd, Rd"}, {OPCODE_lsr, 0xfe0f, 0x9406, 1, OP_AVR1, "1001 010d dddd 0110", OTY_ALBI|OTY_RALL, - "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", + "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_rol, 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "Z,C,N,V,H", + "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "--H-VNZC", {"1", "1", "1", "1"}, "alias for adc Rd, Rd"}, {OPCODE_ror, 0xfe0f, 0x9407, 1, OP_AVR1, "1001 010d dddd 0111", OTY_ALBI|OTY_RALL, - "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", + "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_asr, 0xfe0f, 0x9405, 1, OP_AVR1, "1001 010d dddd 0101", OTY_ALBI|OTY_RALL, - "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "Z,C,N,V", + "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, {OPCODE_swap, 0xfe0f, 0x9402, 1, OP_AVR1, "1001 010d dddd 0010", OTY_ALBI|OTY_RALL, - "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "None", + "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_bset, 0xff8f, 0x9408, 1, OP_AVR1, "1001 0100 0sss 1000", OTY_ALBX, - "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG(s)", + "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG-bit", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, {OPCODE_bclr, 0xff8f, 0x9488, 1, OP_AVR1, "1001 0100 1sss 1000", OTY_ALBI, - "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG(s)", + "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG-bit", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, {OPCODE_sbi, 0xff00, 0x9a00, 1, OP_AVR1, "1001 1010 AAAA Abbb", OTY_ALBX, - "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "None", + "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "--------", {"2", "1", "1", "1"}, ""}, {OPCODE_cbi, 0xff00, 0x9800, 1, OP_AVR1, "1001 1000 AAAA Abbb", OTY_ALBX, - "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "None", + "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "--------", {"2", "1", "1", "1"}, ""}, {OPCODE_bst, 0xfe08, 0xfa00, 1, OP_AVR1, "1111 101r rrrr 0bbb", OTY_ALBI|OTY_RALL, - "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "T", + "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "-T------", {"1", "1", "1", "1"}, ""}, {OPCODE_bld, 0xfe08, 0xf800, 1, OP_AVR1, "1111 100d dddd 0bbb", OTY_ALBI|OTY_RALL, - "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "None", + "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_sec, 0xffff, 0x9408, 1, OP_AVR1, "1001 0100 0000 1000", OTY_ALBI, - "sec", "-", "Set Carry", "C <-- 1", "C", + "sec", "-", "Set Carry", "C <-- 1", "-------C", {"1", "1", "1", "1"}, "alias for bset 0"}, {OPCODE_clc, 0xffff, 0x9488, 1, OP_AVR1, "1001 0100 1000 1000", OTY_ALBI, - "clc", "-", "Clear Carry", "C <-- 0", "C", + "clc", "-", "Clear Carry", "C <-- 0", "-------C", {"1", "1", "1", "1"}, "alias for bclr 0"}, {OPCODE_sen, 0xffff, 0x9428, 1, OP_AVR1, "1001 0100 0010 1000", OTY_ALBI, - "sen", "-", "Set Negative Flag", "N <-- 1", "N", + "sen", "-", "Set Negative Flag", "N <-- 1", "-----N--", {"1", "1", "1", "1"}, "alias for bset 2"}, {OPCODE_cln, 0xffff, 0x94a8, 1, OP_AVR1, "1001 0100 1010 1000", OTY_ALBI, - "cln", "-", "Clear Negative Flag", "N <-- 0", "N", + "cln", "-", "Clear Negative Flag", "N <-- 0", "-----N--", {"1", "1", "1", "1"}, "alias for bclr 2"}, {OPCODE_sez, 0xffff, 0x9418, 1, OP_AVR1, "1001 0100 0001 1000", OTY_ALBI, - "sez", "-", "Set Zero Flag", "Z <-- 1", "Z", + "sez", "-", "Set Zero Flag", "Z <-- 1", "------Z-", {"1", "1", "1", "1"}, "alias for bset 1"}, {OPCODE_clz, 0xffff, 0x9498, 1, OP_AVR1, "1001 0100 1001 1000", OTY_ALBI, - "clz", "-", "Clear Zero Flag", "Z <-- 0", "Z", + "clz", "-", "Clear Zero Flag", "Z <-- 0", "------Z-", {"1", "1", "1", "1"}, "alias for bclr 1"}, {OPCODE_sei, 0xffff, 0x9478, 1, OP_AVR1, "1001 0100 0111 1000", OTY_ALBX, - "sei", "-", "Global Interrupt Enable", "I <-- 1", "I", + "sei", "-", "Global Interrupt Enable", "I <-- 1", "I-------", {"1", "1", "1", "1"}, "alias for bset 7"}, {OPCODE_cli, 0xffff, 0x94f8, 1, OP_AVR1, "1001 0100 1111 1000", OTY_ALBI, - "cli", "-", "Global Interrupt Disable", "I <-- 0", "I", + "cli", "-", "Global Interrupt Disable", "I <-- 0", "I-------", {"1", "1", "1", "1"}, "alias for bclr 7"}, {OPCODE_ses, 0xffff, 0x9448, 1, OP_AVR1, "1001 0100 0100 1000", OTY_ALBI, - "ses", "-", "Set Signed Test Flag", "S <-- 1", "S", + "ses", "-", "Set Signed Test Flag", "S <-- 1", "---S----", {"1", "1", "1", "1"}, "alias for bset 4"}, {OPCODE_cls, 0xffff, 0x94c8, 1, OP_AVR1, "1001 0100 1100 1000", OTY_ALBI, - "cls", "-", "Clear Signed Test Flag", "S <-- 0", "S", + "cls", "-", "Clear Signed Test Flag", "S <-- 0", "---S----", {"1", "1", "1", "1"}, "alias for bclr 4"}, {OPCODE_sev, 0xffff, 0x9438, 1, OP_AVR1, "1001 0100 0011 1000", OTY_ALBI, - "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "V", + "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "----V---", {"1", "1", "1", "1"}, "alias for bset 3"}, {OPCODE_clv, 0xffff, 0x94b8, 1, OP_AVR1, "1001 0100 1011 1000", OTY_ALBI, - "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "V", + "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "----V---", {"1", "1", "1", "1"}, "alias for bclr 3"}, {OPCODE_set, 0xffff, 0x9468, 1, OP_AVR1, "1001 0100 0110 1000", OTY_ALBI, - "set", "-", "Set T in SREG", "T <-- 1", "T", + "set", "-", "Set T in SREG", "T <-- 1", "-T------", {"1", "1", "1", "1"}, "alias for bset 6"}, {OPCODE_clt, 0xffff, 0x94e8, 1, OP_AVR1, "1001 0100 1110 1000", OTY_ALBI, - "clt", "-", "Clear T in SREG", "T <-- 0", "T", + "clt", "-", "Clear T in SREG", "T <-- 0", "-T------", {"1", "1", "1", "1"}, "alias for bclr 6"}, {OPCODE_seh, 0xffff, 0x9458, 1, OP_AVR1, "1001 0100 0101 1000", OTY_ALBI, - "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "H", + "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "--H-----", {"1", "1", "1", "1"}, "alias for bset 5"}, {OPCODE_clh, 0xffff, 0x94d8, 1, OP_AVR1, "1001 0100 1101 1000", OTY_ALBI, - "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "H", + "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "--H-----", {"1", "1", "1", "1"}, "alias for bclr 5"}, // MCU Control Instructions {OPCODE_break, 0xffff, 0x9598, 1, OP_AVR1, "1001 0101 1001 1000", OTY_MCUX, - "break", "-", "Break", "(cf documentation)", "None", + "break", "-", "Break", "(cf documentation)", "--------", {"-", "-", "-", "-"}, "not available on all parts"}, {OPCODE_nop, 0xffff, 0x0000, 1, OP_AVR1, "0000 0000 0000 0000", OTY_MCUI, - "nop", "-", "No Operation", "-", "None", + "nop", "-", "No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_sleep, 0xffff, 0x9588, 1, OP_AVR1, "1001 0101 1000 1000", OTY_MCUX, - "sleep", "-", "Sleep", "(cf documentation)", "None", + "sleep", "-", "Sleep", "(cf documentation)", "--------", {"-", "-", "-", "-"}, ""}, {OPCODE_wdr, 0xffff, 0x95a8, 1, OP_AVR1, "1001 0101 1010 1000", OTY_MCUI, - "wdr", "-", "Watchdog Reset", "(cf documentation)", "None", + "wdr", "-", "Watchdog Reset", "(cf documentation)", "--------", {"1", "1", "1", "1"}, ""}, // Unallocated codes {OPCODE_x_nop_1, 0xff00, 0x0000, 1, OP_AVR_ILL, "0000 0000 xxxx xxxx", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, {OPCODE_x_nop_2, 0xfe0f, 0x9003, 1, OP_AVR_ILL, "1001 000x xxxx 0011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_nop_3, 0xfe0f, 0x9008, 1, OP_AVR_ILL, "1001 000x xxxx 1000", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_nop_4, 0xfe0f, 0x900b, 1, OP_AVR_ILL, "1001 000x xxxx 1011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_nop_5, 0xfe0f, 0x9203, 1, OP_AVR_ILL, "1001 001x xxxx 0011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_nop_6, 0xfe0f, 0x9208, 1, OP_AVR_ILL, "1001 001x xxxx 1000", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_nop_7, 0xfe0f, 0x920b, 1, OP_AVR_ILL, "1001 001x xxxx 1011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_icall, 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPX, - "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", + "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, {OPCODE_x_eicall, 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, - "u/eicall", "-", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", + "u/eicall", "-", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, "xxx != 000"}, {OPCODE_x_ret, 0xff9f, 0x9508, 1, OP_AVR_ILL, "1001 0101 0xx0 1000", OTY_JMPX, - "u/ret", "-", "alt Subroutine Return", "PC <-- STACK", "None", + "u/ret", "-", "alt Subroutine Return", "PC <-- STACK", "--------", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, {OPCODE_x_reti, 0xff9f, 0x9518, 1, OP_AVR_ILL, "1001 0101 0xx1 1000", OTY_JMPX, - "u/reti", "-", "alt Interrupt Return", "PC <-- STACK", "I", + "u/reti", "-", "alt Interrupt Return", "PC <-- STACK", "I-------", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, {OPCODE_x_nop_8, 0xffff, 0x95b8, 1, OP_AVR_ILL, "1001 0101 1011 1000", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_nop_9, 0xfe0f, 0x9404, 1, OP_AVR_ILL, "1001 010x xxxx 0100", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_nop_a, 0xff0f, 0x950b, 1, OP_AVR_ILL, "1001 0101 xxxx 1011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "None", + "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_ijmp, 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI, - "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "None", + "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, "xxx != 000"}, {OPCODE_x_eijmp, 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPI, - "u/eijmp", "-", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "None", + "u/eijmp", "-", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, "xxx != 000"}, {OPCODE_x_bld, 0xfe08, 0xf808, 1, OP_AVR_ILL, "1111 100d dddd 1bbb", OTY_ALBI|OTY_RALL, - "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "None", + "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "--------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_bst, 0xfe08, 0xfa08, 1, OP_AVR_ILL, "1111 101r rrrr 1bbb", OTY_ALBI|OTY_RALL, - "u/bst", "Rr, b", "alt Bit Store from Register to T", "T <-- Rr(b)", "T", + "u/bst", "Rr, b", "alt Bit Store from Register to T", "T <-- Rr(b)", "-T------", {"1", "1", "1", "1"}, ""}, {OPCODE_x_sbrc, 0xfe08, 0xfc08, 1, OP_AVR_ILL, "1111 110r rrrr 1bbb", OTY_SKPI|OTY_RALL, - "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "None", + "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, {OPCODE_x_sbrs, 0xfe08, 0xfe08, 1, OP_AVR_ILL, "1111 111r rrrr 1bbb", OTY_SKPI|OTY_RALL, - "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "None", + "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, }; From 52608e9dcc5c2de4cc8e3df68ad44104ea07d015 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 20 Jul 2024 15:18:42 +0100 Subject: [PATCH 328/422] Introduce idname for avr_opcodes table --- src/avr_opcodes.c | 330 +++++++++++++++++++++++----------------------- src/disasm.c | 40 +++--- src/libavrdude.h | 21 +-- 3 files changed, 197 insertions(+), 194 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 42bc5cf3..c3e83925 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -21,507 +21,509 @@ #include "libavrdude.h" const AVR_opcode_data avr_opcodes[164] = { +#define OP_ID(nam) OPCODE_##nam, #nam + // Arithmetic and Logic Instructions - {OPCODE_add, 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(add), 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11rd dddd rrrr", OTY_ALBI|OTY_RALL, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd + Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_adc, 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(adc), 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd + Rr + C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_adiw, 0xff00, 0x9600, 1, OP_AVR2nRC, "1001 0110 KKdd KKKK", OTY_ALBI|OTY_RW24, + {OP_ID(adiw), 0xff00, 0x9600, 1, OP_AVR2nRC, "1001 0110 KKdd KKKK", OTY_ALBI|OTY_RW24, "adiw", "Rd, K", "Add Immediate to Word", "Rd+1:Rd <-- Rd+1:Rd + K", "---SVNZC", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, - {OPCODE_sub, 0xfc00, 0x1800, 1, OP_AVR1, "0001 10rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(sub), 0xfc00, 0x1800, 1, OP_AVR1, "0001 10rd dddd rrrr", OTY_ALBI|OTY_RALL, "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd - Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_subi, 0xf000, 0x5000, 1, OP_AVR1, "0101 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + {OP_ID(subi), 0xf000, 0x5000, 1, OP_AVR1, "0101 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd - K", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, - {OPCODE_sbc, 0xfc00, 0x0800, 1, OP_AVR1, "0000 10rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(sbc), 0xfc00, 0x0800, 1, OP_AVR1, "0000 10rd dddd rrrr", OTY_ALBI|OTY_RALL, "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd - Rr - C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_sbci, 0xf000, 0x4000, 1, OP_AVR1, "0100 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + {OP_ID(sbci), 0xf000, 0x4000, 1, OP_AVR1, "0100 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd - K - C", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, - {OPCODE_sbiw, 0xff00, 0x9700, 1, OP_AVR2nRC, "1001 0111 KKdd KKKK", OTY_ALBI|OTY_RW24, + {OP_ID(sbiw), 0xff00, 0x9700, 1, OP_AVR2nRC, "1001 0111 KKdd KKKK", OTY_ALBI|OTY_RW24, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd - K", "---SVNZC", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, - {OPCODE_and, 0xfc00, 0x2000, 1, OP_AVR1, "0010 00rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(and), 0xfc00, 0x2000, 1, OP_AVR1, "0010 00rd dddd rrrr", OTY_ALBI|OTY_RALL, "and", "Rd, Rr", "Logical And", "Rd <-- Rd & Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, - {OPCODE_andi, 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + {OP_ID(andi), 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, "andi", "Rd, K", "Logical And with Immediate", "Rd <-- Rd & K", "---SVNZ-", {"1", "1", "1", "1"}, "d = 16..31"}, - {OPCODE_or, 0xfc00, 0x2800, 1, OP_AVR1, "0010 10rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(or), 0xfc00, 0x2800, 1, OP_AVR1, "0010 10rd dddd rrrr", OTY_ALBI|OTY_RALL, "or", "Rd, Rr", "Logical Or", "Rd <-- Rd | Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, - {OPCODE_ori, 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + {OP_ID(ori), 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, "ori", "Rd, K", "Logical Or with Immediate", "Rd <-- Rd | K", "---SVNZ-", {"1", "1", "1", "1"}, "d = 16..31"}, - {OPCODE_eor, 0xfc00, 0x2400, 1, OP_AVR1, "0010 01rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(eor), 0xfc00, 0x2400, 1, OP_AVR1, "0010 01rd dddd rrrr", OTY_ALBI|OTY_RALL, "eor", "Rd, Rr", "Exclusive or", "Rd <-- Rd ^ Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, - {OPCODE_com, 0xfe0f, 0x9400, 1, OP_AVR1, "1001 010d dddd 0000", OTY_ALBI|OTY_RALL, + {OP_ID(com), 0xfe0f, 0x9400, 1, OP_AVR1, "1001 010d dddd 0000", OTY_ALBI|OTY_RALL, "com", "Rd", "One's Complement", "Rd <-- 0xff - Rd", "---SVNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_neg, 0xfe0f, 0x9401, 1, OP_AVR1, "1001 010d dddd 0001", OTY_ALBI|OTY_RALL, + {OP_ID(neg), 0xfe0f, 0x9401, 1, OP_AVR1, "1001 010d dddd 0001", OTY_ALBI|OTY_RALL, "neg", "Rd", "Two's Complement", "Rd <-- 0x00 - Rd", "--HSVNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_sbr, 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, + {OP_ID(sbr), 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "---SVNZ-", {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, - {OPCODE_cbr, 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, + {OP_ID(cbr), 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "---SVNZ-", {"1", "1", "1", "1"}, "alias for andi Rd, (0xff - K); d = 16..31"}, - {OPCODE_inc, 0xfe0f, 0x9403, 1, OP_AVR1, "1001 010d dddd 0011", OTY_ALBI|OTY_RALL, + {OP_ID(inc), 0xfe0f, 0x9403, 1, OP_AVR1, "1001 010d dddd 0011", OTY_ALBI|OTY_RALL, "inc", "Rd", "Increment", "Rd <-- Rd + 1", "---SVNZ-", {"1", "1", "1", "1"}, ""}, - {OPCODE_dec, 0xfe0f, 0x940a, 1, OP_AVR1, "1001 010d dddd 1010", OTY_ALBI|OTY_RALL, + {OP_ID(dec), 0xfe0f, 0x940a, 1, OP_AVR1, "1001 010d dddd 1010", OTY_ALBI|OTY_RALL, "dec", "Rd", "Decrement", "Rd <-- Rd - 1", "---SVNZ-", {"1", "1", "1", "1"}, ""}, - {OPCODE_tst, 0xfc00, 0x2000, 1, OP_AVR1, "0010 00r= rrrr ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + {OP_ID(tst), 0xfc00, 0x2000, 1, OP_AVR1, "0010 00r= rrrr ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "---SVNZ-", {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, - {OPCODE_clr, 0xfc00, 0x2400, 1, OP_AVR1, "0010 01d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + {OP_ID(clr), 0xfc00, 0x2400, 1, OP_AVR1, "0010 01d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, "clr", "Rd", "Clear Register", "Rd <-- Rd ^ Rd", "---SVNZ-", {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, - {OPCODE_ser, 0xff0f, 0xef0f, 1, OP_AVR1, "1110 1111 dddd 1111", OTY_ALBI|OTY_RUPP, + {OP_ID(ser), 0xff0f, 0xef0f, 1, OP_AVR1, "1110 1111 dddd 1111", OTY_ALBI|OTY_RUPP, "ser", "Rd", "Set Register", "Rd <-- 0xff", "--------", {"1", "1", "1", "1"}, "alias for ldi Rd, 0xff; d = 16..31"}, - {OPCODE_mul, 0xfc00, 0x9c00, 1, OP_AVR4, "1001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(mul), 0xfc00, 0x9c00, 1, OP_AVR4, "1001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "------ZC", {"2", "2", "2", "n/a"}, ""}, - {OPCODE_muls, 0xff00, 0x0200, 1, OP_AVR4, "0000 0010 dddd rrrr", OTY_ALBI|OTY_RUPP, + {OP_ID(muls), 0xff00, 0x0200, 1, OP_AVR4, "0000 0010 dddd rrrr", OTY_ALBI|OTY_RUPP, "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..31"}, - {OPCODE_mulsu, 0xff88, 0x0300, 1, OP_AVR4, "0000 0011 0ddd 0rrr", OTY_ALBI|OTY_RUPP, + {OP_ID(mulsu), 0xff88, 0x0300, 1, OP_AVR4, "0000 0011 0ddd 0rrr", OTY_ALBI|OTY_RUPP, "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, - {OPCODE_fmul, 0xff88, 0x0308, 1, OP_AVR4, "0000 0011 0ddd 1rrr", OTY_ALBI|OTY_RUPP, + {OP_ID(fmul), 0xff88, 0x0308, 1, OP_AVR4, "0000 0011 0ddd 1rrr", OTY_ALBI|OTY_RUPP, "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, - {OPCODE_fmuls, 0xff88, 0x0380, 1, OP_AVR4, "0000 0011 1ddd 0rrr", OTY_ALBI|OTY_RUPP, + {OP_ID(fmuls), 0xff88, 0x0380, 1, OP_AVR4, "0000 0011 1ddd 0rrr", OTY_ALBI|OTY_RUPP, "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, - {OPCODE_fmulsu, 0xff88, 0x0388, 1, OP_AVR4, "0000 0011 1ddd 1rrr", OTY_ALBI|OTY_RUPP, + {OP_ID(fmulsu), 0xff88, 0x0388, 1, OP_AVR4, "0000 0011 1ddd 1rrr", OTY_ALBI|OTY_RUPP, "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, - {OPCODE_des, 0xff0f, 0x940b, 1, OP_AVR_XM, "1001 0100 KKKK 1011", OTY_ALBI, + {OP_ID(des), 0xff0f, 0x940b, 1, OP_AVR_XM, "1001 0100 KKKK 1011", OTY_ALBI, "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "--------", {"n/a", "1/2", "n/a", "n/a"}, ""}, // Branch Instructions (and compare) - {OPCODE_rjmp, 0xf000, 0xc000, 1, OP_AVR1, "1100 kkkk kkkk kkkk", OTY_RJMI, + {OP_ID(rjmp), 0xf000, 0xc000, 1, OP_AVR1, "1100 kkkk kkkk kkkk", OTY_RJMI, "rjmp", "k", "Relative Jump", "PC <-- PC + k + 1", "--------", {"2", "2", "2", "2"}, ""}, - {OPCODE_ijmp, 0xffff, 0x9409, 1, OP_AVR2, "1001 0100 0000 1001", OTY_JMPI, + {OP_ID(ijmp), 0xffff, 0x9409, 1, OP_AVR2, "1001 0100 0000 1001", OTY_JMPI, "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, ""}, - {OPCODE_eijmp, 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, + {OP_ID(eijmp), 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, "eijmp", "-", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, ""}, - {OPCODE_jmp, 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, + {OP_ID(jmp), 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, "jmp", "k", "Jump", "PC <-- k", "--------", {"3", "3", "3", "n/a"}, ""}, - {OPCODE_rcall, 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, + {OP_ID(rcall), 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, "rcall", "k", "Relative Call Subroutine", "PC <-- PC + k + 1", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, - {OPCODE_icall, 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPX, + {OP_ID(icall), 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPX, "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, - {OPCODE_eicall, 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, + {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, "eicall", "-", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, ""}, - {OPCODE_call, 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, + {OP_ID(call), 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "--------", {"4/5", "3/4", "3/4", "n/a"}, ""}, - {OPCODE_ret, 0xffff, 0x9508, 1, OP_AVR1, "1001 0101 0000 1000", OTY_JMPX, + {OP_ID(ret), 0xffff, 0x9508, 1, OP_AVR1, "1001 0101 0000 1000", OTY_JMPX, "ret", "-", "Subroutine Return", "PC <-- STACK", "--------", {"4/5", "4/5", "4/5", "6"}, ""}, - {OPCODE_reti, 0xffff, 0x9518, 1, OP_AVR1, "1001 0101 0001 1000", OTY_JMPX, + {OP_ID(reti), 0xffff, 0x9518, 1, OP_AVR1, "1001 0101 0001 1000", OTY_JMPX, "reti", "-", "Interrupt Return", "PC <-- STACK", "I-------", {"4/5", "4/5", "4/5", "6"}, ""}, - {OPCODE_cpse, 0xfc00, 0x1000, 1, OP_AVR1, "0001 00rd dddd rrrr", OTY_SKPI|OTY_RALL, + {OP_ID(cpse), 0xfc00, 0x1000, 1, OP_AVR1, "0001 00rd dddd rrrr", OTY_SKPI|OTY_RALL, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {OPCODE_cp, 0xfc00, 0x1400, 1, OP_AVR1, "0001 01rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(cp), 0xfc00, 0x1400, 1, OP_AVR1, "0001 01rd dddd rrrr", OTY_ALBI|OTY_RALL, "cp", "Rd, Rr", "Compare", "Rd - Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_cpc, 0xfc00, 0x0400, 1, OP_AVR1, "0000 01rd dddd rrrr", OTY_ALBI|OTY_RALL, + {OP_ID(cpc), 0xfc00, 0x0400, 1, OP_AVR1, "0000 01rd dddd rrrr", OTY_ALBI|OTY_RALL, "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_cpi, 0xf000, 0x3000, 1, OP_AVR1, "0011 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, + {OP_ID(cpi), 0xf000, 0x3000, 1, OP_AVR1, "0011 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, - {OPCODE_sbrc, 0xfe08, 0xfc00, 1, OP_AVR1, "1111 110r rrrr 0bbb", OTY_SKPI|OTY_RALL, + {OP_ID(sbrc), 0xfe08, 0xfc00, 1, OP_AVR1, "1111 110r rrrr 0bbb", OTY_SKPI|OTY_RALL, "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {OPCODE_sbrs, 0xfe08, 0xfe00, 1, OP_AVR1, "1111 111r rrrr 0bbb", OTY_SKPI|OTY_RALL, + {OP_ID(sbrs), 0xfe08, 0xfe00, 1, OP_AVR1, "1111 111r rrrr 0bbb", OTY_SKPI|OTY_RALL, "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {OPCODE_sbic, 0xff00, 0x9900, 1, OP_AVR1, "1001 1001 AAAA Abbb", OTY_SKPX, + {OP_ID(sbic), 0xff00, 0x9900, 1, OP_AVR1, "1001 1001 AAAA Abbb", OTY_SKPX, "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0) PC <-- PC + 2/3", "--------", {"1-3", "2-4", "1-3", "1/2"}, ""}, - {OPCODE_sbis, 0xff00, 0x9b00, 1, OP_AVR1, "1001 1011 AAAA Abbb", OTY_SKPX, + {OP_ID(sbis), 0xff00, 0x9b00, 1, OP_AVR1, "1001 1011 AAAA Abbb", OTY_SKPX, "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1) PC <-- PC + 2/3", "--------", {"1-3", "2-4", "1-3", "1/2"}, ""}, - {OPCODE_brcs, 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI, + {OP_ID(brcs), 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI, "brcs", "k", "Branch if Carry Set", "if(C=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, - {OPCODE_brlo, 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI|OTY_ALIAS, + {OP_ID(brlo), 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI|OTY_ALIAS, "brlo", "k", "Branch if Lower", "if(C=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, - {OPCODE_breq, 0xfc07, 0xf001, 1, OP_AVR1, "1111 00kk kkkk k001", OTY_BRAI, + {OP_ID(breq), 0xfc07, 0xf001, 1, OP_AVR1, "1111 00kk kkkk k001", OTY_BRAI, "breq", "k", "Branch if Equal", "if(Z=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 1, k (Z Zero)"}, - {OPCODE_brmi, 0xfc07, 0xf002, 1, OP_AVR1, "1111 00kk kkkk k010", OTY_BRAI, + {OP_ID(brmi), 0xfc07, 0xf002, 1, OP_AVR1, "1111 00kk kkkk k010", OTY_BRAI, "brmi", "k", "Branch if Minus", "if(N=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 2, k (N Negative)"}, - {OPCODE_brvs, 0xfc07, 0xf003, 1, OP_AVR1, "1111 00kk kkkk k011", OTY_BRAI, + {OP_ID(brvs), 0xfc07, 0xf003, 1, OP_AVR1, "1111 00kk kkkk k011", OTY_BRAI, "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 3, k (V Overflow in two's complement)"}, - {OPCODE_brlt, 0xfc07, 0xf004, 1, OP_AVR1, "1111 00kk kkkk k100", OTY_BRAI, + {OP_ID(brlt), 0xfc07, 0xf004, 1, OP_AVR1, "1111 00kk kkkk k100", OTY_BRAI, "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 4, k (S Sign)"}, - {OPCODE_brhs, 0xfc07, 0xf005, 1, OP_AVR1, "1111 00kk kkkk k101", OTY_BRAI, + {OP_ID(brhs), 0xfc07, 0xf005, 1, OP_AVR1, "1111 00kk kkkk k101", OTY_BRAI, "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 5, k (H Half carry)"}, - {OPCODE_brts, 0xfc07, 0xf006, 1, OP_AVR1, "1111 00kk kkkk k110", OTY_BRAI, + {OP_ID(brts), 0xfc07, 0xf006, 1, OP_AVR1, "1111 00kk kkkk k110", OTY_BRAI, "brts", "k", "Branch if T Flag Set", "if(T=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 6, k (T Transfer bit)"}, - {OPCODE_brie, 0xfc07, 0xf007, 1, OP_AVR1, "1111 00kk kkkk k111", OTY_BRAI, + {OP_ID(brie), 0xfc07, 0xf007, 1, OP_AVR1, "1111 00kk kkkk k111", OTY_BRAI, "brie", "k", "Branch if Interrupt Enabled", "if(I=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 7, k (I Interrupt enable)"}, - {OPCODE_brbs, 0xfc00, 0xf000, 1, OP_AVR1, "1111 00kk kkkk ksss", OTY_BRAI, + {OP_ID(brbs), 0xfc00, 0xf000, 1, OP_AVR1, "1111 00kk kkkk ksss", OTY_BRAI, "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, ""}, - {OPCODE_brcc, 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI, + {OP_ID(brcc), 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI, "brcc", "k", "Branch if Carry Cleared", "if(C=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, - {OPCODE_brsh, 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI|OTY_ALIAS, + {OP_ID(brsh), 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI|OTY_ALIAS, "brsh", "k", "Branch if Same or Higher", "if(C=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, - {OPCODE_brne, 0xfc07, 0xf401, 1, OP_AVR1, "1111 01kk kkkk k001", OTY_BRAI, + {OP_ID(brne), 0xfc07, 0xf401, 1, OP_AVR1, "1111 01kk kkkk k001", OTY_BRAI, "brne", "k", "Branch if Not Equal", "if(Z=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 1, k (Z Zero)"}, - {OPCODE_brpl, 0xfc07, 0xf402, 1, OP_AVR1, "1111 01kk kkkk k010", OTY_BRAI, + {OP_ID(brpl), 0xfc07, 0xf402, 1, OP_AVR1, "1111 01kk kkkk k010", OTY_BRAI, "brpl", "k", "Branch if Plus", "if(N=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 2, k (N Negative)"}, - {OPCODE_brvc, 0xfc07, 0xf403, 1, OP_AVR1, "1111 01kk kkkk k011", OTY_BRAI, + {OP_ID(brvc), 0xfc07, 0xf403, 1, OP_AVR1, "1111 01kk kkkk k011", OTY_BRAI, "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 3, k (V Overflow in two's complement)"}, - {OPCODE_brge, 0xfc07, 0xf404, 1, OP_AVR1, "1111 01kk kkkk k100", OTY_BRAI, + {OP_ID(brge), 0xfc07, 0xf404, 1, OP_AVR1, "1111 01kk kkkk k100", OTY_BRAI, "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 4, k (S Sign)"}, - {OPCODE_brhc, 0xfc07, 0xf405, 1, OP_AVR1, "1111 01kk kkkk k101", OTY_BRAI, + {OP_ID(brhc), 0xfc07, 0xf405, 1, OP_AVR1, "1111 01kk kkkk k101", OTY_BRAI, "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 5, k (H Half carry)"}, - {OPCODE_brtc, 0xfc07, 0xf406, 1, OP_AVR1, "1111 01kk kkkk k110", OTY_BRAI, + {OP_ID(brtc), 0xfc07, 0xf406, 1, OP_AVR1, "1111 01kk kkkk k110", OTY_BRAI, "brtc", "k", "Branch if T Flag Cleared", "if(T=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 6, k (T Transfer bit)"}, - {OPCODE_brid, 0xfc07, 0xf407, 1, OP_AVR1, "1111 01kk kkkk k111", OTY_BRAI, + {OP_ID(brid), 0xfc07, 0xf407, 1, OP_AVR1, "1111 01kk kkkk k111", OTY_BRAI, "brid", "k", "Branch if Interrupt Disabled", "if(I=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 7, k (I Interrupt enable)"}, - {OPCODE_brbc, 0xfc00, 0xf400, 1, OP_AVR1, "1111 01kk kkkk ksss", OTY_BRAI, + {OP_ID(brbc), 0xfc00, 0xf400, 1, OP_AVR1, "1111 01kk kkkk ksss", OTY_BRAI, "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, ""}, // Data Transfer Instructions - {OPCODE_mov, 0xfc00, 0x2c00, 1, OP_AVR1, "0010 11rd dddd rrrr", OTY_XFRI|OTY_RALL, + {OP_ID(mov), 0xfc00, 0x2c00, 1, OP_AVR1, "0010 11rd dddd rrrr", OTY_XFRI|OTY_RALL, "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_movw, 0xff00, 0x0100, 1, OP_AVR25, "0000 0001 dddd rrrr", OTY_XFRI|OTY_REVN, + {OP_ID(movw), 0xff00, 0x0100, 1, OP_AVR25, "0000 0001 dddd rrrr", OTY_XFRI|OTY_REVN, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "--------", {"1", "1", "1", "n/a"}, "d, r in {0, 2, ..., 30}"}, - {OPCODE_ldi, 0xf000, 0xe000, 1, OP_AVR1, "1110 KKKK dddd KKKK", OTY_XFRI|OTY_RUPP, + {OP_ID(ldi), 0xf000, 0xe000, 1, OP_AVR1, "1110 KKKK dddd KKKK", OTY_XFRI|OTY_RUPP, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "--------", {"1", "1", "1", "1"}, "d = 16..31"}, - {OPCODE_lds, 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, + {OP_ID(lds), 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "--------", {"2", "3", "3", "2"}, ""}, - {OPCODE_lds_rc, 0xf800, 0xa000, 1, OP_AVR_RC, "1010 0aaa dddd aaaa", OTY_XFRX|OTY_RUPP, + {OP_ID(lds_rc), 0xf800, 0xa000, 1, OP_AVR_RC, "1010 0aaa dddd aaaa", OTY_XFRX|OTY_RUPP, "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "--------", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, - {OPCODE_ld_1, 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, + {OP_ID(ld_1), 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "--------", {"2", "2", "2", "1/2"}, ""}, - {OPCODE_ld_2, 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL, + {OP_ID(ld_2), 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X), X <-- X + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OPCODE_ld_3, 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL, + {OP_ID(ld_3), 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X - 1, Rd <-- (X)", "--------", {"2", "3", "2", "2/3"}, ""}, - {OPCODE_ld_4, 0xfe0f, 0x8008, 1, OP_AVR2, "1000 000d dddd 1000", OTY_XFRX|OTY_RALL, + {OP_ID(ld_4), 0xfe0f, 0x8008, 1, OP_AVR2, "1000 000d dddd 1000", OTY_XFRX|OTY_RALL, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Y+0"}, - {OPCODE_ld_5, 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL, + {OP_ID(ld_5), 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y), Y <-- Y + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OPCODE_ld_6, 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL, + {OP_ID(ld_6), 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y - 1 Rd <-- (Y)", "--------", {"2", "3", "2", "2/3"}, ""}, - {OPCODE_ldd_1, 0xd208, 0x8008, 1, OP_AVR2nRC, "10q0 qq0d dddd 1qqq", OTY_XFRX|OTY_RALL, + {OP_ID(ldd_1), 0xd208, 0x8008, 1, OP_AVR2nRC, "10q0 qq0d dddd 1qqq", OTY_XFRX|OTY_RALL, "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "--------", {"2", "3", "2", "n/a"}, ""}, - {OPCODE_ld_7, 0xfe0f, 0x8000, 1, OP_AVR1, "1000 000d dddd 0000", OTY_XFRX|OTY_RALL, + {OP_ID(ld_7), 0xfe0f, 0x8000, 1, OP_AVR1, "1000 000d dddd 0000", OTY_XFRX|OTY_RALL, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Z+0"}, - {OPCODE_ld_8, 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL, + {OP_ID(ld_8), 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OPCODE_ld_9, 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL, + {OP_ID(ld_9), 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z - 1, Rd <-- (Z)", "--------", {"2", "3", "2", "2/3"}, ""}, - {OPCODE_ldd_2, 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, + {OP_ID(ldd_2), 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "--------", {"2", "3", "2", "n/a"}, ""}, - {OPCODE_sts, 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, + {OP_ID(sts), 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "--------", {"2", "2", "2", "1"}, ""}, - {OPCODE_sts_rc, 0xf800, 0xa800, 1, OP_AVR_RC, "1010 1aaa rrrr aaaa", OTY_XFRX|OTY_RUPP, + {OP_ID(sts_rc), 0xf800, 0xa800, 1, OP_AVR_RC, "1010 1aaa rrrr aaaa", OTY_XFRX|OTY_RUPP, "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "--------", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, - {OPCODE_st_1, 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, + {OP_ID(st_1), 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "--------", {"2", "1", "1", "1"}, ""}, - {OPCODE_st_2, 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL, + {OP_ID(st_2), 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OPCODE_st_3, 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL, + {OP_ID(st_3), 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X - 1, (X) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, - {OPCODE_st_4, 0xfe0f, 0x8208, 1, OP_AVR2, "1000 001r rrrr 1000", OTY_XFRX|OTY_RALL, + {OP_ID(st_4), 0xfe0f, 0x8208, 1, OP_AVR2, "1000 001r rrrr 1000", OTY_XFRX|OTY_RALL, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Y+0, Rr"}, - {OPCODE_st_5, 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL, + {OP_ID(st_5), 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OPCODE_st_6, 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL, + {OP_ID(st_6), 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y - 1, (Y) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, - {OPCODE_std_1, 0xd208, 0x8208, 1, OP_AVR2nRC, "10q0 qq1r rrrr 1qqq", OTY_XFRX|OTY_RALL, + {OP_ID(std_1), 0xd208, 0x8208, 1, OP_AVR2nRC, "10q0 qq1r rrrr 1qqq", OTY_XFRX|OTY_RALL, "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, - {OPCODE_st_7, 0xfe0f, 0x8200, 1, OP_AVR1, "1000 001r rrrr 0000", OTY_XFRX|OTY_RALL, + {OP_ID(st_7), 0xfe0f, 0x8200, 1, OP_AVR1, "1000 001r rrrr 0000", OTY_XFRX|OTY_RALL, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Z+0, Rr"}, - {OPCODE_st_8, 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL, + {OP_ID(st_8), 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr, Z <-- Z + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OPCODE_st_9, 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL, + {OP_ID(st_9), 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z - 1, (Z) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, - {OPCODE_std_2, 0xd208, 0x8200, 1, OP_AVR2nRC, "10q0 qq1r rrrr 0qqq", OTY_XFRX|OTY_RALL, + {OP_ID(std_2), 0xd208, 0x8200, 1, OP_AVR2nRC, "10q0 qq1r rrrr 0qqq", OTY_XFRX|OTY_RALL, "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, - {OPCODE_lpm_1, 0xffff, 0x95c8, 1, OP_AVR1nRC, "1001 0101 1100 1000", OTY_XFRX, + {OP_ID(lpm_1), 0xffff, 0x95c8, 1, OP_AVR1nRC, "1001 0101 1100 1000", OTY_XFRX, "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OPCODE_lpm_2, 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, + {OP_ID(lpm_2), 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OPCODE_lpm_3, 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL, + {OP_ID(lpm_3), 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, - {OPCODE_elpm_1, 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, + {OP_ID(elpm_1), 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OPCODE_elpm_2, 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, + {OP_ID(elpm_2), 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OPCODE_elpm_3, 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL, + {OP_ID(elpm_3), 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, - {OPCODE_spm, 0xffff, 0x95e8, 1, OP_AVR25, "1001 0101 1110 1000", OTY_XFRX, + {OP_ID(spm), 0xffff, 0x95e8, 1, OP_AVR25, "1001 0101 1110 1000", OTY_XFRX, "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "--------", {"-", "-", "-", "-"}, ""}, - {OPCODE_spm_zz, 0xffff, 0x95f8, 1, OP_AVR_XTM, "1001 0101 1111 1000", OTY_XFRX, + {OP_ID(spm_zz), 0xffff, 0x95f8, 1, OP_AVR_XTM, "1001 0101 1111 1000", OTY_XFRX, "spm", "Z+", "Store Program Memory and Post-Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z + 2", "--------", {"n/a", "-", "-", "n/a"}, ""}, - {OPCODE_in, 0xf800, 0xb000, 1, OP_AVR1, "1011 0AAd dddd AAAA", OTY_XFRX|OTY_RALL, + {OP_ID(in), 0xf800, 0xb000, 1, OP_AVR1, "1011 0AAd dddd AAAA", OTY_XFRX|OTY_RALL, "in", "Rd, A", "In from I/O Location", "Rd <-- I/O(A)", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_out, 0xf800, 0xb800, 1, OP_AVR1, "1011 1AAr rrrr AAAA", OTY_XFRX|OTY_RALL, + {OP_ID(out), 0xf800, 0xb800, 1, OP_AVR1, "1011 1AAr rrrr AAAA", OTY_XFRX|OTY_RALL, "out", "A, Rr", "Out to I/O Location", "I/O(A) <-- Rr", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_push, 0xfe0f, 0x920f, 1, OP_AVR2, "1001 001r rrrr 1111", OTY_XFRX|OTY_RALL, + {OP_ID(push), 0xfe0f, 0x920f, 1, OP_AVR2, "1001 001r rrrr 1111", OTY_XFRX|OTY_RALL, "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "--------", {"2", "1", "1", "1"}, ""}, - {OPCODE_pop, 0xfe0f, 0x900f, 1, OP_AVR2, "1001 000d dddd 1111", OTY_XFRX|OTY_RALL, + {OP_ID(pop), 0xfe0f, 0x900f, 1, OP_AVR2, "1001 000d dddd 1111", OTY_XFRX|OTY_RALL, "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "--------", {"2", "2", "2", "3"}, ""}, - {OPCODE_xch, 0xfe0f, 0x9204, 1, OP_AVR_XM, "1001 001d dddd 0100", OTY_XFRX|OTY_RALL, + {OP_ID(xch), 0xfe0f, 0x9204, 1, OP_AVR_XM, "1001 001d dddd 0100", OTY_XFRX|OTY_RALL, "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, - {OPCODE_las, 0xfe0f, 0x9205, 1, OP_AVR_XM, "1001 001d dddd 0101", OTY_ALBX|OTY_RALL, + {OP_ID(las), 0xfe0f, 0x9205, 1, OP_AVR_XM, "1001 001d dddd 0101", OTY_ALBX|OTY_RALL, "las", "Z, Rd", "Load and Set", "(Z) <-- Rd | (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, - {OPCODE_lac, 0xfe0f, 0x9206, 1, OP_AVR_XM, "1001 001d dddd 0110", OTY_ALBX|OTY_RALL, + {OP_ID(lac), 0xfe0f, 0x9206, 1, OP_AVR_XM, "1001 001d dddd 0110", OTY_ALBX|OTY_RALL, "lac", "Z, Rd", "Load and Clear", "(Z) <-- (0xff - Rd) & (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, - {OPCODE_lat, 0xfe0f, 0x9207, 1, OP_AVR_XM, "1001 001d dddd 0111", OTY_ALBX|OTY_RALL, + {OP_ID(lat), 0xfe0f, 0x9207, 1, OP_AVR_XM, "1001 001d dddd 0111", OTY_ALBX|OTY_RALL, "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd ^ (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions - {OPCODE_lsl, 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + {OP_ID(lsl), 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "--H-VNZC", {"1", "1", "1", "1"}, "alias for add Rd, Rd"}, - {OPCODE_lsr, 0xfe0f, 0x9406, 1, OP_AVR1, "1001 010d dddd 0110", OTY_ALBI|OTY_RALL, + {OP_ID(lsr), 0xfe0f, 0x9406, 1, OP_AVR1, "1001 010d dddd 0110", OTY_ALBI|OTY_RALL, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_rol, 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + {OP_ID(rol), 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "--H-VNZC", {"1", "1", "1", "1"}, "alias for adc Rd, Rd"}, - {OPCODE_ror, 0xfe0f, 0x9407, 1, OP_AVR1, "1001 010d dddd 0111", OTY_ALBI|OTY_RALL, + {OP_ID(ror), 0xfe0f, 0x9407, 1, OP_AVR1, "1001 010d dddd 0111", OTY_ALBI|OTY_RALL, "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_asr, 0xfe0f, 0x9405, 1, OP_AVR1, "1001 010d dddd 0101", OTY_ALBI|OTY_RALL, + {OP_ID(asr), 0xfe0f, 0x9405, 1, OP_AVR1, "1001 010d dddd 0101", OTY_ALBI|OTY_RALL, "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, - {OPCODE_swap, 0xfe0f, 0x9402, 1, OP_AVR1, "1001 010d dddd 0010", OTY_ALBI|OTY_RALL, + {OP_ID(swap), 0xfe0f, 0x9402, 1, OP_AVR1, "1001 010d dddd 0010", OTY_ALBI|OTY_RALL, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_bset, 0xff8f, 0x9408, 1, OP_AVR1, "1001 0100 0sss 1000", OTY_ALBX, + {OP_ID(bset), 0xff8f, 0x9408, 1, OP_AVR1, "1001 0100 0sss 1000", OTY_ALBX, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG-bit", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, - {OPCODE_bclr, 0xff8f, 0x9488, 1, OP_AVR1, "1001 0100 1sss 1000", OTY_ALBI, + {OP_ID(bclr), 0xff8f, 0x9488, 1, OP_AVR1, "1001 0100 1sss 1000", OTY_ALBI, "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG-bit", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, - {OPCODE_sbi, 0xff00, 0x9a00, 1, OP_AVR1, "1001 1010 AAAA Abbb", OTY_ALBX, + {OP_ID(sbi), 0xff00, 0x9a00, 1, OP_AVR1, "1001 1010 AAAA Abbb", OTY_ALBX, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "--------", {"2", "1", "1", "1"}, ""}, - {OPCODE_cbi, 0xff00, 0x9800, 1, OP_AVR1, "1001 1000 AAAA Abbb", OTY_ALBX, + {OP_ID(cbi), 0xff00, 0x9800, 1, OP_AVR1, "1001 1000 AAAA Abbb", OTY_ALBX, "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "--------", {"2", "1", "1", "1"}, ""}, - {OPCODE_bst, 0xfe08, 0xfa00, 1, OP_AVR1, "1111 101r rrrr 0bbb", OTY_ALBI|OTY_RALL, + {OP_ID(bst), 0xfe08, 0xfa00, 1, OP_AVR1, "1111 101r rrrr 0bbb", OTY_ALBI|OTY_RALL, "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "-T------", {"1", "1", "1", "1"}, ""}, - {OPCODE_bld, 0xfe08, 0xf800, 1, OP_AVR1, "1111 100d dddd 0bbb", OTY_ALBI|OTY_RALL, + {OP_ID(bld), 0xfe08, 0xf800, 1, OP_AVR1, "1111 100d dddd 0bbb", OTY_ALBI|OTY_RALL, "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_sec, 0xffff, 0x9408, 1, OP_AVR1, "1001 0100 0000 1000", OTY_ALBI, + {OP_ID(sec), 0xffff, 0x9408, 1, OP_AVR1, "1001 0100 0000 1000", OTY_ALBI, "sec", "-", "Set Carry", "C <-- 1", "-------C", {"1", "1", "1", "1"}, "alias for bset 0"}, - {OPCODE_clc, 0xffff, 0x9488, 1, OP_AVR1, "1001 0100 1000 1000", OTY_ALBI, + {OP_ID(clc), 0xffff, 0x9488, 1, OP_AVR1, "1001 0100 1000 1000", OTY_ALBI, "clc", "-", "Clear Carry", "C <-- 0", "-------C", {"1", "1", "1", "1"}, "alias for bclr 0"}, - {OPCODE_sen, 0xffff, 0x9428, 1, OP_AVR1, "1001 0100 0010 1000", OTY_ALBI, + {OP_ID(sen), 0xffff, 0x9428, 1, OP_AVR1, "1001 0100 0010 1000", OTY_ALBI, "sen", "-", "Set Negative Flag", "N <-- 1", "-----N--", {"1", "1", "1", "1"}, "alias for bset 2"}, - {OPCODE_cln, 0xffff, 0x94a8, 1, OP_AVR1, "1001 0100 1010 1000", OTY_ALBI, + {OP_ID(cln), 0xffff, 0x94a8, 1, OP_AVR1, "1001 0100 1010 1000", OTY_ALBI, "cln", "-", "Clear Negative Flag", "N <-- 0", "-----N--", {"1", "1", "1", "1"}, "alias for bclr 2"}, - {OPCODE_sez, 0xffff, 0x9418, 1, OP_AVR1, "1001 0100 0001 1000", OTY_ALBI, + {OP_ID(sez), 0xffff, 0x9418, 1, OP_AVR1, "1001 0100 0001 1000", OTY_ALBI, "sez", "-", "Set Zero Flag", "Z <-- 1", "------Z-", {"1", "1", "1", "1"}, "alias for bset 1"}, - {OPCODE_clz, 0xffff, 0x9498, 1, OP_AVR1, "1001 0100 1001 1000", OTY_ALBI, + {OP_ID(clz), 0xffff, 0x9498, 1, OP_AVR1, "1001 0100 1001 1000", OTY_ALBI, "clz", "-", "Clear Zero Flag", "Z <-- 0", "------Z-", {"1", "1", "1", "1"}, "alias for bclr 1"}, - {OPCODE_sei, 0xffff, 0x9478, 1, OP_AVR1, "1001 0100 0111 1000", OTY_ALBX, + {OP_ID(sei), 0xffff, 0x9478, 1, OP_AVR1, "1001 0100 0111 1000", OTY_ALBX, "sei", "-", "Global Interrupt Enable", "I <-- 1", "I-------", {"1", "1", "1", "1"}, "alias for bset 7"}, - {OPCODE_cli, 0xffff, 0x94f8, 1, OP_AVR1, "1001 0100 1111 1000", OTY_ALBI, + {OP_ID(cli), 0xffff, 0x94f8, 1, OP_AVR1, "1001 0100 1111 1000", OTY_ALBI, "cli", "-", "Global Interrupt Disable", "I <-- 0", "I-------", {"1", "1", "1", "1"}, "alias for bclr 7"}, - {OPCODE_ses, 0xffff, 0x9448, 1, OP_AVR1, "1001 0100 0100 1000", OTY_ALBI, + {OP_ID(ses), 0xffff, 0x9448, 1, OP_AVR1, "1001 0100 0100 1000", OTY_ALBI, "ses", "-", "Set Signed Test Flag", "S <-- 1", "---S----", {"1", "1", "1", "1"}, "alias for bset 4"}, - {OPCODE_cls, 0xffff, 0x94c8, 1, OP_AVR1, "1001 0100 1100 1000", OTY_ALBI, + {OP_ID(cls), 0xffff, 0x94c8, 1, OP_AVR1, "1001 0100 1100 1000", OTY_ALBI, "cls", "-", "Clear Signed Test Flag", "S <-- 0", "---S----", {"1", "1", "1", "1"}, "alias for bclr 4"}, - {OPCODE_sev, 0xffff, 0x9438, 1, OP_AVR1, "1001 0100 0011 1000", OTY_ALBI, + {OP_ID(sev), 0xffff, 0x9438, 1, OP_AVR1, "1001 0100 0011 1000", OTY_ALBI, "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "----V---", {"1", "1", "1", "1"}, "alias for bset 3"}, - {OPCODE_clv, 0xffff, 0x94b8, 1, OP_AVR1, "1001 0100 1011 1000", OTY_ALBI, + {OP_ID(clv), 0xffff, 0x94b8, 1, OP_AVR1, "1001 0100 1011 1000", OTY_ALBI, "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "----V---", {"1", "1", "1", "1"}, "alias for bclr 3"}, - {OPCODE_set, 0xffff, 0x9468, 1, OP_AVR1, "1001 0100 0110 1000", OTY_ALBI, + {OP_ID(set), 0xffff, 0x9468, 1, OP_AVR1, "1001 0100 0110 1000", OTY_ALBI, "set", "-", "Set T in SREG", "T <-- 1", "-T------", {"1", "1", "1", "1"}, "alias for bset 6"}, - {OPCODE_clt, 0xffff, 0x94e8, 1, OP_AVR1, "1001 0100 1110 1000", OTY_ALBI, + {OP_ID(clt), 0xffff, 0x94e8, 1, OP_AVR1, "1001 0100 1110 1000", OTY_ALBI, "clt", "-", "Clear T in SREG", "T <-- 0", "-T------", {"1", "1", "1", "1"}, "alias for bclr 6"}, - {OPCODE_seh, 0xffff, 0x9458, 1, OP_AVR1, "1001 0100 0101 1000", OTY_ALBI, + {OP_ID(seh), 0xffff, 0x9458, 1, OP_AVR1, "1001 0100 0101 1000", OTY_ALBI, "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "--H-----", {"1", "1", "1", "1"}, "alias for bset 5"}, - {OPCODE_clh, 0xffff, 0x94d8, 1, OP_AVR1, "1001 0100 1101 1000", OTY_ALBI, + {OP_ID(clh), 0xffff, 0x94d8, 1, OP_AVR1, "1001 0100 1101 1000", OTY_ALBI, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "--H-----", {"1", "1", "1", "1"}, "alias for bclr 5"}, // MCU Control Instructions - {OPCODE_break, 0xffff, 0x9598, 1, OP_AVR1, "1001 0101 1001 1000", OTY_MCUX, + {OP_ID(break), 0xffff, 0x9598, 1, OP_AVR1, "1001 0101 1001 1000", OTY_MCUX, "break", "-", "Break", "(cf documentation)", "--------", {"-", "-", "-", "-"}, "not available on all parts"}, - {OPCODE_nop, 0xffff, 0x0000, 1, OP_AVR1, "0000 0000 0000 0000", OTY_MCUI, + {OP_ID(nop), 0xffff, 0x0000, 1, OP_AVR1, "0000 0000 0000 0000", OTY_MCUI, "nop", "-", "No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_sleep, 0xffff, 0x9588, 1, OP_AVR1, "1001 0101 1000 1000", OTY_MCUX, + {OP_ID(sleep), 0xffff, 0x9588, 1, OP_AVR1, "1001 0101 1000 1000", OTY_MCUX, "sleep", "-", "Sleep", "(cf documentation)", "--------", {"-", "-", "-", "-"}, ""}, - {OPCODE_wdr, 0xffff, 0x95a8, 1, OP_AVR1, "1001 0101 1010 1000", OTY_MCUI, + {OP_ID(wdr), 0xffff, 0x95a8, 1, OP_AVR1, "1001 0101 1010 1000", OTY_MCUI, "wdr", "-", "Watchdog Reset", "(cf documentation)", "--------", {"1", "1", "1", "1"}, ""}, // Unallocated codes - {OPCODE_x_nop_1, 0xff00, 0x0000, 1, OP_AVR_ILL, "0000 0000 xxxx xxxx", OTY_MCUI, + {OP_ID(u_nop_1), 0xff00, 0x0000, 1, OP_AVR_ILL, "0000 0000 xxxx xxxx", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, - {OPCODE_x_nop_2, 0xfe0f, 0x9003, 1, OP_AVR_ILL, "1001 000x xxxx 0011", OTY_MCUI, + {OP_ID(u_nop_2), 0xfe0f, 0x9003, 1, OP_AVR_ILL, "1001 000x xxxx 0011", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_nop_3, 0xfe0f, 0x9008, 1, OP_AVR_ILL, "1001 000x xxxx 1000", OTY_MCUI, + {OP_ID(u_nop_3), 0xfe0f, 0x9008, 1, OP_AVR_ILL, "1001 000x xxxx 1000", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_nop_4, 0xfe0f, 0x900b, 1, OP_AVR_ILL, "1001 000x xxxx 1011", OTY_MCUI, + {OP_ID(u_nop_4), 0xfe0f, 0x900b, 1, OP_AVR_ILL, "1001 000x xxxx 1011", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_nop_5, 0xfe0f, 0x9203, 1, OP_AVR_ILL, "1001 001x xxxx 0011", OTY_MCUI, + {OP_ID(u_nop_5), 0xfe0f, 0x9203, 1, OP_AVR_ILL, "1001 001x xxxx 0011", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_nop_6, 0xfe0f, 0x9208, 1, OP_AVR_ILL, "1001 001x xxxx 1000", OTY_MCUI, + {OP_ID(u_nop_6), 0xfe0f, 0x9208, 1, OP_AVR_ILL, "1001 001x xxxx 1000", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_nop_7, 0xfe0f, 0x920b, 1, OP_AVR_ILL, "1001 001x xxxx 1011", OTY_MCUI, + {OP_ID(u_nop_7), 0xfe0f, 0x920b, 1, OP_AVR_ILL, "1001 001x xxxx 1011", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_icall, 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPX, + {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPX, "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, - {OPCODE_x_eicall, 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, + {OP_ID(u_eicall), 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, "u/eicall", "-", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, "xxx != 000"}, - {OPCODE_x_ret, 0xff9f, 0x9508, 1, OP_AVR_ILL, "1001 0101 0xx0 1000", OTY_JMPX, + {OP_ID(u_ret), 0xff9f, 0x9508, 1, OP_AVR_ILL, "1001 0101 0xx0 1000", OTY_JMPX, "u/ret", "-", "alt Subroutine Return", "PC <-- STACK", "--------", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, - {OPCODE_x_reti, 0xff9f, 0x9518, 1, OP_AVR_ILL, "1001 0101 0xx1 1000", OTY_JMPX, + {OP_ID(u_reti), 0xff9f, 0x9518, 1, OP_AVR_ILL, "1001 0101 0xx1 1000", OTY_JMPX, "u/reti", "-", "alt Interrupt Return", "PC <-- STACK", "I-------", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, - {OPCODE_x_nop_8, 0xffff, 0x95b8, 1, OP_AVR_ILL, "1001 0101 1011 1000", OTY_MCUI, + {OP_ID(u_nop_8), 0xffff, 0x95b8, 1, OP_AVR_ILL, "1001 0101 1011 1000", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_nop_9, 0xfe0f, 0x9404, 1, OP_AVR_ILL, "1001 010x xxxx 0100", OTY_MCUI, + {OP_ID(u_nop_9), 0xfe0f, 0x9404, 1, OP_AVR_ILL, "1001 010x xxxx 0100", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_nop_a, 0xff0f, 0x950b, 1, OP_AVR_ILL, "1001 0101 xxxx 1011", OTY_MCUI, + {OP_ID(u_nop_a), 0xff0f, 0x950b, 1, OP_AVR_ILL, "1001 0101 xxxx 1011", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_ijmp, 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI, + {OP_ID(u_ijmp), 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI, "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, "xxx != 000"}, - {OPCODE_x_eijmp, 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPI, + {OP_ID(u_eijmp), 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPI, "u/eijmp", "-", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, "xxx != 000"}, - {OPCODE_x_bld, 0xfe08, 0xf808, 1, OP_AVR_ILL, "1111 100d dddd 1bbb", OTY_ALBI|OTY_RALL, + {OP_ID(u_bld), 0xfe08, 0xf808, 1, OP_AVR_ILL, "1111 100d dddd 1bbb", OTY_ALBI|OTY_RALL, "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "--------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_bst, 0xfe08, 0xfa08, 1, OP_AVR_ILL, "1111 101r rrrr 1bbb", OTY_ALBI|OTY_RALL, + {OP_ID(u_bst), 0xfe08, 0xfa08, 1, OP_AVR_ILL, "1111 101r rrrr 1bbb", OTY_ALBI|OTY_RALL, "u/bst", "Rr, b", "alt Bit Store from Register to T", "T <-- Rr(b)", "-T------", {"1", "1", "1", "1"}, ""}, - {OPCODE_x_sbrc, 0xfe08, 0xfc08, 1, OP_AVR_ILL, "1111 110r rrrr 1bbb", OTY_SKPI|OTY_RALL, + {OP_ID(u_sbrc), 0xfe08, 0xfc08, 1, OP_AVR_ILL, "1111 110r rrrr 1bbb", OTY_SKPI|OTY_RALL, "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, - {OPCODE_x_sbrs, 0xfe08, 0xfe08, 1, OP_AVR_ILL, "1111 111r rrrr 1bbb", OTY_SKPI|OTY_RALL, + {OP_ID(u_sbrs), 0xfe08, 0xfe08, 1, OP_AVR_ILL, "1111 111r rrrr 1bbb", OTY_SKPI|OTY_RALL, "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, }; diff --git a/src/disasm.c b/src/disasm.c index ccd0718a..67f9b79b 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -420,26 +420,26 @@ int disasm_init(const AVRPART *p) { Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); // Also register unallocated opcodes - Register_Opcode(nop_Callback, "0000 0000 xxxx xxxx", OPCODE_x_nop_1); - Register_Opcode(nop_Callback, "1001 000x xxxx 0011", OPCODE_x_nop_2); - Register_Opcode(nop_Callback, "1001 000x xxxx 1000", OPCODE_x_nop_3); - Register_Opcode(nop_Callback, "1001 000x xxxx 1011", OPCODE_x_nop_4); - Register_Opcode(nop_Callback, "1001 001x xxxx 0011", OPCODE_x_nop_5); - Register_Opcode(nop_Callback, "1001 001x xxxx 1000", OPCODE_x_nop_6); - Register_Opcode(nop_Callback, "1001 001x xxxx 1011", OPCODE_x_nop_7); - Register_Opcode(icall_Callback, "1001 0101 xxx0 1001", OPCODE_x_icall); - Register_Opcode(eicall_Callback, "1001 0101 xxx1 1001", OPCODE_x_eicall); - Register_Opcode(ret_Callback, "1001 0101 0xx0 1000", OPCODE_x_ret); - Register_Opcode(reti_Callback, "1001 0101 0xx1 1000", OPCODE_x_reti); - Register_Opcode(nop_Callback, "1001 0101 1011 1000", OPCODE_x_nop_8); - Register_Opcode(nop_Callback, "1001 010x xxxx 0100", OPCODE_x_nop_9); - Register_Opcode(nop_Callback, "1001 0101 xxxx 1011", OPCODE_x_nop_a); - Register_Opcode(ijmp_Callback, "1001 0100 xxx0 1001", OPCODE_x_ijmp); - Register_Opcode(eijmp_Callback, "1001 0100 xxx1 1001", OPCODE_x_eijmp); - Register_Opcode(bld_Callback, "1111 100d dddd 1bbb", OPCODE_x_bld); - Register_Opcode(bst_Callback, "1111 101d dddd 1bbb", OPCODE_x_bst); - Register_Opcode(sbrc_Callback, "1111 110r rrrr 1bbb", OPCODE_x_sbrc); - Register_Opcode(sbrs_Callback, "1111 111r rrrr 1bbb", OPCODE_x_sbrs); + Register_Opcode(nop_Callback, "0000 0000 xxxx xxxx", OPCODE_u_nop_1); + Register_Opcode(nop_Callback, "1001 000x xxxx 0011", OPCODE_u_nop_2); + Register_Opcode(nop_Callback, "1001 000x xxxx 1000", OPCODE_u_nop_3); + Register_Opcode(nop_Callback, "1001 000x xxxx 1011", OPCODE_u_nop_4); + Register_Opcode(nop_Callback, "1001 001x xxxx 0011", OPCODE_u_nop_5); + Register_Opcode(nop_Callback, "1001 001x xxxx 1000", OPCODE_u_nop_6); + Register_Opcode(nop_Callback, "1001 001x xxxx 1011", OPCODE_u_nop_7); + Register_Opcode(icall_Callback, "1001 0101 xxx0 1001", OPCODE_u_icall); + Register_Opcode(eicall_Callback, "1001 0101 xxx1 1001", OPCODE_u_eicall); + Register_Opcode(ret_Callback, "1001 0101 0xx0 1000", OPCODE_u_ret); + Register_Opcode(reti_Callback, "1001 0101 0xx1 1000", OPCODE_u_reti); + Register_Opcode(nop_Callback, "1001 0101 1011 1000", OPCODE_u_nop_8); + Register_Opcode(nop_Callback, "1001 010x xxxx 0100", OPCODE_u_nop_9); + Register_Opcode(nop_Callback, "1001 0101 xxxx 1011", OPCODE_u_nop_a); + Register_Opcode(ijmp_Callback, "1001 0100 xxx0 1001", OPCODE_u_ijmp); + Register_Opcode(eijmp_Callback, "1001 0100 xxx1 1001", OPCODE_u_eijmp); + Register_Opcode(bld_Callback, "1111 100d dddd 1bbb", OPCODE_u_bld); + Register_Opcode(bst_Callback, "1111 101d dddd 1bbb", OPCODE_u_bst); + Register_Opcode(sbrc_Callback, "1111 110r rrrr 1bbb", OPCODE_u_sbrc); + Register_Opcode(sbrs_Callback, "1111 111r rrrr 1bbb", OPCODE_u_sbrs); qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); diff --git a/src/libavrdude.h b/src/libavrdude.h index 740310e0..b1203a45 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1538,11 +1538,11 @@ typedef enum { OPCODE_ses, OPCODE_cls, OPCODE_sev, OPCODE_clv, OPCODE_set, OPCODE_clt, OPCODE_seh, OPCODE_clh, OPCODE_break, OPCODE_nop, OPCODE_sleep, OPCODE_wdr, - OPCODE_x_nop_1, OPCODE_x_nop_2, OPCODE_x_nop_3, OPCODE_x_nop_4, - OPCODE_x_nop_5, OPCODE_x_nop_6, OPCODE_x_nop_7, OPCODE_x_icall, - OPCODE_x_eicall, OPCODE_x_ret, OPCODE_x_reti, OPCODE_x_nop_8, - OPCODE_x_nop_9, OPCODE_x_nop_a, OPCODE_x_ijmp, OPCODE_x_eijmp, - OPCODE_x_bld, OPCODE_x_bst, OPCODE_x_sbrc, OPCODE_x_sbrs, + OPCODE_u_nop_1, OPCODE_u_nop_2, OPCODE_u_nop_3, OPCODE_u_nop_4, + OPCODE_u_nop_5, OPCODE_u_nop_6, OPCODE_u_nop_7, OPCODE_u_icall, + OPCODE_u_eicall, OPCODE_u_ret, OPCODE_u_reti, OPCODE_u_nop_8, + OPCODE_u_nop_9, OPCODE_u_nop_a, OPCODE_u_ijmp, OPCODE_u_eijmp, + OPCODE_u_bld, OPCODE_u_bst, OPCODE_u_sbrc, OPCODE_u_sbrs, } AVR_opcode; typedef struct { @@ -1615,17 +1615,18 @@ typedef enum { #define OTY_CONSTRAINT 0x2000 // Opcode has constraints: Rr == Rd (tst, clr, lsl, rol) typedef struct { - AVR_opcode mnemo; // OPCODE_add, ... + AVR_opcode mnemo; // Eg, OPCODE_add + const char *idname; // Unique id, eg, "ldx_1" (for error msgs or debugging) int mask, value, nwords; - AVR_archlevel avrlevel; // Eg, OP_AVR1 - const char *bits; // Eg, "0000 11rd dddd rrrr" - int type; // Eg, OTY_ALBI|OTY_RALL + AVR_archlevel avrlevel; // OP_AVR1 + const char *bits; // "0000 11rd dddd rrrr" + int type; // OTY_ALBI|OTY_RALL const char *opcode, // "add" *operands, // "Rd, Rr" *description, // "Add without Carry" *operation, // "Rd <-- Rd + Rr" - *flags, // "Z,C,N,V,S,H" + *flags, // "--HSVNZC" *clock[OP_AVR_cycle_N], // Timings for AVRe, AVRxm, AVRxt and AVRrc *remarks; } AVR_opcode_data; From d8fea60471ff4b02963909c20103864f00623b06 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 20 Jul 2024 15:55:00 +0100 Subject: [PATCH 329/422] Reorder avr_opcodes table so that first match is reasonable - Unallocated opcodes come last - Specific reduced-core sts/lds opcodes are penultimate - More specific opcodes come before less specific ones (clr before eor) - Opcodes labelled alias come behind those not labelled so --- src/avr_opcodes.c | 93 +++++++++++++++++++++++++++-------------------- src/libavrdude.h | 61 ++++++++++++++++--------------- 2 files changed, 84 insertions(+), 70 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index c3e83925..03a2edf6 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -20,16 +20,35 @@ #include "libavrdude.h" +/* + * AVR opcode table + * + * - Order makes the first match of a 16-bit opcode to be a "good" representation + * - Order of enums OPCODE_... in libavedude.h must align with table order here + * + */ const AVR_opcode_data avr_opcodes[164] = { #define OP_ID(nam) OPCODE_##nam, #nam // Arithmetic and Logic Instructions + {OP_ID(lsl), 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "--H-VNZC", + {"1", "1", "1", "1"}, "alias for add Rd, Rd"}, {OP_ID(add), 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11rd dddd rrrr", OTY_ALBI|OTY_RALL, "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd + Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, + {OP_ID(rol), 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "--H-VNZC", + {"1", "1", "1", "1"}, "alias for adc Rd, Rd"}, {OP_ID(adc), 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd + Rr + C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, + {OP_ID(ror), 0xfe0f, 0x9407, 1, OP_AVR1, "1001 010d dddd 0111", OTY_ALBI|OTY_RALL, + "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", + {"1", "1", "1", "1"}, ""}, + {OP_ID(asr), 0xfe0f, 0x9405, 1, OP_AVR1, "1001 010d dddd 0101", OTY_ALBI|OTY_RALL, + "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", + {"1", "1", "1", "1"}, ""}, {OP_ID(adiw), 0xff00, 0x9600, 1, OP_AVR2nRC, "1001 0110 KKdd KKKK", OTY_ALBI|OTY_RW24, "adiw", "Rd, K", "Add Immediate to Word", "Rd+1:Rd <-- Rd+1:Rd + K", "---SVNZC", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, @@ -48,18 +67,30 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(sbiw), 0xff00, 0x9700, 1, OP_AVR2nRC, "1001 0111 KKdd KKKK", OTY_ALBI|OTY_RW24, "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd - K", "---SVNZC", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, + {OP_ID(tst), 0xfc00, 0x2000, 1, OP_AVR1, "0010 00r= rrrr ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "---SVNZ-", + {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, {OP_ID(and), 0xfc00, 0x2000, 1, OP_AVR1, "0010 00rd dddd rrrr", OTY_ALBI|OTY_RALL, "and", "Rd, Rr", "Logical And", "Rd <-- Rd & Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OP_ID(andi), 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, "andi", "Rd, K", "Logical And with Immediate", "Rd <-- Rd & K", "---SVNZ-", {"1", "1", "1", "1"}, "d = 16..31"}, + {OP_ID(cbr), 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, + "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "---SVNZ-", + {"1", "1", "1", "1"}, "alias for andi Rd, (0xff - K); d = 16..31"}, {OP_ID(or), 0xfc00, 0x2800, 1, OP_AVR1, "0010 10rd dddd rrrr", OTY_ALBI|OTY_RALL, "or", "Rd, Rr", "Logical Or", "Rd <-- Rd | Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OP_ID(ori), 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, "ori", "Rd, K", "Logical Or with Immediate", "Rd <-- Rd | K", "---SVNZ-", {"1", "1", "1", "1"}, "d = 16..31"}, + {OP_ID(sbr), 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, + "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "---SVNZ-", + {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, + {OP_ID(clr), 0xfc00, 0x2400, 1, OP_AVR1, "0010 01d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, + "clr", "Rd", "Clear Register", "Rd <-- Rd ^ Rd", "---SVNZ-", + {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, {OP_ID(eor), 0xfc00, 0x2400, 1, OP_AVR1, "0010 01rd dddd rrrr", OTY_ALBI|OTY_RALL, "eor", "Rd, Rr", "Exclusive or", "Rd <-- Rd ^ Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, @@ -69,27 +100,12 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(neg), 0xfe0f, 0x9401, 1, OP_AVR1, "1001 010d dddd 0001", OTY_ALBI|OTY_RALL, "neg", "Rd", "Two's Complement", "Rd <-- 0x00 - Rd", "--HSVNZC", {"1", "1", "1", "1"}, ""}, - {OP_ID(sbr), 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, - "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "---SVNZ-", - {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, - {OP_ID(cbr), 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, - "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "---SVNZ-", - {"1", "1", "1", "1"}, "alias for andi Rd, (0xff - K); d = 16..31"}, {OP_ID(inc), 0xfe0f, 0x9403, 1, OP_AVR1, "1001 010d dddd 0011", OTY_ALBI|OTY_RALL, "inc", "Rd", "Increment", "Rd <-- Rd + 1", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OP_ID(dec), 0xfe0f, 0x940a, 1, OP_AVR1, "1001 010d dddd 1010", OTY_ALBI|OTY_RALL, "dec", "Rd", "Decrement", "Rd <-- Rd - 1", "---SVNZ-", {"1", "1", "1", "1"}, ""}, - {OP_ID(tst), 0xfc00, 0x2000, 1, OP_AVR1, "0010 00r= rrrr ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "---SVNZ-", - {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, - {OP_ID(clr), 0xfc00, 0x2400, 1, OP_AVR1, "0010 01d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "clr", "Rd", "Clear Register", "Rd <-- Rd ^ Rd", "---SVNZ-", - {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, - {OP_ID(ser), 0xff0f, 0xef0f, 1, OP_AVR1, "1110 1111 dddd 1111", OTY_ALBI|OTY_RUPP, - "ser", "Rd", "Set Register", "Rd <-- 0xff", "--------", - {"1", "1", "1", "1"}, "alias for ldi Rd, 0xff; d = 16..31"}, {OP_ID(mul), 0xfc00, 0x9c00, 1, OP_AVR4, "1001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "------ZC", {"2", "2", "2", "n/a"}, ""}, @@ -235,15 +251,15 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(movw), 0xff00, 0x0100, 1, OP_AVR25, "0000 0001 dddd rrrr", OTY_XFRI|OTY_REVN, "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "--------", {"1", "1", "1", "n/a"}, "d, r in {0, 2, ..., 30}"}, + {OP_ID(ser), 0xff0f, 0xef0f, 1, OP_AVR1, "1110 1111 dddd 1111", OTY_ALBI|OTY_RUPP, + "ser", "Rd", "Set Register", "Rd <-- 0xff", "--------", + {"1", "1", "1", "1"}, "alias for ldi Rd, 0xff; d = 16..31"}, {OP_ID(ldi), 0xf000, 0xe000, 1, OP_AVR1, "1110 KKKK dddd KKKK", OTY_XFRI|OTY_RUPP, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "--------", {"1", "1", "1", "1"}, "d = 16..31"}, {OP_ID(lds), 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "--------", {"2", "3", "3", "2"}, ""}, - {OP_ID(lds_rc), 0xf800, 0xa000, 1, OP_AVR_RC, "1010 0aaa dddd aaaa", OTY_XFRX|OTY_RUPP, - "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "--------", - {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, {OP_ID(ld_1), 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "--------", {"2", "2", "2", "1/2"}, ""}, @@ -280,9 +296,6 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(sts), 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "--------", {"2", "2", "2", "1"}, ""}, - {OP_ID(sts_rc), 0xf800, 0xa800, 1, OP_AVR_RC, "1010 1aaa rrrr aaaa", OTY_XFRX|OTY_RUPP, - "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "--------", - {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, {OP_ID(st_1), 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "--------", {"2", "1", "1", "1"}, ""}, @@ -366,30 +379,12 @@ const AVR_opcode_data avr_opcodes[164] = { {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions - {OP_ID(lsl), 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "--H-VNZC", - {"1", "1", "1", "1"}, "alias for add Rd, Rd"}, {OP_ID(lsr), 0xfe0f, 0x9406, 1, OP_AVR1, "1001 010d dddd 0110", OTY_ALBI|OTY_RALL, "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, - {OP_ID(rol), 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "--H-VNZC", - {"1", "1", "1", "1"}, "alias for adc Rd, Rd"}, - {OP_ID(ror), 0xfe0f, 0x9407, 1, OP_AVR1, "1001 010d dddd 0111", OTY_ALBI|OTY_RALL, - "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", - {"1", "1", "1", "1"}, ""}, - {OP_ID(asr), 0xfe0f, 0x9405, 1, OP_AVR1, "1001 010d dddd 0101", OTY_ALBI|OTY_RALL, - "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", - {"1", "1", "1", "1"}, ""}, {OP_ID(swap), 0xfe0f, 0x9402, 1, OP_AVR1, "1001 010d dddd 0010", OTY_ALBI|OTY_RALL, "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "--------", {"1", "1", "1", "1"}, ""}, - {OP_ID(bset), 0xff8f, 0x9408, 1, OP_AVR1, "1001 0100 0sss 1000", OTY_ALBX, - "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG-bit", - {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, - {OP_ID(bclr), 0xff8f, 0x9488, 1, OP_AVR1, "1001 0100 1sss 1000", OTY_ALBI, - "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG-bit", - {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, {OP_ID(sbi), 0xff00, 0x9a00, 1, OP_AVR1, "1001 1010 AAAA Abbb", OTY_ALBX, "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "--------", {"2", "1", "1", "1"}, ""}, @@ -450,6 +445,12 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(clh), 0xffff, 0x94d8, 1, OP_AVR1, "1001 0100 1101 1000", OTY_ALBI, "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "--H-----", {"1", "1", "1", "1"}, "alias for bclr 5"}, + {OP_ID(bset), 0xff8f, 0x9408, 1, OP_AVR1, "1001 0100 0sss 1000", OTY_ALBX, + "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG-bit", + {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, + {OP_ID(bclr), 0xff8f, 0x9488, 1, OP_AVR1, "1001 0100 1sss 1000", OTY_ALBI, + "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG-bit", + {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, // MCU Control Instructions {OP_ID(break), 0xffff, 0x9598, 1, OP_AVR1, "1001 0101 1001 1000", OTY_MCUX, @@ -465,7 +466,18 @@ const AVR_opcode_data avr_opcodes[164] = { "wdr", "-", "Watchdog Reset", "(cf documentation)", "--------", {"1", "1", "1", "1"}, ""}, - // Unallocated codes + /* + * Special 16-bit lds/sts opcodes for reduced-core ATtinys only; they conflict with + * regular ldd Rd, Y+q; ldd Rd, Z+q; std Y+q, Rr; std Z+q, Rr opcodes + */ + {OP_ID(lds_rc), 0xf800, 0xa000, 1, OP_AVR_RC, "1010 0aaa dddd aaaa", OTY_XFRX|OTY_RUPP, + "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "--------", + {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, + {OP_ID(sts_rc), 0xf800, 0xa800, 1, OP_AVR_RC, "1010 1aaa rrrr aaaa", OTY_XFRX|OTY_RUPP, + "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "--------", + {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, + + // Unallocated codes: they are said(!) to do the following {OP_ID(u_nop_1), 0xff00, 0x0000, 1, OP_AVR_ILL, "0000 0000 xxxx xxxx", OTY_MCUI, "u/nop", "-", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, @@ -527,3 +539,4 @@ const AVR_opcode_data avr_opcodes[164] = { "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, }; + diff --git a/src/libavrdude.h b/src/libavrdude.h index b1203a45..d02b5f78 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1501,43 +1501,44 @@ typedef struct { unsigned char Used; } Disasm_IO_Register; +// Order of enums must align with avr_opcodes[] table order typedef enum { - OPCODE_add, OPCODE_adc, OPCODE_adiw, OPCODE_sub, + OPCODE_lsl, OPCODE_add, OPCODE_rol, OPCODE_adc, + OPCODE_ror, OPCODE_asr, OPCODE_adiw, OPCODE_sub, OPCODE_subi, OPCODE_sbc, OPCODE_sbci, OPCODE_sbiw, - OPCODE_and, OPCODE_andi, OPCODE_or, OPCODE_ori, - OPCODE_eor, OPCODE_com, OPCODE_neg, OPCODE_sbr, - OPCODE_cbr, OPCODE_inc, OPCODE_dec, OPCODE_tst, - OPCODE_clr, OPCODE_ser, OPCODE_mul, OPCODE_muls, - OPCODE_mulsu, OPCODE_fmul, OPCODE_fmuls, OPCODE_fmulsu, - OPCODE_des, OPCODE_rjmp, OPCODE_ijmp, OPCODE_eijmp, - OPCODE_jmp, OPCODE_rcall, OPCODE_icall, OPCODE_eicall, - OPCODE_call, OPCODE_ret, OPCODE_reti, OPCODE_cpse, - OPCODE_cp, OPCODE_cpc, OPCODE_cpi, OPCODE_sbrc, - OPCODE_sbrs, OPCODE_sbic, OPCODE_sbis, OPCODE_brcs, - OPCODE_brlo, OPCODE_breq, OPCODE_brmi, OPCODE_brvs, - OPCODE_brlt, OPCODE_brhs, OPCODE_brts, OPCODE_brie, - OPCODE_brbs, OPCODE_brcc, OPCODE_brsh, OPCODE_brne, - OPCODE_brpl, OPCODE_brvc, OPCODE_brge, OPCODE_brhc, - OPCODE_brtc, OPCODE_brid, OPCODE_brbc, OPCODE_mov, - OPCODE_movw, OPCODE_ldi, OPCODE_lds, OPCODE_lds_rc, - OPCODE_ld_1, OPCODE_ld_2, OPCODE_ld_3, OPCODE_ld_4, - OPCODE_ld_5, OPCODE_ld_6, OPCODE_ldd_1, OPCODE_ld_7, - OPCODE_ld_8, OPCODE_ld_9, OPCODE_ldd_2, OPCODE_sts, - OPCODE_sts_rc, OPCODE_st_1, OPCODE_st_2, OPCODE_st_3, - OPCODE_st_4, OPCODE_st_5, OPCODE_st_6, OPCODE_std_1, - OPCODE_st_7, OPCODE_st_8, OPCODE_st_9, OPCODE_std_2, - OPCODE_lpm_1, OPCODE_lpm_2, OPCODE_lpm_3, OPCODE_elpm_1, - OPCODE_elpm_2, OPCODE_elpm_3, OPCODE_spm, OPCODE_spm_zz, - OPCODE_in, OPCODE_out, OPCODE_push, OPCODE_pop, - OPCODE_xch, OPCODE_las, OPCODE_lac, OPCODE_lat, - OPCODE_lsl, OPCODE_lsr, OPCODE_rol, OPCODE_ror, - OPCODE_asr, OPCODE_swap, OPCODE_bset, OPCODE_bclr, + OPCODE_tst, OPCODE_and, OPCODE_andi, OPCODE_cbr, + OPCODE_or, OPCODE_ori, OPCODE_sbr, OPCODE_clr, + OPCODE_eor, OPCODE_com, OPCODE_neg, OPCODE_inc, + OPCODE_dec, OPCODE_mul, OPCODE_muls, OPCODE_mulsu, + OPCODE_fmul, OPCODE_fmuls, OPCODE_fmulsu, OPCODE_des, + OPCODE_rjmp, OPCODE_ijmp, OPCODE_eijmp, OPCODE_jmp, + OPCODE_rcall, OPCODE_icall, OPCODE_eicall, OPCODE_call, + OPCODE_ret, OPCODE_reti, OPCODE_cpse, OPCODE_cp, + OPCODE_cpc, OPCODE_cpi, OPCODE_sbrc, OPCODE_sbrs, + OPCODE_sbic, OPCODE_sbis, OPCODE_brcs, OPCODE_brlo, + OPCODE_breq, OPCODE_brmi, OPCODE_brvs, OPCODE_brlt, + OPCODE_brhs, OPCODE_brts, OPCODE_brie, OPCODE_brbs, + OPCODE_brcc, OPCODE_brsh, OPCODE_brne, OPCODE_brpl, + OPCODE_brvc, OPCODE_brge, OPCODE_brhc, OPCODE_brtc, + OPCODE_brid, OPCODE_brbc, OPCODE_mov, OPCODE_movw, + OPCODE_ser, OPCODE_ldi, OPCODE_lds, OPCODE_ld_1, + OPCODE_ld_2, OPCODE_ld_3, OPCODE_ld_4, OPCODE_ld_5, + OPCODE_ld_6, OPCODE_ldd_1, OPCODE_ld_7, OPCODE_ld_8, + OPCODE_ld_9, OPCODE_ldd_2, OPCODE_sts, OPCODE_st_1, + OPCODE_st_2, OPCODE_st_3, OPCODE_st_4, OPCODE_st_5, + OPCODE_st_6, OPCODE_std_1, OPCODE_st_7, OPCODE_st_8, + OPCODE_st_9, OPCODE_std_2, OPCODE_lpm_1, OPCODE_lpm_2, + OPCODE_lpm_3, OPCODE_elpm_1, OPCODE_elpm_2, OPCODE_elpm_3, + OPCODE_spm, OPCODE_spm_zz, OPCODE_in, OPCODE_out, + OPCODE_push, OPCODE_pop, OPCODE_xch, OPCODE_las, + OPCODE_lac, OPCODE_lat, OPCODE_lsr, OPCODE_swap, OPCODE_sbi, OPCODE_cbi, OPCODE_bst, OPCODE_bld, OPCODE_sec, OPCODE_clc, OPCODE_sen, OPCODE_cln, OPCODE_sez, OPCODE_clz, OPCODE_sei, OPCODE_cli, OPCODE_ses, OPCODE_cls, OPCODE_sev, OPCODE_clv, OPCODE_set, OPCODE_clt, OPCODE_seh, OPCODE_clh, - OPCODE_break, OPCODE_nop, OPCODE_sleep, OPCODE_wdr, + OPCODE_bset, OPCODE_bclr, OPCODE_break, OPCODE_nop, + OPCODE_sleep, OPCODE_wdr, OPCODE_lds_rc, OPCODE_sts_rc, OPCODE_u_nop_1, OPCODE_u_nop_2, OPCODE_u_nop_3, OPCODE_u_nop_4, OPCODE_u_nop_5, OPCODE_u_nop_6, OPCODE_u_nop_7, OPCODE_u_icall, OPCODE_u_eicall, OPCODE_u_ret, OPCODE_u_reti, OPCODE_u_nop_8, From c3732b098e7be013057559c3dafee8346676ee8d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 20 Jul 2024 17:21:50 +0100 Subject: [PATCH 330/422] Add utility functions to avr_opcode.c --- src/avr_opcodes.c | 89 +++++++++++++++++++++++++++++++++++++++++++---- src/disasm.c | 2 +- src/libavrdude.h | 6 ++++ 3 files changed, 90 insertions(+), 7 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 03a2edf6..af05c5bc 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -23,10 +23,59 @@ /* * AVR opcode table * - * - Order makes the first match of a 16-bit opcode to be a "good" representation - * - Order of enums OPCODE_... in libavedude.h must align with table order here + * - Order of enums OPCODE_... in libavedude.h must align with table + * + * - Order makes the first match of a 16-bit opcode a "good" one + * + Unallocated opcodes come last + * + Specific reduced-core sts/lds opcodes are penultimate + * + More specific opcodes before less specific ones (clr before eor) + * + Opcodes labelled alias come behind those not labelled so + * + * - The operand field has a very specific syntax as follows + * + * A 5-bit I/O address (sbic, sbis, sbi, cbi) + * 6-bit I/O address (in, out) + * + * a 7-bit address in weird format 0x40..0xbf for reduced-core (lds, sts) + * + * b bit number 0..7 (sbrc, sbrs, sbic, sbis, sbi, cbi, bst, bld, u/bld, + * u/bst, u/sbrc, u/sbrs) + * + * k 7-bit signed relative address in words for 2*k+2 bytes PC offset in + * [-126, 128] (brcs, brlo, breq, brmi, brvs, brlt, brhs, brts, brie, + brcc, brsh, brne, brpl, brvc, brge, brhc, brtc, brid, brbs, brbc) + * 12-bit signed relative address in words for 2*k+2 bytes PC offset in + * [-4094, 4096] (rjmp, rcall) + * 16-bit absolute byte address (lds, sts) + * 22-bit absolute word address for the PC (jmp, call) + * + * K 4-bit round index 0..15 (des) + * 6-bit constant 0..63 (adiw, sbiw) + * 8-bit constant 0..255 (subi, sbci, andi, ori, sbr, cbr, cpi, ldi) + * + * q 6-bit displacement 0..63 (ldd, ldd, std, std) + * + * Rd 2-bit destination register in r24, r26, r28, r30 (adiw, sbiw) + * 3-bit dest register in r16, ..., r23 (mulsu, fmul, fmuls, fmulsu) + * 4-bit destination register in r16, ..., r31 (subi, sbci, andi, ori, + * sbr, cbr, ser, muls, cpi, ldi, lds) + * 4-bit destination register in r0, r2, ..., r30 (movw) + * 5-bit destination register in r0, r1, ..., r31 (add, adc, sub, sbc, + * and, or, eor, com, neg, inc, dec, clr, mul, cpse, cp, cpc, mov, + * lds, ld, ldd, lpm, elpm, in, pop, xch, las, lac, lat, lsl, lsr, + * rol, ror, asr, swap, bld, u/bld) + * + * Rr 3-bit source register in r16, ..., r23 (mulsu, fmul, fmuls, fmulsu) + * 4-bit source register in r16, ..., r31 (muls, sts) + * 4-bit source register in r0, ..., r30 (movw) + * 5-bit source register in r0, ..., r31 (add, adc, sub, sbc, and, or, + * eor, tst, mul, cpse, cp, cpc, sbrc, sbrs, mov, sts, st, std, + * out, push, bst, u/bst, u/sbrc, u/sbrs) + * + * s SREG bit number 0..7 (brbs, brbc, bset, bclr) * */ + const AVR_opcode_data avr_opcodes[164] = { #define OP_ID(nam) OPCODE_##nam, #nam @@ -138,7 +187,7 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(eijmp), 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, "eijmp", "-", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, ""}, - {OP_ID(jmp), 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, + {OP_ID(jmp), 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, "jmp", "k", "Jump", "PC <-- k", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(rcall), 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, @@ -150,7 +199,7 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, "eicall", "-", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, ""}, - {OP_ID(call), 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, + {OP_ID(call), 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "--------", {"4/5", "3/4", "3/4", "n/a"}, ""}, {OP_ID(ret), 0xffff, 0x9508, 1, OP_AVR1, "1001 0101 0000 1000", OTY_JMPX, @@ -257,7 +306,7 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(ldi), 0xf000, 0xe000, 1, OP_AVR1, "1110 KKKK dddd KKKK", OTY_XFRI|OTY_RUPP, "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "--------", {"1", "1", "1", "1"}, "d = 16..31"}, - {OP_ID(lds), 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, + {OP_ID(lds), 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "--------", {"2", "3", "3", "2"}, ""}, {OP_ID(ld_1), 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, @@ -293,7 +342,7 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(ldd_2), 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "--------", {"2", "3", "2", "n/a"}, ""}, - {OP_ID(sts), 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, + {OP_ID(sts), 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "--------", {"2", "2", "2", "1"}, ""}, {OP_ID(st_1), 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, @@ -540,3 +589,31 @@ const AVR_opcode_data avr_opcodes[164] = { {"1-3", "1-3", "1-3", "1/2"}, ""}, }; +// Return whether or not a 16-bit opcode has a 16-bit address argument +int is_opcode32(int op) { + return + (op & 0xfe0e) == 0x940e || // call + (op & 0xfe0e) == 0x940c || // jmp + (op & 0xfe0f) == 0x9200 || // sts + (op & 0xfe0f) == 0x9000; // lds +} + +// Does the 16-bit opcode match the avr_opcodes table entry for mnemo? +int opcode_match(int op, AVR_opcode mnemo) { + if((op & avr_opcodes[mnemo].mask) == avr_opcodes[mnemo].value) { + if(!(avr_opcodes[mnemo].type & OTY_CONSTRAINT)) + return 1; + // Match constraint Rd == Rr as in "0010 00r= rrrr ====" + return (op>>0 & 15) == (op>>4 & 15) && (op>>9 & 1) == (op>>8 & 1); + } + return 0; +} + +// Return first match of opcode that is compatible with avrlevel or OPCODE_NONE +AVR_opcode opcode_mnemo(int op, int avrlevel) { + for(AVR_opcode i = 0; i < OPCODE_N; i++) + if(avr_opcodes[i].avrlevel & avrlevel) + if(opcode_match(op, i)) + return i; + return OPCODE_NONE; +} diff --git a/src/disasm.c b/src/disasm.c index 67f9b79b..dcb3dc2b 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -444,7 +444,7 @@ int disasm_init(const AVRPART *p) { qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); for(size_t i = 0; i < sizeof avr_opcodes/sizeof*avr_opcodes; i++) - if(avr_opcodes[i].mnemo != i) { + if(avr_opcodes[i].mnemo != (AVR_opcode) i) { msg_error("avr_opcodes[] table broken (this should never happen)\n"); return -1; } diff --git a/src/libavrdude.h b/src/libavrdude.h index d02b5f78..f74a78e5 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1503,6 +1503,7 @@ typedef struct { // Order of enums must align with avr_opcodes[] table order typedef enum { + OPCODE_NONE = -1, OPCODE_lsl, OPCODE_add, OPCODE_rol, OPCODE_adc, OPCODE_ror, OPCODE_asr, OPCODE_adiw, OPCODE_sub, OPCODE_subi, OPCODE_sbc, OPCODE_sbci, OPCODE_sbiw, @@ -1544,6 +1545,7 @@ typedef enum { OPCODE_u_eicall, OPCODE_u_ret, OPCODE_u_reti, OPCODE_u_nop_8, OPCODE_u_nop_9, OPCODE_u_nop_a, OPCODE_u_ijmp, OPCODE_u_eijmp, OPCODE_u_bld, OPCODE_u_bst, OPCODE_u_sbrc, OPCODE_u_sbrs, + OPCODE_N } AVR_opcode; typedef struct { @@ -1737,6 +1739,10 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); +int is_opcode32(int op); +int opcode_match(int op, AVR_opcode mnemo); +AVR_opcode opcode_mnemo(int op, int avrlevel); + int disasm_init(const AVRPART *p); int disasm_init_tagfile(const AVRPART *p, const char *file); int disasm(const char *buf, int len, int addr); From dcb9c7e70ec4c94df66bdfda480d67054eaff1fc Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sat, 20 Jul 2024 22:18:34 +0200 Subject: [PATCH 331/422] Improve error handling when Avrdude is built without libserialport --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.c b/src/main.c index 4555d342..32da1604 100644 --- a/src/main.c +++ b/src/main.c @@ -1413,9 +1413,11 @@ int main(int argc, char * argv []) pmsg_error("unable to open port %s for programmer %s\n", port, pgmid); skipopen: if (print_ports && pgm->conntype == CONNTYPE_SERIAL) { +#ifdef HAVE_LIBSERIALPORT list_available_serialports(programmers); if(touch_1200bps == 1) pmsg_info("alternatively, try -rr or -rrr for longer delays\n"); +#endif } exitrc = 1; pgm->ppidata = 0; /* clear all bits at exit */ From ea48a297082f88b0a0647b9d1ba259dfb958d79f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 20 Jul 2024 22:40:48 +0100 Subject: [PATCH 332/422] Change operands entries from "-" to "" in avr_opcodes table --- src/avr_opcodes.c | 80 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index af05c5bc..b41835f7 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -43,7 +43,7 @@ * * k 7-bit signed relative address in words for 2*k+2 bytes PC offset in * [-126, 128] (brcs, brlo, breq, brmi, brvs, brlt, brhs, brts, brie, - brcc, brsh, brne, brpl, brvc, brge, brhc, brtc, brid, brbs, brbc) + * brcc, brsh, brne, brpl, brvc, brge, brhc, brtc, brid, brbs, brbc) * 12-bit signed relative address in words for 2*k+2 bytes PC offset in * [-4094, 4096] (rjmp, rcall) * 16-bit absolute byte address (lds, sts) @@ -185,7 +185,7 @@ const AVR_opcode_data avr_opcodes[164] = { "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, ""}, {OP_ID(eijmp), 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, - "eijmp", "-", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", + "eijmp", "", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, ""}, {OP_ID(jmp), 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, "jmp", "k", "Jump", "PC <-- k", "--------", @@ -197,16 +197,16 @@ const AVR_opcode_data avr_opcodes[164] = { "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, - "eicall", "-", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", + "eicall", "", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, ""}, {OP_ID(call), 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "--------", {"4/5", "3/4", "3/4", "n/a"}, ""}, {OP_ID(ret), 0xffff, 0x9508, 1, OP_AVR1, "1001 0101 0000 1000", OTY_JMPX, - "ret", "-", "Subroutine Return", "PC <-- STACK", "--------", + "ret", "", "Subroutine Return", "PC <-- STACK", "--------", {"4/5", "4/5", "4/5", "6"}, ""}, {OP_ID(reti), 0xffff, 0x9518, 1, OP_AVR1, "1001 0101 0001 1000", OTY_JMPX, - "reti", "-", "Interrupt Return", "PC <-- STACK", "I-------", + "reti", "", "Interrupt Return", "PC <-- STACK", "I-------", {"4/5", "4/5", "4/5", "6"}, ""}, {OP_ID(cpse), 0xfc00, 0x1000, 1, OP_AVR1, "0001 00rd dddd rrrr", OTY_SKPI|OTY_RALL, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr) PC <-- PC + 2/3", "--------", @@ -379,7 +379,7 @@ const AVR_opcode_data avr_opcodes[164] = { "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, {OP_ID(lpm_1), 0xffff, 0x95c8, 1, OP_AVR1nRC, "1001 0101 1100 1000", OTY_XFRX, - "lpm", "-", "Load Program Memory", "R0 <-- (Z)", "--------", + "lpm", "", "Load Program Memory", "R0 <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(lpm_2), 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "--------", @@ -447,52 +447,52 @@ const AVR_opcode_data avr_opcodes[164] = { "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(sec), 0xffff, 0x9408, 1, OP_AVR1, "1001 0100 0000 1000", OTY_ALBI, - "sec", "-", "Set Carry", "C <-- 1", "-------C", + "sec", "", "Set Carry", "C <-- 1", "-------C", {"1", "1", "1", "1"}, "alias for bset 0"}, {OP_ID(clc), 0xffff, 0x9488, 1, OP_AVR1, "1001 0100 1000 1000", OTY_ALBI, - "clc", "-", "Clear Carry", "C <-- 0", "-------C", + "clc", "", "Clear Carry", "C <-- 0", "-------C", {"1", "1", "1", "1"}, "alias for bclr 0"}, {OP_ID(sen), 0xffff, 0x9428, 1, OP_AVR1, "1001 0100 0010 1000", OTY_ALBI, - "sen", "-", "Set Negative Flag", "N <-- 1", "-----N--", + "sen", "", "Set Negative Flag", "N <-- 1", "-----N--", {"1", "1", "1", "1"}, "alias for bset 2"}, {OP_ID(cln), 0xffff, 0x94a8, 1, OP_AVR1, "1001 0100 1010 1000", OTY_ALBI, - "cln", "-", "Clear Negative Flag", "N <-- 0", "-----N--", + "cln", "", "Clear Negative Flag", "N <-- 0", "-----N--", {"1", "1", "1", "1"}, "alias for bclr 2"}, {OP_ID(sez), 0xffff, 0x9418, 1, OP_AVR1, "1001 0100 0001 1000", OTY_ALBI, - "sez", "-", "Set Zero Flag", "Z <-- 1", "------Z-", + "sez", "", "Set Zero Flag", "Z <-- 1", "------Z-", {"1", "1", "1", "1"}, "alias for bset 1"}, {OP_ID(clz), 0xffff, 0x9498, 1, OP_AVR1, "1001 0100 1001 1000", OTY_ALBI, - "clz", "-", "Clear Zero Flag", "Z <-- 0", "------Z-", + "clz", "", "Clear Zero Flag", "Z <-- 0", "------Z-", {"1", "1", "1", "1"}, "alias for bclr 1"}, {OP_ID(sei), 0xffff, 0x9478, 1, OP_AVR1, "1001 0100 0111 1000", OTY_ALBX, - "sei", "-", "Global Interrupt Enable", "I <-- 1", "I-------", + "sei", "", "Global Interrupt Enable", "I <-- 1", "I-------", {"1", "1", "1", "1"}, "alias for bset 7"}, {OP_ID(cli), 0xffff, 0x94f8, 1, OP_AVR1, "1001 0100 1111 1000", OTY_ALBI, - "cli", "-", "Global Interrupt Disable", "I <-- 0", "I-------", + "cli", "", "Global Interrupt Disable", "I <-- 0", "I-------", {"1", "1", "1", "1"}, "alias for bclr 7"}, {OP_ID(ses), 0xffff, 0x9448, 1, OP_AVR1, "1001 0100 0100 1000", OTY_ALBI, - "ses", "-", "Set Signed Test Flag", "S <-- 1", "---S----", + "ses", "", "Set Signed Test Flag", "S <-- 1", "---S----", {"1", "1", "1", "1"}, "alias for bset 4"}, {OP_ID(cls), 0xffff, 0x94c8, 1, OP_AVR1, "1001 0100 1100 1000", OTY_ALBI, - "cls", "-", "Clear Signed Test Flag", "S <-- 0", "---S----", + "cls", "", "Clear Signed Test Flag", "S <-- 0", "---S----", {"1", "1", "1", "1"}, "alias for bclr 4"}, {OP_ID(sev), 0xffff, 0x9438, 1, OP_AVR1, "1001 0100 0011 1000", OTY_ALBI, - "sev", "-", "Set Two's Complement Overflow", "V <-- 1", "----V---", + "sev", "", "Set Two's Complement Overflow", "V <-- 1", "----V---", {"1", "1", "1", "1"}, "alias for bset 3"}, {OP_ID(clv), 0xffff, 0x94b8, 1, OP_AVR1, "1001 0100 1011 1000", OTY_ALBI, - "clv", "-", "Clear Two's Complement Overflow", "V <-- 0", "----V---", + "clv", "", "Clear Two's Complement Overflow", "V <-- 0", "----V---", {"1", "1", "1", "1"}, "alias for bclr 3"}, {OP_ID(set), 0xffff, 0x9468, 1, OP_AVR1, "1001 0100 0110 1000", OTY_ALBI, - "set", "-", "Set T in SREG", "T <-- 1", "-T------", + "set", "", "Set T in SREG", "T <-- 1", "-T------", {"1", "1", "1", "1"}, "alias for bset 6"}, {OP_ID(clt), 0xffff, 0x94e8, 1, OP_AVR1, "1001 0100 1110 1000", OTY_ALBI, - "clt", "-", "Clear T in SREG", "T <-- 0", "-T------", + "clt", "", "Clear T in SREG", "T <-- 0", "-T------", {"1", "1", "1", "1"}, "alias for bclr 6"}, {OP_ID(seh), 0xffff, 0x9458, 1, OP_AVR1, "1001 0100 0101 1000", OTY_ALBI, - "seh", "-", "Set Half Carry Flag in SREG", "H <-- 1", "--H-----", + "seh", "", "Set Half Carry Flag in SREG", "H <-- 1", "--H-----", {"1", "1", "1", "1"}, "alias for bset 5"}, {OP_ID(clh), 0xffff, 0x94d8, 1, OP_AVR1, "1001 0100 1101 1000", OTY_ALBI, - "clh", "-", "Clear Half Carry Flag in SREG", "H <-- 0", "--H-----", + "clh", "", "Clear Half Carry Flag in SREG", "H <-- 0", "--H-----", {"1", "1", "1", "1"}, "alias for bclr 5"}, {OP_ID(bset), 0xff8f, 0x9408, 1, OP_AVR1, "1001 0100 0sss 1000", OTY_ALBX, "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG-bit", @@ -503,16 +503,16 @@ const AVR_opcode_data avr_opcodes[164] = { // MCU Control Instructions {OP_ID(break), 0xffff, 0x9598, 1, OP_AVR1, "1001 0101 1001 1000", OTY_MCUX, - "break", "-", "Break", "(cf documentation)", "--------", + "break", "", "Break", "(cf documentation)", "--------", {"-", "-", "-", "-"}, "not available on all parts"}, {OP_ID(nop), 0xffff, 0x0000, 1, OP_AVR1, "0000 0000 0000 0000", OTY_MCUI, - "nop", "-", "No Operation", "-", "--------", + "nop", "", "No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(sleep), 0xffff, 0x9588, 1, OP_AVR1, "1001 0101 1000 1000", OTY_MCUX, - "sleep", "-", "Sleep", "(cf documentation)", "--------", + "sleep", "", "Sleep", "(cf documentation)", "--------", {"-", "-", "-", "-"}, ""}, {OP_ID(wdr), 0xffff, 0x95a8, 1, OP_AVR1, "1001 0101 1010 1000", OTY_MCUI, - "wdr", "-", "Watchdog Reset", "(cf documentation)", "--------", + "wdr", "", "Watchdog Reset", "(cf documentation)", "--------", {"1", "1", "1", "1"}, ""}, /* @@ -528,52 +528,52 @@ const AVR_opcode_data avr_opcodes[164] = { // Unallocated codes: they are said(!) to do the following {OP_ID(u_nop_1), 0xff00, 0x0000, 1, OP_AVR_ILL, "0000 0000 xxxx xxxx", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, {OP_ID(u_nop_2), 0xfe0f, 0x9003, 1, OP_AVR_ILL, "1001 000x xxxx 0011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_3), 0xfe0f, 0x9008, 1, OP_AVR_ILL, "1001 000x xxxx 1000", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_4), 0xfe0f, 0x900b, 1, OP_AVR_ILL, "1001 000x xxxx 1011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_5), 0xfe0f, 0x9203, 1, OP_AVR_ILL, "1001 001x xxxx 0011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_6), 0xfe0f, 0x9208, 1, OP_AVR_ILL, "1001 001x xxxx 1000", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_7), 0xfe0f, 0x920b, 1, OP_AVR_ILL, "1001 001x xxxx 1011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPX, "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, {OP_ID(u_eicall), 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, - "u/eicall", "-", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", + "u/eicall", "", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, "xxx != 000"}, {OP_ID(u_ret), 0xff9f, 0x9508, 1, OP_AVR_ILL, "1001 0101 0xx0 1000", OTY_JMPX, - "u/ret", "-", "alt Subroutine Return", "PC <-- STACK", "--------", + "u/ret", "", "alt Subroutine Return", "PC <-- STACK", "--------", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, {OP_ID(u_reti), 0xff9f, 0x9518, 1, OP_AVR_ILL, "1001 0101 0xx1 1000", OTY_JMPX, - "u/reti", "-", "alt Interrupt Return", "PC <-- STACK", "I-------", + "u/reti", "", "alt Interrupt Return", "PC <-- STACK", "I-------", {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, {OP_ID(u_nop_8), 0xffff, 0x95b8, 1, OP_AVR_ILL, "1001 0101 1011 1000", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_9), 0xfe0f, 0x9404, 1, OP_AVR_ILL, "1001 010x xxxx 0100", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_a), 0xff0f, 0x950b, 1, OP_AVR_ILL, "1001 0101 xxxx 1011", OTY_MCUI, - "u/nop", "-", "alt No Operation", "-", "--------", + "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_ijmp), 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI, "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, "xxx != 000"}, {OP_ID(u_eijmp), 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPI, - "u/eijmp", "-", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", + "u/eijmp", "", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, "xxx != 000"}, {OP_ID(u_bld), 0xfe08, 0xf808, 1, OP_AVR_ILL, "1111 100d dddd 1bbb", OTY_ALBI|OTY_RALL, "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "--------", From 02fca3d6e7cd089acda1086c43069b44ccf452dd Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 21 Jul 2024 10:01:41 +0100 Subject: [PATCH 333/422] Remove operand for spm/lpm/(e)ijmp/(e)icall --- src/avr_opcodes.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index b41835f7..16c93f2e 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -36,20 +36,20 @@ * A 5-bit I/O address (sbic, sbis, sbi, cbi) * 6-bit I/O address (in, out) * - * a 7-bit address in weird format 0x40..0xbf for reduced-core (lds, sts) + * a 7-bit encoded address 0x40..0xbf for reduced-core (lds, sts) * * b bit number 0..7 (sbrc, sbrs, sbic, sbis, sbi, cbi, bst, bld, u/bld, * u/bst, u/sbrc, u/sbrs) * - * k 7-bit signed relative address in words for 2*k+2 bytes PC offset in - * [-126, 128] (brcs, brlo, breq, brmi, brvs, brlt, brhs, brts, brie, - * brcc, brsh, brne, brpl, brvc, brge, brhc, brtc, brid, brbs, brbc) - * 12-bit signed relative address in words for 2*k+2 bytes PC offset in - * [-4094, 4096] (rjmp, rcall) + * k signed 7-bit for 2*k+2 byte PC offset in [-126, 128] (brcs, brlo, + * breq, brmi, brvs, brlt, brhs, brts, brie, brcc, brsh, brne, brpl, + * brvc, brge, brhc, brtc, brid, brbs, brbc) + * signed 12-bit for 2*k+2 bytes PC offset in [-4094, 4096] (rjmp, + * rcall) * 16-bit absolute byte address (lds, sts) * 22-bit absolute word address for the PC (jmp, call) * - * K 4-bit round index 0..15 (des) + * K 4-bit encryption round index 0..15 (des) * 6-bit constant 0..63 (adiw, sbiw) * 8-bit constant 0..255 (subi, sbci, andi, ori, sbr, cbr, cpi, ldi) * @@ -67,10 +67,10 @@ * * Rr 3-bit source register in r16, ..., r23 (mulsu, fmul, fmuls, fmulsu) * 4-bit source register in r16, ..., r31 (muls, sts) - * 4-bit source register in r0, ..., r30 (movw) - * 5-bit source register in r0, ..., r31 (add, adc, sub, sbc, and, or, - * eor, tst, mul, cpse, cp, cpc, sbrc, sbrs, mov, sts, st, std, - * out, push, bst, u/bst, u/sbrc, u/sbrs) + * 4-bit source register in r0, r2, ..., r30 (movw) + * 5-bit source register in r0, r1, ..., r31 (add, adc, sub, sbc, and, + * or, eor, tst, mul, cpse, cp, cpc, sbrc, sbrs, mov, sts, st, + * std, out, push, bst, u/bst, u/sbrc, u/sbrs) * * s SREG bit number 0..7 (brbs, brbc, bset, bclr) * @@ -182,7 +182,7 @@ const AVR_opcode_data avr_opcodes[164] = { "rjmp", "k", "Relative Jump", "PC <-- PC + k + 1", "--------", {"2", "2", "2", "2"}, ""}, {OP_ID(ijmp), 0xffff, 0x9409, 1, OP_AVR2, "1001 0100 0000 1001", OTY_JMPI, - "ijmp", "Z", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", + "ijmp", "", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, ""}, {OP_ID(eijmp), 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, "eijmp", "", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", @@ -194,7 +194,7 @@ const AVR_opcode_data avr_opcodes[164] = { "rcall", "k", "Relative Call Subroutine", "PC <-- PC + k + 1", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, {OP_ID(icall), 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPX, - "icall", "Z", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", + "icall", "", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, "eicall", "", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", @@ -388,7 +388,7 @@ const AVR_opcode_data avr_opcodes[164] = { "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(elpm_1), 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, - "elpm", "R0, Z", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "--------", + "elpm", "", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(elpm_2), 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "--------", @@ -397,7 +397,7 @@ const AVR_opcode_data avr_opcodes[164] = { "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(spm), 0xffff, 0x95e8, 1, OP_AVR25, "1001 0101 1110 1000", OTY_XFRX, - "spm", "Z", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "--------", + "spm", "", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "--------", {"-", "-", "-", "-"}, ""}, {OP_ID(spm_zz), 0xffff, 0x95f8, 1, OP_AVR_XTM, "1001 0101 1111 1000", OTY_XFRX, "spm", "Z+", "Store Program Memory and Post-Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z + 2", "--------", @@ -549,7 +549,7 @@ const AVR_opcode_data avr_opcodes[164] = { "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPX, - "u/icall", "Z", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", + "u/icall", "", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, {OP_ID(u_eicall), 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, "u/eicall", "", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", @@ -570,7 +570,7 @@ const AVR_opcode_data avr_opcodes[164] = { "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_ijmp), 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI, - "u/ijmp", "Z", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", + "u/ijmp", "", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, "xxx != 000"}, {OP_ID(u_eijmp), 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPI, "u/eijmp", "", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", From 26628ef30d1272d6de0a683656237cf846730a71 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 21 Jul 2024 16:52:10 +0200 Subject: [PATCH 334/422] improve libserialport error handling --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.c b/src/main.c index 32da1604..eea35866 100644 --- a/src/main.c +++ b/src/main.c @@ -1331,6 +1331,7 @@ int main(int argc, char * argv []) // Use libserialport to find the actual serial port ser = locate_programmer(programmers, port_tok[0]); if (is_serialadapter(ser)) { +#ifdef HAVE_LIBSERIALPORT int rv = setport_from_serialadapter(&port, ser, port_tok[1]); if (rv == -1) { pmsg_warning("serial adapter %s", port_tok[0]); @@ -1344,6 +1345,7 @@ int main(int argc, char * argv []) print_ports = false; if(rv) ser = NULL; +#endif } else if(str_eq(port_tok[0], DEFAULT_USB)) { // Port or usb:[vid]:[pid] int vid, pid; From d58ad3365c1880974830f84623eaf6983d512457 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 02:20:54 +0100 Subject: [PATCH 335/422] Move from callbacks to table-driven disassembly --- src/CMakeLists.txt | 1 - src/Makefile.am | 1 - src/avr_opcodes.c | 75 ++- src/disasm.c | 669 +++++++++++------------- src/disasm_callbacks_assembly.c | 892 -------------------------------- src/disasm_jumpcall.c | 19 +- src/disasm_private.h | 150 ------ src/disasm_tagfile.c | 8 +- src/libavrdude.h | 32 +- src/strutil.c | 27 + src/term.c | 220 ++++---- 11 files changed, 544 insertions(+), 1550 deletions(-) delete mode 100644 src/disasm_callbacks_assembly.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 82cddc05..930819e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -183,7 +183,6 @@ add_library(libavrdude crc16.h disasm.c disasm_private.h - disasm_callbacks_assembly.c disasm_jumpcall.c disasm_tagfile.c dfu.c diff --git a/src/Makefile.am b/src/Makefile.am index 1ea58c2d..9f2ca7e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -121,7 +121,6 @@ libavrdude_a_SOURCES = \ crc16.h \ disasm.c \ disasm_private.h \ - disasm_callbacks_assembly.c \ disasm_jumpcall.c \ disasm_tagfile.c \ dfu.c \ diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 16c93f2e..4a0e35e6 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -41,11 +41,11 @@ * b bit number 0..7 (sbrc, sbrs, sbic, sbis, sbi, cbi, bst, bld, u/bld, * u/bst, u/sbrc, u/sbrs) * - * k signed 7-bit for 2*k+2 byte PC offset in [-126, 128] (brcs, brlo, - * breq, brmi, brvs, brlt, brhs, brts, brie, brcc, brsh, brne, brpl, - * brvc, brge, brhc, brtc, brid, brbs, brbc) - * signed 12-bit for 2*k+2 bytes PC offset in [-4094, 4096] (rjmp, - * rcall) + * k signed 7-bit for 2*k byte PC additional offset in [.-128, .+126] + * (brcs, brlo, breq, brmi, brvs, brlt, brhs, brts, brie, brcc, brsh, + * brne, brpl, brvc, brge, brhc, brtc, brid, brbs, brbc) + * signed 12-bit for 2*k bytes PC additional offset in [.-4096, .+4094] + * (rjmp, rcall) * 16-bit absolute byte address (lds, sts) * 22-bit absolute word address for the PC (jmp, call) * @@ -589,7 +589,7 @@ const AVR_opcode_data avr_opcodes[164] = { {"1-3", "1-3", "1-3", "1/2"}, ""}, }; -// Return whether or not a 16-bit opcode has a 16-bit address argument +// Return whether or not the giveb 16-bit opcode has a 16-bit address argument int is_opcode32(int op) { return (op & 0xfe0e) == 0x940e || // call @@ -598,6 +598,11 @@ int is_opcode32(int op) { (op & 0xfe0f) == 0x9000; // lds } +// Return the register number of the 16-bit ldi opcode (and 0 if it's not ldi) +int ldi_register(int op) { + return (op & 0xf000) == 0xe000? 16 + ((op >> 4) & 15): 0; +} + // Does the 16-bit opcode match the avr_opcodes table entry for mnemo? int opcode_match(int op, AVR_opcode mnemo) { if((op & avr_opcodes[mnemo].mask) == avr_opcodes[mnemo].value) { @@ -617,3 +622,61 @@ AVR_opcode opcode_mnemo(int op, int avrlevel) { return i; return OPCODE_NONE; } + +// Opcodes in avr_opcodes[] that a part ought to be able to run +int avr_get_archlevel(const AVRPART *p) { + int ret = + p->prog_modes & PM_UPDI? PART_AVR_XT: + p->prog_modes & PM_PDI? PART_AVR_XM: + p->prog_modes & PM_TPI? PART_AVR_RC: 0; + + if(!ret) { // Non-TPI classic part + switch(p->archnum) { + case 1: + ret = PART_AVR1; + break; + default: // If AVRDUE doesn't know, it's probably rare & old + case 2: + ret = PART_AVR2; + break; + case 25: + ret = PART_AVR25; + break; + case 3: case 31: case 35: // Sic + ret = PART_AVR3; + break; + break; + case 4: + ret = PART_AVR4; + break; + case 5: + ret = PART_AVR5; + break; + case 51: + ret = PART_AVR51; + break; + case 6: + ret = PART_AVR6; + } + } + + AVRMEM *mem = avr_locate_flash(p); + if(mem) { // Add opcodes needed for large parts in any case + if(mem->size > 8192) + ret |= OP_AVR_M; // JMP, CALL + if(mem->size > 65536) + ret |= OP_AVR_L; // ELPM + if(mem->size > 128*1024) + ret |= OP_AVR_XL; // EIJMP, EICALL + } + + return ret; +} + +// Index in the avr_opcodes[].clock[] array for timings of an opcode +AVR_cycle_index avr_get_cycle_index(const AVRPART *p) { + return + p->prog_modes & PM_UPDI? OP_AVRxt: + p->prog_modes & PM_PDI? OP_AVRxm: + p->prog_modes & PM_TPI? OP_AVRrc: OP_AVRe; +} diff --git a/src/disasm.c b/src/disasm.c index dcb3dc2b..e3a4ef7b 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -1,12 +1,10 @@ /* * AVRDUDE - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2024 by Stefan Rueger * - * This file was ported from - * avrdisas - A disassembler for AVR microcontroller units + * Based on avrdisas (but heavily rewritten) * Copyright (C) 2007 Johannes Bauer * - * Copyright (C) 2024 port by Stefan Rueger - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -37,164 +35,308 @@ #include "disasm_private.h" -static void Register_Opcode(void (*Callback)(const char *, int, AVR_opcode), const char *New_Opcode_String, AVR_opcode mnemo) { - if(cx->dis_n_ops < (int) (sizeof cx->dis_op/sizeof*cx->dis_op)) { - cx->dis_op[cx->dis_n_ops].Opcode_String = mmt_strdup(New_Opcode_String); - cx->dis_op[cx->dis_n_ops].mnemo = mnemo; - cx->dis_op[cx->dis_n_ops].Callback = Callback; - cx->dis_n_ops++; - } -} - -static int Get_Bitmask_Length(const char *Bitmask) { - int Length = 0; - size_t i; - - for(i = 0; i < strlen(Bitmask); i++) { - if(Bitmask[i] != ' ') - Length++; - } - return Length; -} - -static void Clear_Registers() { - int i; - - for(i = 0; i < 256; i++) - cx->dis_regs[i] = 0; -} - -static char Get_From_Bitmask(const char *Bitmask, int Byte, int Bit) { - size_t i; - int Cnt = 0; - int GetBit; - - GetBit = (Byte * 8) + Bit; - for(i = 0; i < strlen(Bitmask); i++) { - if(Bitmask[i] != ' ') { - if(Cnt == GetBit) - return Bitmask[i]; - Cnt++; - } - } - return '?'; -} - -static int Match_Opcode(const char *Bitmask, const char *Bitstream) { - int i; - int Length; - int Byte_Mask, Bit_Mask; - int Byte_Stream, Bit_Stream; - char Mask_Val, Stream_Val; - - Clear_Registers(); - Length = Get_Bitmask_Length(Bitmask); - - for(i = 0; i < Length; i++) { - Byte_Mask = i / 8; - Bit_Mask = i % 8; - - Byte_Stream = i / 8; - Byte_Stream ^= 1; // Invert last bit - Bit_Stream = 7 - (i % 8); - - Mask_Val = Get_From_Bitmask(Bitmask, Byte_Mask, Bit_Mask); - Stream_Val = (Bitstream[Byte_Stream] >> Bit_Stream) & 0x01; - - // term_out("Extracting Bit %2d: Maske = (%d, %d) [%c], Stream = (%d, %d) [%d] ", i, Byte_Mask, Bit_Mask, Mask_Val, Byte_Stream, Bit_Stream, Stream_Val); - if((Mask_Val == '0') || (Mask_Val == '1')) { - // This Bit is a identification Bit - if(Mask_Val == '0') { - if(Stream_Val == 1) { - - // term_out("\nMatch failed.\n") - return 0; - } - } else { - if(Stream_Val == 0) { - - // term_out("\nMatch failed.\n") - return 0; - } - } - } else { - // This Bit is a register Bit, set in appropriate place - cx->dis_regs[(int) Mask_Val] <<= 1; - cx->dis_regs[(int) Mask_Val] |= Stream_Val; - - // term_out("-> %d Stored [%x]", Stream_Val, cx->dis_regs[(int) Mask_Val]); - } - - // term_out("\n"); - } - return 1; -} - -static int Get_Next_Opcode(const char *Bitstream) { - for(int i = 0; i < cx->dis_n_ops; i++) - if(avr_opcodes[cx->dis_op[i].mnemo].avrlevel & cx->dis_opts.AVR_Level) - if(Match_Opcode(cx->dis_op[i].Opcode_String, Bitstream) == 1) - return i; - return -1; -} - +// Wrap around flash int disasm_wrap(int addr) { - int flashsz = cx->dis_opts.FlashSize; - - if(flashsz > 0) { - while(addr >= flashsz) - addr -= flashsz; - while(addr < 0) - addr += flashsz; - } + if(cx->dis_flashsz) + addr &= cx->dis_flashsz-1; return addr; } -int disasm(const char *Bitstream, int Read, int addr) { - int Pos; - int Opcode; - int i; +typedef struct { + char code[256], comment[256]; +} Disasm_line; + +#define Ra (regs['a']) +#define Rd (regs['d']) +#define Rr (regs['r']) +#define Rk (regs['k']) +#define RK (regs['K']) +#define Rs (regs['s']) +#define RA (regs['A']) +#define Rb (regs['b']) +#define Rq (regs['q']) + +#define Na (bits['a']) +#define Nd (bits['d']) +#define Nr (bits['r']) +#define Nk (bits['k']) +#define NK (bits['K']) +#define Ns (bits['s']) +#define NA (bits['A']) +#define Nb (bits['b']) +#define Nq (bits['q']) + +char *add_comment(Disasm_line *line, const char *comment) { + int len = strlen(line->comment), rem = 256-len-1; + char *p = line->comment + len; + + if(len && *comment && rem > 2) + strcpy(p, ", "), p += 2, rem -= 2; + strncpy(p, comment, rem); + p[rem] = 0; + + return p + strlen(p); +} + + +static const char *regstyle(int n, int regword) { + if(regword && !cx->dis_opts.avrgcc_style) + return str_ccprintf("%d:%d", n+1, n); + return str_ccprintf("%d", n); +} + +// Return the number of bits set in Number +static unsigned bitcount(unsigned n) { + unsigned ret; + + // A la Kernighan (and Richie): iteratively clear the least significant bit set + for(ret = 0; n; ret++) + n &= n-1; + + return ret; +} + +void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm_line *line, int pass) { + const AVR_opcode_data *oc = avr_opcodes+mnemo; + memset(line, 0, sizeof*line); + + int regs[128] = {0}, bits[128] = {0}; + unsigned bmask = 0x8000; + for(const char *p = oc->bits; *p && bmask; p++) { + if(*p == ' ') + continue; + bits[*p & 0x7f]++; + regs[*p & 0x7f] <<= 1; + regs[*p & 0x7f] |= !!(opcode & bmask); + bmask >>= 1; + } + + // Treat 32 bit opcodes + if(oc->nwords == 2) { + bits['k'] += 16; + regs['k'] <<= 16; + regs['k'] |= (buf[2] & 0xff) | (buf[3] & 0xff)<<8; + } + + // Some sanity checks for things the code relies on + if(NA && NA != 5 && NA != 6) + pmsg_warning("unexpected number of A bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + if(Na && Na != 7) + pmsg_warning("unexpected number of a bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + if(Nb && Nb != 3) + pmsg_warning("unexpected number of b bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + if(Nk && Nk != 7 && Nk != 12 && Nk != 16 && Nk != 22) + pmsg_warning("unexpected number of k bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + if(NK && NK != 4 && NK != 6 && NK != 8) + pmsg_warning("unexpected number of bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + if(Nq && Nq != 6) + pmsg_warning("unexpected number of q bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + if(Nd && (Nd < 2 || Nd > 5)) + pmsg_warning("unexpected number of Rd bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + if(Nr && (Nr < 3 || Nr > 5)) + pmsg_warning("unexpected number of Rr bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + if(Ns && Ns != 3) + pmsg_warning("unexpected number of s bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); + + switch(mnemo) { // Exceptions go here + case OPCODE_andi: // cbr r17, 0x06 is marginally easier to read than andi r17, 0xf9 + if(bitcount(RK) >= 4) { + RK = ~RK & 0xff; + mnemo = OPCODE_cbr; + oc = avr_opcodes+mnemo; + } + default: + break; + } + + // Apply register formula + int regword = 0; + switch(oc->type & OTY_RMASK) { + case OTY_REVN: // Even registers r0, r2, ..., r30 + Rd *= 2, Rr *= 2; + regword = 1; // movw + break; + case OTY_RUPP: // Upper registers only r16, ..., r31 + Rd += 16, Rr += 16; + break; + case OTY_RW24: // r24, r26, r28, r30 only + Rd = 2*Rd + 24; + regword = 1; // adiw, sbiw + break; + } + + if(Na) { + /* + * Address is limited to 0x40...0xbf for the reduced-core (TPI part) + * ADDR[7:0] ← (/INST[8], INST[8], INST[10], INST[9], INST[3], INST[2], INST[1], INST[0]) + * ADDR[7:0] ← (/a[4], a[4], a[6], a[5], a[3], a[2], a[1], a[0]) + */ + Ra = (Ra & 0xf) | ((Ra >> 1) & 0x30) | ((Ra & 0x10) << 2) | (((Ra & 0x10) ^ 0x10) << 3); + } + + int target = 0, offset = 0, is_jumpcall = 0, is_relative = 0; + int is_function = !!(oc->type & OTY_EXTERNAL); // call/rcall affects stack memory + const char *kmemaddr = NULL, *memaddr, *regname; + + switch(Nk) { + case 0: + break; + case 7: // Branches + offset = (int8_t) (Rk<<1); // Sign-extend and multiply by 2 + target = disasm_wrap(addr + offset + 2); + if(pass == 1) + Register_JumpCall(addr, target, mnemo, 0); + is_jumpcall = 1; + is_relative = 1; + break; // rjmp/rcall + case 12: + offset = (int16_t) (Rk<<4) >> 3; // Sign extend and multiply by 2 + target = disasm_wrap(addr + offset + 2); + if(pass == 1) + Register_JumpCall(addr, target, mnemo, is_function); + is_jumpcall = 1; + is_relative = 1; + break; + case 16: // lds/sts + kmemaddr = Tagfile_Resolve_Mem_Address(Rk); + break; + case 22: + target = disasm_wrap(2*Rk); + if(pass == 1) + Register_JumpCall(addr, target, mnemo, is_function); + is_jumpcall = 1; + break; + default: + pmsg_warning("OPCODE_%s has an unexpected number %d of k bits\n", + oc->idname, Nk); + } + + int awd = cx->dis_addrwidth, swd = cx->dis_sramwidth; + snprintf(line->code, 256, "%-7s ", oc->opcode); + char *c = line->code + strlen(line->code); + *line->comment = 0; + + for(const char *o = oc->operands; *o && c-line->code < 255; o++) { + switch(*o) { + case 'R': + *c++ = 'r', *c = 0; + break; + default: + *c++ = *o, *c = 0; + break; + case 'A': + if((regname = Resolve_IO_Register(RA))) + snprintf(c, 256-strlen(c), "%s", regname); + else + snprintf(c, 256-strlen(c), "0x%02x", RA); + c += strlen(c); + break; + case 'a': + snprintf(c, 255 - (c-line->code), "0x%02x", Ra); + if((memaddr = Tagfile_Resolve_Mem_Address(Ra))) + add_comment(line, str_ccprintf("%s", memaddr)); + break; + case 'k': + if(is_jumpcall) { + if(cx->dis_opts.Process_Labels) { + snprintf(c, 255 - (c-line->code), "%s", Get_Label_Name(target, NULL)); + add_comment(line, str_ccprintf("0x%0*x", awd, target)); + } else { + if(is_relative) { + snprintf(c, 255 - (c-line->code), ".%+d", offset); + add_comment(line, str_ccprintf("0x%0*x", awd, target)); + } else + snprintf(c, 255 - (c-line->code), "0x%0*x", awd, target); + } + } else { + snprintf(c, 255 - (c-line->code), "0x%0*x", swd, Rk); + if(kmemaddr) + add_comment(line, str_ccprintf("%s", kmemaddr)); + } + break; + case 'b': + snprintf(c, 255 - (c-line->code), "%d", Rb); + add_comment(line, str_ccprintf("bit %d = 0x%02x", Rb, 1 << Rb)); + break; + case 's': + snprintf(c, 255 - (c-line->code), "%d", Rs); + break; + case 'd': + snprintf(c, 255 - (c-line->code), "%s", regstyle(Rd, regword)); + break; + case 'r': + snprintf(c, 255 - (c-line->code), "%s", regstyle(Rr, regword)); + break; + case 'K': + if(NK == 4) + snprintf(c, 255 - (c-line->code), "%d", RK); + else { + snprintf(c, 255 - (c-line->code), "0x%02x", RK); + add_comment(line, str_ccprintf("%d", RK)); + } + break; + case 'q': snprintf(c, 255 - (c-line->code), "%d", Rq); + break; + } + c += strlen(c); + } + // Trim trailing spaces + while(--c >= line->code && *c == ' ') + *c = 0; +} + +/* + * Disassemble buflen bytes at buf which corresponds to address addr + * + * Before the location buf there are leadin bytes available (0 - 2) + * After the location buf+readlen there are leadout bytes available (0 -4) + */ +int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { + int Pos; + int opcode, mnemo, oplen; + int i; + Disasm_line line; - cx->dis_pass = 1; Pos = 0; - if(cx->dis_opts.Process_Labels || cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC) { + for(int i = 0; i < cx->dis_IORegisterN; i++) + cx->dis_IORegisters[i].Used = 0; + + if(cx->dis_opts.Process_Labels || cx->dis_opts.avrgcc_style) { // Preprocess to gather jump labels or to gain knowledge about registers which are being used - while(Pos < Read) { - Opcode = Get_Next_Opcode(Bitstream + Pos); - if(Opcode == -1) { + while(Pos < buflen) { + opcode = (buf[Pos] & 0xff) | (buf[Pos+1] & 0xff)<<8; + mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); + oplen = 2*avr_opcodes[mnemo].nwords; + if(mnemo == -1) { Pos += 2; } else { - cx->dis_op[Opcode].Callback(Bitstream + Pos, disasm_wrap(Pos + addr), cx->dis_op[Opcode].mnemo); - Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; + disassemble(buf + Pos, disasm_wrap(Pos + addr), opcode, mnemo, &line, 1); + Pos += oplen; } } Enumerate_Labels(); - cx->dis_pass = 2; Pos = 0; } - if(cx->dis_opts.CodeStyle == CODESTYLE_AVRGCC) + if(cx->dis_opts.avrgcc_style) Emit_Used_IO_Registers(); - while(Pos < Read) { - int Added; - + while(Pos < buflen) { // Check if this is actually code or maybe only data from tagfile - Added = Tagfile_Process_Data(Bitstream, Pos, addr); - if(Added != 0) { - // Data was added + int Added = Tagfile_Process_Data(buf, Pos, addr); + if(Added) { Pos += Added; continue; } - Opcode = Get_Next_Opcode(Bitstream + Pos); - if(Opcode != -1) { - cx->dis_code[0] = 0; - cx->dis_comment[0] = 0; - cx->dis_after_code[0] = 0; - cx->dis_op[Opcode].Callback(Bitstream + Pos, disasm_wrap(Pos + addr), cx->dis_op[Opcode].mnemo); + opcode = (buf[Pos] & 0xff) | (buf[Pos+1] & 0xff)<<8; + mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); + oplen = 2*avr_opcodes[mnemo].nwords; + + if(mnemo != -1) { + disassemble(buf + Pos, disasm_wrap(Pos + addr), opcode, mnemo, &line, 2); if(cx->dis_opts.Process_Labels) Print_JumpCalls(disasm_wrap(Pos + addr)); @@ -202,38 +344,34 @@ int disasm(const char *Bitstream, int Read, int addr) { if(cx->dis_opts.Show_Addresses) term_out("%4x: ", disasm_wrap(Pos + addr)); if(cx->dis_opts.Show_Cycles) - term_out("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clock[cx->dis_opts.cycle_index]); + term_out("[%-3s] ", avr_opcodes[mnemo].clock[cx->dis_cycle_index]); if(cx->dis_opts.Show_Opcodes) { // Now display the Opcode - for(i = 0; i < (Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8; i++) - term_out("%02x ", (unsigned char) (Bitstream[Pos + i])); - + for(i = 0; i < oplen; i++) + term_out("%02x ", buf[Pos + i] & 0xff); term_out(" "); - // Missing spaces - for(i = 0; i < 5 - ((Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8); i++) { + for(i = 0; i < 5 - oplen; i++) term_out(" "); - } } - if(cx->dis_code[0] == 0) { + if(line.code[0] == 0) { // No code was generated? - term_out("; - Not implemented opcode: %d -\n", cx->dis_op[Opcode].mnemo); + term_out("; opcode %s not implemented\n", avr_opcodes[mnemo].idname); } else { - if((cx->dis_comment[0] == 0) || (!cx->dis_opts.Show_Comments)) { - // No comment - term_out("%s\n", cx->dis_code); + if(!line.comment[0] || !cx->dis_opts.Show_Comments) { + term_out("%s\n", line.code); } else { - // Comment available - term_out("%-23s ; %s\n", cx->dis_code, cx->dis_comment); + term_out("%-23s ; %s\n", line.code, line.comment); } } - term_out("%s", cx->dis_after_code); + if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) // @@@ + term_out("\n"); - Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8; + Pos += oplen; } else { term_out(".word 0x%02x%02x ; Invalid opcode at 0x%04x\n", - ((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], disasm_wrap(Pos + addr)); + buf[Pos + 1] & 0xff, buf[Pos] & 0xff, disasm_wrap(Pos + addr)); Pos += 2; } } @@ -241,214 +379,35 @@ int disasm(const char *Bitstream, int Read, int addr) { return 0; } -static int Get_Specifity(const char *Opcode) { - int Specifity = 0; - - for(size_t i = 0; i < strlen(Opcode); i++) - if((Opcode[i] == '0') || (Opcode[i] == '1')) - Specifity++; - - return Specifity; -} - -// Percolate higher specifity towards beginning of array but ensure illegal opcodes are last -static int Comparison(const void *Element1, const void *Element2) { - Disasm_opcode *OC1, *OC2; - int SP1, SP2, illegal1, illegal2, diff; - OC1 = (Disasm_opcode *) Element1; - OC2 = (Disasm_opcode *) Element2; - illegal1 = avr_opcodes[OC1->mnemo].avrlevel == OP_AVR_ILL; - illegal2 = avr_opcodes[OC2->mnemo].avrlevel == OP_AVR_ILL; - if((diff = illegal1 - illegal2)) - return diff; - SP1 = Get_Specifity(OC1->Opcode_String); - SP2 = Get_Specifity(OC2->Opcode_String); - if((diff = SP1 - SP2)) - return -diff; - // Tie break by mnemonic - return OC1->mnemo - OC2->mnemo; -} - int disasm_init(const AVRPART *p) { - for(int i=0; idis_n_ops; i++) - mmt_free(cx->dis_op[i].Opcode_String); - cx->dis_n_ops = 0; - - Register_Opcode(adc_Callback, "0001 11rd dddd rrrr", OPCODE_adc); - Register_Opcode(add_Callback, "0000 11rd dddd rrrr", OPCODE_add); - Register_Opcode(adiw_Callback, "1001 0110 KKdd KKKK", OPCODE_adiw); - Register_Opcode(and_Callback, "0010 00rd dddd rrrr", OPCODE_and); - Register_Opcode(andi_Callback, "0111 KKKK dddd KKKK", OPCODE_andi); - Register_Opcode(asr_Callback, "1001 010d dddd 0101", OPCODE_asr); - Register_Opcode(bclr_Callback, "1001 0100 1sss 1000", OPCODE_bclr); - Register_Opcode(bld_Callback, "1111 100d dddd 0bbb", OPCODE_bld); - Register_Opcode(brbc_Callback, "1111 01kk kkkk ksss", OPCODE_brbc); - Register_Opcode(brbs_Callback, "1111 00kk kkkk ksss", OPCODE_brbs); - Register_Opcode(brcc_Callback, "1111 01kk kkkk k000", OPCODE_brcc); - Register_Opcode(brcs_Callback, "1111 00kk kkkk k000", OPCODE_brcs); - Register_Opcode(break_Callback, "1001 0101 1001 1000", OPCODE_break); - Register_Opcode(breq_Callback, "1111 00kk kkkk k001", OPCODE_breq); - Register_Opcode(brge_Callback, "1111 01kk kkkk k100", OPCODE_brge); - Register_Opcode(brhc_Callback, "1111 01kk kkkk k101", OPCODE_brhc); - Register_Opcode(brhs_Callback, "1111 00kk kkkk k101", OPCODE_brhs); - Register_Opcode(brid_Callback, "1111 01kk kkkk k111", OPCODE_brid); - Register_Opcode(brie_Callback, "1111 00kk kkkk k111", OPCODE_brie); - Register_Opcode(brlo_Callback, "1111 00kk kkkk k000", OPCODE_brlo); - Register_Opcode(brlt_Callback, "1111 00kk kkkk k100", OPCODE_brlt); - Register_Opcode(brmi_Callback, "1111 00kk kkkk k010", OPCODE_brmi); - Register_Opcode(brne_Callback, "1111 01kk kkkk k001", OPCODE_brne); - Register_Opcode(brpl_Callback, "1111 01kk kkkk k010", OPCODE_brpl); - Register_Opcode(brsh_Callback, "1111 01kk kkkk k000", OPCODE_brsh); - Register_Opcode(brtc_Callback, "1111 01kk kkkk k110", OPCODE_brtc); - Register_Opcode(brts_Callback, "1111 00kk kkkk k110", OPCODE_brts); - Register_Opcode(brvc_Callback, "1111 01kk kkkk k011", OPCODE_brvc); - Register_Opcode(brvs_Callback, "1111 00kk kkkk k011", OPCODE_brvs); - Register_Opcode(bset_Callback, "1001 0100 0sss 1000", OPCODE_bset); - Register_Opcode(bst_Callback, "1111 101d dddd 0bbb", OPCODE_bst); - Register_Opcode(call_Callback, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OPCODE_call); - Register_Opcode(cbi_Callback, "1001 1000 AAAA Abbb", OPCODE_cbi); - // Register_Opcode(cbr_Callback, "0111 KKKK dddd KKKK", OPCODE_cbr); // Implied by (a function of) andi - Register_Opcode(clc_Callback, "1001 0100 1000 1000", OPCODE_clc); - Register_Opcode(clh_Callback, "1001 0100 1101 1000", OPCODE_clh); - Register_Opcode(cli_Callback, "1001 0100 1111 1000", OPCODE_cli); - Register_Opcode(cln_Callback, "1001 0100 1010 1000", OPCODE_cln); - // Register_Opcode(clr_Callback, "0010 01dd dddd dddd", OPCODE_clr); // Implied by eor - Register_Opcode(cls_Callback, "1001 0100 1100 1000", OPCODE_cls); - Register_Opcode(clt_Callback, "1001 0100 1110 1000", OPCODE_clt); - Register_Opcode(clv_Callback, "1001 0100 1011 1000", OPCODE_clv); - Register_Opcode(clz_Callback, "1001 0100 1001 1000", OPCODE_clz); - Register_Opcode(com_Callback, "1001 010d dddd 0000", OPCODE_com); - Register_Opcode(cp_Callback, "0001 01rd dddd rrrr", OPCODE_cp); - Register_Opcode(cpc_Callback, "0000 01rd dddd rrrr", OPCODE_cpc); - Register_Opcode(cpi_Callback, "0011 KKKK dddd KKKK", OPCODE_cpi); - Register_Opcode(cpse_Callback, "0001 00rd dddd rrrr", OPCODE_cpse); - Register_Opcode(des_Callback, "1001 0100 KKKK 1011", OPCODE_des); - Register_Opcode(dec_Callback, "1001 010d dddd 1010", OPCODE_dec); - Register_Opcode(eicall_Callback, "1001 0101 0001 1001", OPCODE_eicall); - Register_Opcode(eijmp_Callback, "1001 0100 0001 1001", OPCODE_eijmp); - Register_Opcode(elpm1_Callback, "1001 0101 1101 1000", OPCODE_elpm_1); - Register_Opcode(elpm2_Callback, "1001 000d dddd 0110", OPCODE_elpm_2); - Register_Opcode(elpm3_Callback, "1001 000d dddd 0111", OPCODE_elpm_3); - Register_Opcode(eor_Callback, "0010 01rd dddd rrrr", OPCODE_eor); - Register_Opcode(fmul_Callback, "0000 0011 0ddd 1rrr", OPCODE_fmul); - Register_Opcode(fmuls_Callback, "0000 0011 1ddd 0rrr", OPCODE_fmuls); - Register_Opcode(fmulsu_Callback, "0000 0011 1ddd 1rrr", OPCODE_fmulsu); - Register_Opcode(icall_Callback, "1001 0101 0000 1001", OPCODE_icall); - Register_Opcode(ijmp_Callback, "1001 0100 0000 1001", OPCODE_ijmp); - Register_Opcode(in_Callback, "1011 0AAd dddd AAAA", OPCODE_in); - Register_Opcode(inc_Callback, "1001 010d dddd 0011", OPCODE_inc); - Register_Opcode(jmp_Callback, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OPCODE_jmp); - Register_Opcode(lac_Callback, "1001 001d dddd 0110", OPCODE_lac); - Register_Opcode(las_Callback, "1001 001d dddd 0101", OPCODE_las); - Register_Opcode(lat_Callback, "1001 001d dddd 0111", OPCODE_lat); - Register_Opcode(ldx1_Callback, "1001 000d dddd 1100", OPCODE_ld_1); - Register_Opcode(ldx2_Callback, "1001 000d dddd 1101", OPCODE_ld_2); - Register_Opcode(ldx3_Callback, "1001 000d dddd 1110", OPCODE_ld_3); - Register_Opcode(ldy1_Callback, "1000 000d dddd 1000", OPCODE_ld_4); - Register_Opcode(ldy2_Callback, "1001 000d dddd 1001", OPCODE_ld_5); - Register_Opcode(ldy3_Callback, "1001 000d dddd 1010", OPCODE_ld_6); - Register_Opcode(ldy4_Callback, "10q0 qq0d dddd 1qqq", OPCODE_ldd_1); - Register_Opcode(ldz1_Callback, "1000 000d dddd 0000", OPCODE_ld_7); - Register_Opcode(ldz2_Callback, "1001 000d dddd 0001", OPCODE_ld_8); - Register_Opcode(ldz3_Callback, "1001 000d dddd 0010", OPCODE_ld_9); - Register_Opcode(ldz4_Callback, "10q0 qq0d dddd 0qqq", OPCODE_ldd_2); - Register_Opcode(ldi_Callback, "1110 KKKK dddd KKKK", OPCODE_ldi); - Register_Opcode(lds_Callback, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_lds); - Register_Opcode(lds_rc_Callback, "1010 0kkk dddd kkkk", OPCODE_lds_rc); - Register_Opcode(lpm1_Callback, "1001 0101 1100 1000", OPCODE_lpm_1); - Register_Opcode(lpm2_Callback, "1001 000d dddd 0100", OPCODE_lpm_2); - Register_Opcode(lpm3_Callback, "1001 000d dddd 0101", OPCODE_lpm_3); - // Register_Opcode(lsl_Callback, "0000 11dd dddd dddd", OPCODE_lsl); // Implied by add - Register_Opcode(lsr_Callback, "1001 010d dddd 0110", OPCODE_lsr); - Register_Opcode(mov_Callback, "0010 11rd dddd rrrr", OPCODE_mov); - Register_Opcode(movw_Callback, "0000 0001 dddd rrrr", OPCODE_movw); - Register_Opcode(mul_Callback, "1001 11rd dddd rrrr", OPCODE_mul); - Register_Opcode(muls_Callback, "0000 0010 dddd rrrr", OPCODE_muls); - Register_Opcode(mulsu_Callback, "0000 0011 0ddd 0rrr", OPCODE_mulsu); - Register_Opcode(neg_Callback, "1001 010d dddd 0001", OPCODE_neg); - Register_Opcode(nop_Callback, "0000 0000 0000 0000", OPCODE_nop); - Register_Opcode(or_Callback, "0010 10rd dddd rrrr", OPCODE_or); - Register_Opcode(ori_Callback, "0110 KKKK dddd KKKK", OPCODE_ori); - Register_Opcode(out_Callback, "1011 1AAr rrrr AAAA", OPCODE_out); - Register_Opcode(pop_Callback, "1001 000d dddd 1111", OPCODE_pop); - Register_Opcode(push_Callback, "1001 001d dddd 1111", OPCODE_push); - Register_Opcode(rcall_Callback, "1101 kkkk kkkk kkkk", OPCODE_rcall); - Register_Opcode(ret_Callback, "1001 0101 0000 1000", OPCODE_ret); - Register_Opcode(reti_Callback, "1001 0101 0001 1000", OPCODE_reti); - Register_Opcode(rjmp_Callback, "1100 kkkk kkkk kkkk", OPCODE_rjmp); - // Register_Opcode(rol_Callback, "0001 11dd dddd dddd", OPCODE_rol); // Implied by adc - Register_Opcode(ror_Callback, "1001 010d dddd 0111", OPCODE_ror); - Register_Opcode(sbc_Callback, "0000 10rd dddd rrrr", OPCODE_sbc); - Register_Opcode(sbci_Callback, "0100 KKKK dddd KKKK", OPCODE_sbci); - Register_Opcode(sbi_Callback, "1001 1010 AAAA Abbb", OPCODE_sbi); - Register_Opcode(sbic_Callback, "1001 1001 AAAA Abbb", OPCODE_sbic); - Register_Opcode(sbis_Callback, "1001 1011 AAAA Abbb", OPCODE_sbis); - Register_Opcode(sbiw_Callback, "1001 0111 KKdd KKKK", OPCODE_sbiw); - // Register_Opcode(sbr_Callback, "0110 KKKK dddd KKKK", OPCODE_sbr); // Implied by ori - Register_Opcode(sbrc_Callback, "1111 110r rrrr 0bbb", OPCODE_sbrc); - Register_Opcode(sbrs_Callback, "1111 111r rrrr 0bbb", OPCODE_sbrs); - Register_Opcode(sec_Callback, "1001 0100 0000 1000", OPCODE_sec); - Register_Opcode(seh_Callback, "1001 0100 0101 1000", OPCODE_seh); - Register_Opcode(sei_Callback, "1001 0100 0111 1000", OPCODE_sei); - Register_Opcode(sen_Callback, "1001 0100 0010 1000", OPCODE_sen); - Register_Opcode(ser_Callback, "1110 1111 dddd 1111", OPCODE_ser); - Register_Opcode(ses_Callback, "1001 0100 0100 1000", OPCODE_ses); - Register_Opcode(set_Callback, "1001 0100 0110 1000", OPCODE_set); - Register_Opcode(sev_Callback, "1001 0100 0011 1000", OPCODE_sev); - Register_Opcode(sez_Callback, "1001 0100 0001 1000", OPCODE_sez); - Register_Opcode(sleep_Callback, "1001 0101 1000 1000", OPCODE_sleep); - Register_Opcode(spm_Callback, "1001 0101 1110 1000", OPCODE_spm); - Register_Opcode(spm_zz_Callback, "1001 0101 1111 1000", OPCODE_spm_zz); - Register_Opcode(stx1_Callback, "1001 001r rrrr 1100", OPCODE_st_1); - Register_Opcode(stx2_Callback, "1001 001r rrrr 1101", OPCODE_st_2); - Register_Opcode(stx3_Callback, "1001 001r rrrr 1110", OPCODE_st_3); - Register_Opcode(sty1_Callback, "1000 001r rrrr 1000", OPCODE_st_4); - Register_Opcode(sty2_Callback, "1001 001r rrrr 1001", OPCODE_st_5); - Register_Opcode(sty3_Callback, "1001 001r rrrr 1010", OPCODE_st_6); - Register_Opcode(sty4_Callback, "10q0 qq1r rrrr 1qqq", OPCODE_std_1); - Register_Opcode(stz1_Callback, "1000 001r rrrr 0000", OPCODE_st_7); - Register_Opcode(stz2_Callback, "1001 001r rrrr 0001", OPCODE_st_8); - Register_Opcode(stz3_Callback, "1001 001r rrrr 0010", OPCODE_st_9); - Register_Opcode(stz4_Callback, "10q0 qq1r rrrr 0qqq", OPCODE_std_2); - Register_Opcode(sts_Callback, "1001 001d dddd 0000 kkkk kkkk kkkk kkkk", OPCODE_sts); - Register_Opcode(sts_rc_Callback, "1010 1kkk dddd kkkk", OPCODE_sts_rc); - Register_Opcode(sub_Callback, "0001 10rd dddd rrrr", OPCODE_sub); - Register_Opcode(subi_Callback, "0101 KKKK dddd KKKK", OPCODE_subi); - Register_Opcode(swap_Callback, "1001 010d dddd 0010", OPCODE_swap); - // Register_Opcode(tst_Callback, "0010 00dd dddd dddd", OPCODE_tst); // Implied by and - Register_Opcode(xch_Callback, "1001 001d dddd 0100", OPCODE_xch); - Register_Opcode(wdr_Callback, "1001 0101 1010 1000", OPCODE_wdr); - - // Also register unallocated opcodes - Register_Opcode(nop_Callback, "0000 0000 xxxx xxxx", OPCODE_u_nop_1); - Register_Opcode(nop_Callback, "1001 000x xxxx 0011", OPCODE_u_nop_2); - Register_Opcode(nop_Callback, "1001 000x xxxx 1000", OPCODE_u_nop_3); - Register_Opcode(nop_Callback, "1001 000x xxxx 1011", OPCODE_u_nop_4); - Register_Opcode(nop_Callback, "1001 001x xxxx 0011", OPCODE_u_nop_5); - Register_Opcode(nop_Callback, "1001 001x xxxx 1000", OPCODE_u_nop_6); - Register_Opcode(nop_Callback, "1001 001x xxxx 1011", OPCODE_u_nop_7); - Register_Opcode(icall_Callback, "1001 0101 xxx0 1001", OPCODE_u_icall); - Register_Opcode(eicall_Callback, "1001 0101 xxx1 1001", OPCODE_u_eicall); - Register_Opcode(ret_Callback, "1001 0101 0xx0 1000", OPCODE_u_ret); - Register_Opcode(reti_Callback, "1001 0101 0xx1 1000", OPCODE_u_reti); - Register_Opcode(nop_Callback, "1001 0101 1011 1000", OPCODE_u_nop_8); - Register_Opcode(nop_Callback, "1001 010x xxxx 0100", OPCODE_u_nop_9); - Register_Opcode(nop_Callback, "1001 0101 xxxx 1011", OPCODE_u_nop_a); - Register_Opcode(ijmp_Callback, "1001 0100 xxx0 1001", OPCODE_u_ijmp); - Register_Opcode(eijmp_Callback, "1001 0100 xxx1 1001", OPCODE_u_eijmp); - Register_Opcode(bld_Callback, "1111 100d dddd 1bbb", OPCODE_u_bld); - Register_Opcode(bst_Callback, "1111 101d dddd 1bbb", OPCODE_u_bst); - Register_Opcode(sbrc_Callback, "1111 110r rrrr 1bbb", OPCODE_u_sbrc); - Register_Opcode(sbrs_Callback, "1111 111r rrrr 1bbb", OPCODE_u_sbrs); - - qsort(cx->dis_op, cx->dis_n_ops, sizeof(Disasm_opcode), Comparison); + AVRMEM *mem; + // Sanity check (problems only occur if avr_opcodes was changed) for(size_t i = 0; i < sizeof avr_opcodes/sizeof*avr_opcodes; i++) if(avr_opcodes[i].mnemo != (AVR_opcode) i) { msg_error("avr_opcodes[] table broken (this should never happen)\n"); return -1; } + cx->dis_flashsz = 0; // Flash size rounded up to next power of two + cx->dis_addrwidth = 4; // Number of hex digits needed for flash addresses + cx->dis_sramwidth = 3; // Number of hex digits needed for sram addresses + + if((mem = avr_locate_flash(p)) && mem->size > 1) { + int nbits = intlog2(mem->size - 1) + 1; + cx->dis_flashsz = 1 << nbits; + cx->dis_addrwidth = (nbits+3)/4; + } + + if((mem = avr_locate_sram(p)) && mem->size > 1) { + int size = mem->size; + if(mem->offset > 0 && mem->offset <= 0x200) + size += mem->offset; + cx->dis_sramwidth = (intlog2(size - 1) + 1 + 3)/4; + } + + cx->dis_cycle_index = avr_get_cycle_index(p); + disasm_init_regfile(p); return 0; } diff --git a/src/disasm_callbacks_assembly.c b/src/disasm_callbacks_assembly.c deleted file mode 100644 index c5156283..00000000 --- a/src/disasm_callbacks_assembly.c +++ /dev/null @@ -1,892 +0,0 @@ -/* - * AVRDUDE - A Downloader/Uploader for AVR device programmers - * - * This file was ported from - * avrdisas - A disassembler for AVR microcontroller units - * Copyright (C) 2007 Johannes Bauer - * - * Copyright (C) 2024 port by Stefan Rueger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* $Id$ */ - - -#include -#include - -#include "libavrdude.h" -#include "disasm_private.h" - - -// Wrap r/jmp around flash where possible -static int FixTargetAddress(int Address) { - int flashsz = cx->dis_opts.FlashSize; - - // Flash size is a power of two: flash wraps round - if(flashsz > 0 && !(flashsz & (flashsz - 1))) { - Address %= flashsz; - if(Address < 0) - Address += flashsz; - } - return Address; -} - - -// Return the number of bits set in Number -static unsigned BitCount(unsigned n) { - unsigned ret; - - // A la Kernighan (and Richie): iteratively clear the least significant bit set - for(ret = 0; n; ret++) - n &= n-1; - - return ret; -} - -static void Operation_Simple(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%s", avr_opcodes[mnemo].opcode); -} - -static void Operation_Rd(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd); -} - -static void Operation_Z_Rd(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s Z, r%d", avr_opcodes[mnemo].opcode, Rd); -} - -static void Operation_Rd16(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d", avr_opcodes[mnemo].opcode, Rd + 16); -} - -static void Operation_Rd_Rr(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd, Rr); -} - -static void Operation_Rd16_Rr16(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, Rd + 16, Rr + 16); -} - -static void Operation_Rd16_K(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd + 16, RK); - snprintf(cx->dis_comment, 255, "%d", RK); -} - -static void Operation_RdW_RrW(AVR_opcode mnemo) { - if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, r%d:%d", avr_opcodes[mnemo].opcode, (2 * Rd) + 1, 2 * Rd, (2 * Rr) + 1, 2 * Rr); - } else { - snprintf(cx->dis_code, 255, "%-7s r%d, r%d", avr_opcodes[mnemo].opcode, 2 * Rd, 2 * Rr); - } -} - -static void Operation_s_k(AVR_opcode mnemo, int Position) { - int Bits, Offset; - int Target; - - Bits = Rs; - Offset = (2 * Rk); - if(Offset > 128) - Offset -= 256; - Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, mnemo, 0); - if(cx->dis_opts.Process_Labels == 0) { - if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s %d, .+%d", avr_opcodes[mnemo].opcode, Bits, Offset); - } else { - snprintf(cx->dis_code, 255, "%-7s %d, .%d", avr_opcodes[mnemo].opcode, Bits, Offset); - } - snprintf(cx->dis_comment, 255, "0x%02x = %d -> 0x%02x", (1 << Bits), (1 << Bits), Target); - } else { - snprintf(cx->dis_code, 255, "%-7s %d, %s", avr_opcodes[mnemo].opcode, Bits, Get_Label_Name(Target, NULL)); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bits), (1 << Bits)); - } -} - -static void Operation_r_b(AVR_opcode mnemo) { - int Register, Bit; - - Register = Rr; - Bit = Rb; - snprintf(cx->dis_code, 255, "%-7s r%d, %d", avr_opcodes[mnemo].opcode, Register, Bit); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -static void Operation_Rd_b(AVR_opcode mnemo) { - int Register, Bit; - - Register = Rd; - Bit = Rb; - snprintf(cx->dis_code, 255, "%-7s r%d, %d", avr_opcodes[mnemo].opcode, Register, Bit); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -static void Operation_A_b(AVR_opcode mnemo) { - int Register, Bit; - const char *Register_Name; - - Register = RA; - Bit = Rb; - Register_Name = Resolve_IO_Register(Register); - if(Register_Name == NULL) { - snprintf(cx->dis_code, 255, "%-7s 0x%02x, %d", avr_opcodes[mnemo].opcode, Register, Bit); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); - } else { - snprintf(cx->dis_code, 255, "%-7s %s, %d", avr_opcodes[mnemo].opcode, Register_Name, Bit); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); - } -} - -static void Operation_s(AVR_opcode mnemo) { - int Bit; - - Bit = Rs; - snprintf(cx->dis_code, 255, "%-7s %d", avr_opcodes[mnemo].opcode, Bit); - snprintf(cx->dis_comment, 255, "0x%02x = %d", (1 << Bit), (1 << Bit)); -} - -static void Operation_K(AVR_opcode mnemo) { - snprintf(cx->dis_code, 255, "%-7s %d", avr_opcodes[mnemo].opcode, RK); -} - -static void Operation_k(AVR_opcode mnemo, int Position, const char *Pseudocode) { - int Offset; - int Target; - - Offset = (2 * Rk); - if(Offset > 128) - Offset -= 256; - Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, mnemo, 0); - if(cx->dis_opts.Process_Labels == 0) { - if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s .+%d", avr_opcodes[mnemo].opcode, Offset); - } else { - snprintf(cx->dis_code, 255, "%-7s .%d", avr_opcodes[mnemo].opcode, Offset); - } - snprintf(cx->dis_comment, 255, "0x%02x", Target); - } else { - snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, Get_Label_Name(Target, NULL)); - } -} - -/************* Now to the callback functions *************/ - -CALLBACK(adc_Callback) { - if(Rd == Rr) { - Operation_Rd(OPCODE_rol); - } else { - Operation_Rd_Rr(mnemo); - } -} - -CALLBACK(add_Callback) { - if(Rd == Rr) { - Operation_Rd(OPCODE_lsl); - } else { - Operation_Rd_Rr(mnemo); - } -} - -CALLBACK(adiw_Callback) { - if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, 2 * Rd + 25, 2 * Rd + 24, RK); - } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, 2 * Rd + 24, RK); - } - snprintf(cx->dis_comment, 255, "%d", RK); -} - -CALLBACK(and_Callback) { - if(Rd == Rr) { - Operation_Rd(OPCODE_tst); - } else { - Operation_Rd_Rr(mnemo); - } -} - -CALLBACK(andi_Callback) { - if(BitCount(RK) < 4) { - Operation_Rd16_K(mnemo); - } else { - RK = ~RK; - RK &= 0xff; - Operation_Rd16_K(OPCODE_cbr); - } -} - -CALLBACK(asr_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(bclr_Callback) { - Operation_s(mnemo); -} - -CALLBACK(bld_Callback) { - Operation_Rd_b(mnemo); -} - -CALLBACK(brbc_Callback) { - Operation_s_k(mnemo, Position); -} - -CALLBACK(brbs_Callback) { - Operation_s_k(mnemo, Position); -} - -CALLBACK(brcc_Callback) { - Operation_k(mnemo, Position, "Carry == 0"); -} - -CALLBACK(brcs_Callback) { - Operation_k(mnemo, Position, "Carry == 1"); -} - -CALLBACK(break_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(breq_Callback) { - Operation_k(mnemo, Position, "c1 == c2"); -} - -CALLBACK(brge_Callback) { - Operation_k(mnemo, Position, "c1 (signed)>= c2"); -} - -CALLBACK(brhc_Callback) { - Operation_k(mnemo, Position, "HalfCarry == 0"); -} - -CALLBACK(brhs_Callback) { - Operation_k(mnemo, Position, "HalfCarry == 1"); -} - -CALLBACK(brid_Callback) { - Operation_k(mnemo, Position, "Global_Interrupts_Disabled()"); -} - -CALLBACK(brie_Callback) { - Operation_k(mnemo, Position, "Global_Interrupts_Enabled()"); -} - -CALLBACK(brlo_Callback) { - Operation_k(mnemo, Position, "c1 (unsigned)< c2"); -} - -CALLBACK(brlt_Callback) { - Operation_k(mnemo, Position, "c1 (signed)< c2"); -} - -CALLBACK(brmi_Callback) { - Operation_k(mnemo, Position, "< 0"); -} - -CALLBACK(brne_Callback) { - Operation_k(mnemo, Position, "c1 != c2"); -} - -CALLBACK(brpl_Callback) { - Operation_k(mnemo, Position, "> 0"); -} - -CALLBACK(brsh_Callback) { - Operation_k(mnemo, Position, "c1 (unsigned)>= c2"); -} - -CALLBACK(brtc_Callback) { - Operation_k(mnemo, Position, "T == 0"); -} - -CALLBACK(brts_Callback) { - Operation_k(mnemo, Position, "T == 1"); -} - -CALLBACK(brvc_Callback) { - Operation_k(mnemo, Position, "Overflow == 0"); -} - -CALLBACK(brvs_Callback) { - Operation_k(mnemo, Position, "Overflow == 1"); -} - -CALLBACK(bset_Callback) { - Operation_s(mnemo); -} - -CALLBACK(bst_Callback) { - Operation_Rd_b(mnemo); -} - -CALLBACK(call_Callback) { - int Pos; - - Pos = FixTargetAddress(2 * Rk); - Register_JumpCall(Position, Pos, mnemo, 1); - if(!cx->dis_opts.Process_Labels) { - snprintf(cx->dis_code, 255, "%-7s 0x%02x", avr_opcodes[mnemo].opcode, Pos); - } else { - char *LabelComment = NULL; - const char *LabelName = Get_Label_Name(Pos, &LabelComment); - - snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, LabelName); - if(LabelComment != NULL) - snprintf(cx->dis_comment, 255, "%s", LabelComment); - } -} - -CALLBACK(cbi_Callback) { - Operation_A_b(mnemo); -} - -CALLBACK(clc_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(clh_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(cli_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(cln_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(cls_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(clt_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(clv_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(clz_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(com_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(cp_Callback) { - Operation_Rd_Rr(mnemo); -} - -CALLBACK(cpc_Callback) { - Operation_Rd_Rr(mnemo); -} - -CALLBACK(cpi_Callback) { - Operation_Rd16_K(mnemo); -} - -CALLBACK(cpse_Callback) { - Operation_Rd_Rr(mnemo); -} - -CALLBACK(dec_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(des_Callback) { - Operation_K(mnemo); -} - -CALLBACK(eicall_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(eijmp_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(elpm1_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(elpm2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(elpm3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z+", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(eor_Callback) { - if(Rd == Rr) { - Operation_Rd(OPCODE_clr); - } else { - Operation_Rd_Rr(mnemo); - } -} - -CALLBACK(fmul_Callback) { - Operation_Rd16_Rr16(mnemo); -} - -CALLBACK(fmuls_Callback) { - Operation_Rd16_Rr16(mnemo); -} - -CALLBACK(fmulsu_Callback) { - Operation_Rd16_Rr16(mnemo); -} - -CALLBACK(icall_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(ijmp_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(in_Callback) { - int Register_Number; - const char *Register_Name; - - Register_Number = RA; - Register_Name = Resolve_IO_Register(Register_Number); - if(Register_Name != NULL) { - snprintf(cx->dis_code, 255, "%-7s r%d, %s", avr_opcodes[mnemo].opcode, Rd, Register_Name); - } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd, Register_Number); - snprintf(cx->dis_comment, 255, "%d", RA); - } -} - -CALLBACK(inc_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(jmp_Callback) { - int Pos; - - Pos = FixTargetAddress(2 * Rk); - if(!cx->dis_opts.Process_Labels) { - snprintf(cx->dis_code, 255, "%-7s 0x%02x", avr_opcodes[mnemo].opcode, Pos); - } else { - snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, Get_Label_Name(Pos, NULL)); - } - Register_JumpCall(Position, Pos, mnemo, 0); -} - -CALLBACK(lac_Callback) { - Operation_Z_Rd(mnemo); -} - -CALLBACK(las_Callback) { - Operation_Z_Rd(mnemo); -} - -CALLBACK(lat_Callback) { - Operation_Z_Rd(mnemo); -} - -CALLBACK(ldx1_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, X", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldx2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, X+", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldx3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, -X", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldy1_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Y", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldy2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Y+", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldy3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, -Y", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldy4_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Y+%d", avr_opcodes[mnemo].opcode, Rd, Rq); -} - -CALLBACK(ldz1_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldz2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z+", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldz3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, -Z", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(ldz4_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z+%d", avr_opcodes[mnemo].opcode, Rd, Rq); -} - -CALLBACK(ldi_Callback) { - Operation_Rd16_K(mnemo); -} - -CALLBACK(lds_Callback) { - const char *MemAddress; - - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%04x", avr_opcodes[mnemo].opcode, Rd, Rk); - MemAddress = Tagfile_Resolve_Mem_Address(Rk); - if(MemAddress) { - snprintf(cx->dis_comment, 255, "%s", MemAddress); - } -} - -CALLBACK(lds_rc_Callback) { - /* - * Address is limited to 0x40...0xbf for the reduced-core (TPI part) - * ADDR[7:0] ← (/INST[8], INST[8], INST[10], INST[9], INST[3], INST[2], INST[1], INST[0]) - * ADDR[7:0] ← (/k[4], k[4], k[6], k[5], k[3], k[2], k[1], k[0]) - */ - int addr = (Rk & 0xf) | ((Rk >> 1) & 0x30) | ((Rk & 0x10) << 2) | (((Rk & 0x10) ^ 0x10) << 3); - - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, Rd+16, addr); - const char *MemAddress = Tagfile_Resolve_Mem_Address(addr); - if(MemAddress) - snprintf(cx->dis_comment, 255, "%s", MemAddress); -} - -CALLBACK(lpm1_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(lpm2_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(lpm3_Callback) { - snprintf(cx->dis_code, 255, "%-7s r%d, Z+", avr_opcodes[mnemo].opcode, Rd); -} - -CALLBACK(lsr_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(mov_Callback) { - Operation_Rd_Rr(mnemo); -} - -CALLBACK(movw_Callback) { - Operation_RdW_RrW(mnemo); -} - -CALLBACK(mul_Callback) { - Operation_Rd_Rr(mnemo); -} - -CALLBACK(muls_Callback) { - Operation_Rd16_Rr16(mnemo); -} - -CALLBACK(mulsu_Callback) { - Operation_Rd16_Rr16(mnemo); -} - -CALLBACK(neg_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(nop_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(or_Callback) { - Operation_Rd_Rr(mnemo); -} - -CALLBACK(ori_Callback) { - Operation_Rd16_K(BitCount(RK) < 4? mnemo: OPCODE_sbr); -} - -CALLBACK(out_Callback) { - int Register_Number; - const char *Register_Name; - - Register_Number = RA; - Register_Name = Resolve_IO_Register(Register_Number); - if(Register_Name != NULL) { - snprintf(cx->dis_code, 255, "%-7s %s, r%d", avr_opcodes[mnemo].opcode, Register_Name, Rr); - } else { - snprintf(cx->dis_code, 255, "%-7s 0x%02x, r%d", avr_opcodes[mnemo].opcode, Register_Number, Rr); - snprintf(cx->dis_comment, 255, "%d", RA); - } -} - -CALLBACK(pop_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(push_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(rcall_Callback) { - int Offset; - int Target; - - Offset = 2 * (Rk); - if(Offset > 4096) - Offset -= 8192; - Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, mnemo, 1); - if(cx->dis_opts.Process_Labels == 0) { - if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s .+%d", avr_opcodes[mnemo].opcode, Offset); - } else { - snprintf(cx->dis_code, 255, "%-7s .%d", avr_opcodes[mnemo].opcode, Offset); - } - snprintf(cx->dis_comment, 255, "0x%02x", Target); - } else { - char *LabelComment = NULL; - const char *LabelName = Get_Label_Name(Target, &LabelComment); - - snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, LabelName); - if(LabelComment != NULL) - snprintf(cx->dis_comment, 255, "%s", LabelComment); - } -} - -CALLBACK(ret_Callback) { - Operation_Simple(mnemo); - snprintf(cx->dis_after_code, 255, "\n"); -} - -CALLBACK(reti_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(rjmp_Callback) { - int Offset; - int Target; - - Offset = 2 * (Rk); - if(Offset > 4096) - Offset -= 8192; - Target = FixTargetAddress(Position + Offset + 2); - - Register_JumpCall(Position, Target, mnemo, 0); - if(cx->dis_opts.Process_Labels == 0) { - if(Offset > 0) { - snprintf(cx->dis_code, 255, "%-7s .+%d", avr_opcodes[mnemo].opcode, Offset); - } else { - snprintf(cx->dis_code, 255, "%-7s .%d", avr_opcodes[mnemo].opcode, Offset); - } - if(Target >= 0) { - snprintf(cx->dis_comment, 255, "0x%02x", Target); - } else { - snprintf(cx->dis_comment, 255, "-0x%02x - Illegal jump position?", -Target); - } - } else { - snprintf(cx->dis_code, 255, "%-7s %s", avr_opcodes[mnemo].opcode, Get_Label_Name(Target, NULL)); - } -} - -CALLBACK(ror_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(sbc_Callback) { - Operation_Rd_Rr(mnemo); -} - -CALLBACK(sbci_Callback) { - Operation_Rd16_K(mnemo); -} - -CALLBACK(sbi_Callback) { - Operation_A_b(mnemo); -} - -CALLBACK(sbic_Callback) { - Operation_A_b(mnemo); -} - -CALLBACK(sbis_Callback) { - Operation_A_b(mnemo); -} - -CALLBACK(sbiw_Callback) { - if(cx->dis_opts.CodeStyle == CODESTYLE_AVR_INSTRUCTION_SET) { - snprintf(cx->dis_code, 255, "%-7s r%d:%d, 0x%02x", avr_opcodes[mnemo].opcode, 2 * Rd + 25, 2 * Rd + 24, RK); - } else { - snprintf(cx->dis_code, 255, "%-7s r%d, 0x%02x", avr_opcodes[mnemo].opcode, 2 * Rd + 24, RK); - } - snprintf(cx->dis_comment, 255, "%d", RK); -} - -CALLBACK(sbrc_Callback) { - Operation_r_b(mnemo); -} - -CALLBACK(sbrs_Callback) { - Operation_r_b(mnemo); -} - -CALLBACK(sec_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(seh_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(sei_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(sen_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(ser_Callback) { - Operation_Rd16(mnemo); -} - -CALLBACK(ses_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(set_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(sev_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(sez_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(sleep_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(spm_Callback) { - Operation_Simple(mnemo); -} - -CALLBACK(spm_zz_Callback) { - snprintf(cx->dis_code, 255, "%-7s Z+", avr_opcodes[mnemo].opcode); -} - -CALLBACK(stx1_Callback) { - snprintf(cx->dis_code, 255, "%-7s X, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(stx2_Callback) { - snprintf(cx->dis_code, 255, "%-7s X+, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(stx3_Callback) { - snprintf(cx->dis_code, 255, "%-7s -X, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(sty1_Callback) { - snprintf(cx->dis_code, 255, "%-7s Y, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(sty2_Callback) { - snprintf(cx->dis_code, 255, "%-7s Y+, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(sty3_Callback) { - snprintf(cx->dis_code, 255, "%-7s -Y, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(sty4_Callback) { - snprintf(cx->dis_code, 255, "%-7s Y+%d, r%d", avr_opcodes[mnemo].opcode, Rq, Rr); -} - -CALLBACK(stz1_Callback) { - snprintf(cx->dis_code, 255, "%-7s Z, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(stz2_Callback) { - snprintf(cx->dis_code, 255, "%-7s Z+, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(stz3_Callback) { - snprintf(cx->dis_code, 255, "%-7s -Z, r%d", avr_opcodes[mnemo].opcode, Rr); -} - -CALLBACK(stz4_Callback) { - snprintf(cx->dis_code, 255, "%-7s Z+%d, r%d", avr_opcodes[mnemo].opcode, Rq, Rr); -} - -CALLBACK(sts_Callback) { - // The AVR instruction set 11/2005 defines operation as: "(k) <- Rr", however "(k) <- Rd" seems to be right - const char *MemAddress; - - MemAddress = Tagfile_Resolve_Mem_Address(Rk); - snprintf(cx->dis_code, 255, "%-7s 0x%04x, r%d", avr_opcodes[mnemo].opcode, Rk, Rd); - if(MemAddress) { - snprintf(cx->dis_comment, 255, "%s", MemAddress); - } -} - -CALLBACK(sts_rc_Callback) { - /* - * Address is limited to 0x40...0xbf for the reduced-core (TPI part) - * ADDR[7:0] ← (/INST[8], INST[8], INST[10], INST[9], INST[3], INST[2], INST[1], INST[0]) - * ADDR[7:0] ← (/k[4], k[4], k[6], k[5], k[3], k[2], k[1], k[0]) - */ - int addr = (Rk & 0xf) | ((Rk >> 1) & 0x30) | ((Rk & 0x10) << 2) | (((Rk & 0x10) ^ 0x10) << 3); - - snprintf(cx->dis_code, 255, "%-7s 0x%02x, r%d", avr_opcodes[mnemo].opcode, addr, Rd+16); - const char *MemAddress = Tagfile_Resolve_Mem_Address(addr); - if(MemAddress) - snprintf(cx->dis_comment, 255, "%s", MemAddress); -} - -CALLBACK(sub_Callback) { - Operation_Rd_Rr(mnemo); -} - -CALLBACK(subi_Callback) { - Operation_Rd16_K(mnemo); -} - -CALLBACK(swap_Callback) { - Operation_Rd(mnemo); -} - -CALLBACK(xch_Callback) { - Operation_Z_Rd(mnemo); -} - -CALLBACK(wdr_Callback) { - Operation_Simple(mnemo); -} diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 23ca365a..113929e0 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -41,20 +41,20 @@ void disasm_zap_JumpCalls() { cx->dis_JumpCallN = 0; } -void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall) { - if((cx->dis_opts.Process_Labels == 1) && (cx->dis_pass == 1)) { +void Register_JumpCall(int From, int To, int mnemo, unsigned char FunctionCall) { + if(cx->dis_opts.Process_Labels) { Disasm_JumpCall *jc = cx->dis_JumpCalls; int N = cx->dis_JumpCallN; // Already entered this JC? for(int i = 0; i < N; i++) - if(jc[i].From == From && jc[N].To == To && jc[N].Type == Type) + if(jc[i].From == From && jc[N].To == To && jc[N].mnemo == mnemo) return; jc = mmt_realloc(jc, sizeof(Disasm_JumpCall) * (N+1)); jc[N].From = From; jc[N].To = To; - jc[N].Type = Type; + jc[N].mnemo = mnemo; jc[N].LabelNumber = 0; jc[N].FunctionCall = FunctionCall; @@ -75,10 +75,6 @@ static int JC_Comparison(const void *Element1, const void *Element2) { return -1; } -static void Sort_JumpCalls() { - qsort(cx->dis_JumpCalls, cx->dis_JumpCallN, sizeof(Disasm_JumpCall), JC_Comparison); -} - static void Correct_Label_Types(void) { int i, j; int LastIdx = 0; @@ -93,7 +89,7 @@ static void Correct_Label_Types(void) { LastDest = cx->dis_JumpCalls[i].To; CurType = 0; } - CurType = (CurType || cx->dis_JumpCalls[i].FunctionCall); + CurType = CurType || cx->dis_JumpCalls[i].FunctionCall; } for(j = LastIdx; j < cx->dis_JumpCallN; j++) cx->dis_JumpCalls[j].FunctionCall = CurType; @@ -108,7 +104,7 @@ void Enumerate_Labels(void) { if(cx->dis_JumpCallN < 2) return; - Sort_JumpCalls(); + qsort(cx->dis_JumpCalls, cx->dis_JumpCallN, sizeof(Disasm_JumpCall), JC_Comparison); Correct_Label_Types(); Destination = cx->dis_JumpCalls[0].To; @@ -159,7 +155,8 @@ void Print_JumpCalls(int Position) { term_out("\n"); Match = 1; } - term_out("; Referenced from offset 0x%02x by %s\n", cx->dis_JumpCalls[i].From, avr_opcodes[cx->dis_JumpCalls[i].Type].opcode); + term_out("; Referenced from 0x%0*x by %s\n", cx->dis_addrwidth, + cx->dis_JumpCalls[i].From, avr_opcodes[cx->dis_JumpCalls[i].mnemo].opcode); } } if(Match == 1) { diff --git a/src/disasm_private.h b/src/disasm_private.h index 13af2c77..3df3de50 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -26,17 +26,6 @@ #ifndef disasm_private_h #define disasm_private_h -#define Rd (cx->dis_regs['d']) -#define Rr (cx->dis_regs['r']) -#define Rk (cx->dis_regs['k']) -#define RK (cx->dis_regs['K']) -#define Rs (cx->dis_regs['s']) -#define RA (cx->dis_regs['A']) -#define Rb (cx->dis_regs['b']) -#define Rq (cx->dis_regs['q']) - -#define CALLBACK(name) void name(const char *Bitstream, int Position, AVR_opcode mnemo) - #define TYPE_BYTE 1 #define TYPE_WORD 2 #define TYPE_ASTRING 3 @@ -58,143 +47,4 @@ void Enumerate_Labels(); const char *Get_Label_Name(int Destination, char **LabelComment); void Print_JumpCalls(int Position); -void adc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void add_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void adiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void and_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void andi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void asr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void bclr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void bld_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brbc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brbs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brcc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brcs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void break_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void breq_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brge_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brhc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brhs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brid_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brie_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brlo_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brlt_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brmi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brne_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brpl_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brsh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brtc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brvc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void brvs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void bset_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void bst_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void call_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cli_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cln_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clt_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clv_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void clz_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void com_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void cpse_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void dec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void des_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void eicall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void eijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void elpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void elpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void elpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void eor_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void fmul_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void fmuls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void fmulsu_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void icall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ijmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void in_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void inc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void jmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lac_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void las_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lat_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldy1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldy2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldy3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldy4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldz1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ldi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lds_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lds_rc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lpm1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lpm2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lpm3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void lsr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void mov_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void movw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void mul_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void muls_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void mulsu_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void neg_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void nop_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void or_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ori_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void out_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void pop_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void push_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void rcall_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ret_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void reti_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void rjmp_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ror_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbci_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbic_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbis_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbiw_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbrc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sbrs_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sec_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void seh_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sei_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sen_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ser_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void ses_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void set_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sev_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sez_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sleep_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void spm_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void spm_zz_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stx1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stx2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stx3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sty1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sty2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sty3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sty4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stz1_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stz2_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stz3_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void stz4_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sts_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sts_rc_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void sub_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void subi_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void swap_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void xch_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); -void wdr_Callback(const char *Bitstream, int Position, AVR_opcode mnemo); - #endif diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index 81e96dbc..02e08fd6 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -432,7 +432,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { } if(cx->dis_PGMLabels[Index].Count != 1) term_out("s"); - term_out(" starting at 0x%x", disasm_wrap(Position + offset)); + term_out(" starting at 0x%0*x", cx->dis_addrwidth, disasm_wrap(Position + offset)); if(cx->dis_PGMLabels[Index].Comment != NULL) { term_out(" (%s)", cx->dis_PGMLabels[Index].Comment); @@ -457,8 +457,8 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { if((BytesAdvanced % 2) != 0) { // Not yet aligned correctly if(Bitstream[Position + BytesAdvanced] != 0x00) - pmsg_warning("autoalignment expected zero but got 0x%0x padding; ignored\n", - ((unsigned char *) Bitstream)[Position + BytesAdvanced]); + pmsg_warning("autoalignment expected zero but got 0x%02x padding; ignored\n", + Bitstream[Position + BytesAdvanced] & 0xff); term_out(".byte 0x%02x ; String Autoalignment\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); BytesAdvanced++; } @@ -549,5 +549,5 @@ const char *Resolve_IO_Register(int Number) { void Emit_Used_IO_Registers() { for(int i = 0; i < cx->dis_IORegisterN; i++) if(cx->dis_IORegisters[i].Used) - term_out(".equ %s, 0x%x\n", cx->dis_IORegisters[i].Name, cx->dis_IORegisters[i].Address); + term_out(".equ %s, 0x%02x\n", cx->dis_IORegisters[i].Name, cx->dis_IORegisters[i].Address); } diff --git a/src/libavrdude.h b/src/libavrdude.h index f74a78e5..5c4f0be2 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1459,18 +1459,16 @@ typedef struct { int Show_Opcodes; int Show_Comments; int Show_Cycles; - char *Tagfile; - int CodeStyle; + int avrgcc_style; int Process_Labels; - int FlashSize; - int AVR_Level; - AVR_cycle_index cycle_index; + int avrlevel; + char *Tagfile; } Disasm_options; typedef struct { int From; int To; - int Type; + int mnemo; unsigned int LabelNumber; int FunctionCall; } Disasm_JumpCall; @@ -1548,13 +1546,6 @@ typedef enum { OPCODE_N } AVR_opcode; -typedef struct { - char *Opcode_String; - void (*Callback)(const char *, int, AVR_opcode); - AVR_opcode mnemo; -} Disasm_opcode; - - typedef enum { OP_AVR_RC = 1, // Reduced-core Tiny only (128 byte STS/LDS) OP_AVR1 = 2, // All AVR can run this OPCODE @@ -1636,9 +1627,6 @@ typedef struct { extern const AVR_opcode_data avr_opcodes[164]; -#define CODESTYLE_AVR_INSTRUCTION_SET 0 -#define CODESTYLE_AVRGCC 1 - #ifdef __cplusplus extern "C" { #endif @@ -1711,6 +1699,7 @@ bool is_bigendian(void); void change_endian(void *p, int size); int is_memset(const void *p, char c, size_t n); unsigned long long int str_ull(const char *str, char **endptr, int base); +int looks_like_number(const char *str); Str2data *str_todata(const char *str, int type, const AVRPART *part, const char *memstr); void str_freedata(Str2data *sd); unsigned long long int str_int(const char *str, int type, const char **errpp); @@ -1740,12 +1729,15 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); int is_opcode32(int op); +int ldi_register(int op); int opcode_match(int op, AVR_opcode mnemo); AVR_opcode opcode_mnemo(int op, int avrlevel); +int avr_get_archlevel(const AVRPART *p); +AVR_cycle_index avr_get_cycle_index(const AVRPART *p); int disasm_init(const AVRPART *p); int disasm_init_tagfile(const AVRPART *p, const char *file); -int disasm(const char *buf, int len, int addr); +int disasm(const char *buf, int len, int addr, int leadin, int leadout); void disasm_zap_JumpCalls(); #ifdef __cplusplus @@ -1840,12 +1832,8 @@ typedef struct { int reccount; // Static variables from disasm*.c - int dis_initopts, dis_pass; + int dis_initopts, dis_flashsz, dis_addrwidth, dis_sramwidth, dis_cycle_index; Disasm_options dis_opts; - int dis_n_ops; - Disasm_opcode dis_op[256]; // Must be 256 - int dis_regs[256]; // Must be 256 - char dis_code[256], dis_comment[256], dis_after_code[256]; // Must be 256 int dis_JumpCallN, dis_CodeLabelN, dis_PGMLabelN, dis_MemLabelN, dis_IORegisterN; Disasm_JumpCall *dis_JumpCalls; Disasm_CodeLabel *dis_CodeLabels; diff --git a/src/strutil.c b/src/strutil.c index 9fcd158f..21be3d3a 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -667,6 +667,33 @@ unsigned long long int str_ull(const char *str, char **endptr, int base) { return ret; } +// Returns whether or not the string str looks like a number +int looks_like_number(const char *str) { + int base = 0; + char *endptr; + + while(isspace(*str & 0xff)) + str++; + + // Skip sign but don't allow double sign + if(*str == '-' || *str == '+') { + str++; + if(*str == '-' || *str == '+') + return 0; + } + + if(*str == '0' && (str[1] == 'b' || str[1] == 'B')) + base = 2, str+=2; + else if(*str == '0' && (str[1] == 'x' || str[1] == 'X')) + base = 16, str+=2; + + + errno = 0; + (void) strtoull(str, &endptr, base); + + return endptr != str && !*endptr && !errno; +} + /* * str_todata() is the workhorse for generic string to data conversion for the terminal write diff --git a/src/term.c b/src/term.c index ab21db79..e51efad6 100644 --- a/src/term.c +++ b/src/term.c @@ -212,13 +212,41 @@ static int hexdump_buf(const FILE *f, const AVRMEM *m, int startaddr, const unsi return 0; } +static int disasm_ison(char c) { + switch(c) { + case 'a': return cx->dis_opts.Show_Addresses; + case 'o': return cx->dis_opts.Show_Opcodes; + case 'c': return cx->dis_opts.Show_Comments; + case 'q': return cx->dis_opts.Show_Cycles; + case 's': return cx->dis_opts.avrgcc_style; + case 'l': return cx->dis_opts.Process_Labels; + case 'd': return cx->dis_opts.avrlevel == (PART_ALL | OP_AVR_ILL); + } + return 0; +} + +/* + * Read in memory spec'd by disasm or read/dump's (argc, argv) syntax + * + * Return a buffer with three sections + * - up to two lead-in bytes (*prequel) + * - blen bytes (buf + *prequel corresponds to address *baddr) + * - up to 7 lead-out bytes (*sequel) + * + * Also tell the caller which memory (*memp) was read from. + * + * dump/read needs *memp, *baddr and *blen (*prequel and *sequel are 0) + * disasm needs *baddr, *blen, *prequel and *sequel + */ -// Just read in memory; used by cmd_dump() and cmd_disasm() static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[], - const AVRMEM **memp, int *baddr, int *blen) { + const AVRMEM **memp, int *baddr, int *blen, int *prequel, int *sequel) { int i = cx->term_mi; const char *cmd = tolower(**argv) == 'r'? "read": str_casestarts(*argv, "di")? "disasm []": "dump"; + int is_disasm = cmd[1] == 'i'; + int default_read_size = is_disasm? 32: 256; + if ((argc < 2 && cx->term_rmem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { msg_error( "Syntax: %s # Entire region\n" @@ -227,17 +255,25 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, " %s # Continue with most recently shown \n" "Function: %s\n", cmd, cmd, cmd, cmd, - cmd[1] == 'i'? "disassemble memory section": "display memory section as hex dump" + is_disasm? "disassemble memory section": "display memory section as hex dump" ); - if(cmd[1] == 'i') { - msg_error("Options:\n" - " -a show addresses (default), -A don't show addresses\n" - " -o show opcode bytes (default), -O don't show opcode bytes\n" - " -c show comments (default), -C don't show comments\n" - " -q show call cycles, -Q don't show call cycles (default)\n" - " -s use avr-gcc code style (default), -S use AVR inst set code style\n" - " -l preprocess jump/call (default), -L don't preprocess jump/call\n" - " -d decode all (even unallocated) opcodes; -D only those of the part\n" + if(is_disasm) { + struct { char ochr[2]; const char *info[2]; } opts[] = { + {{'a', 'A'}, {"show addresses", "don't show addresses"}}, + {{'o', 'O'}, {"show opcode bytes", "don't show opcode bytes"}}, + {{'c', 'C'}, {"show comments", "don't show comments"}}, + {{'q', 'Q'}, {"show cycles", "don't show cycles"}}, + {{'s', 'S'}, {"use avr-gcc code style", "use AVR instruction set style"}}, + {{'l', 'L'}, {"preprocess jump/call labels", "don't preprocess labels"}}, + {{'d', 'D'}, {"decode all opcodes", "decode only opcodes for the part"}}, + }; + + msg_error("Options:\n"); + for(size_t i = 0; i < sizeof opts/sizeof*opts; i++) { + int on = disasm_ison(opts[i].ochr[0]); + msg_error(" -%c %s, -%c %s\n", opts[i].ochr[on], opts[i].info[on], opts[i].ochr[!on], opts[i].info[!on]); + } + msg_error( " -z zap list of jumps/calls before disassembly\n" " -t= set the tagfile (zaps old tagfile contents)\n" ); @@ -248,12 +284,11 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, "the interval at that many bytes below the memory size.\n" "\n" "The latter two versions of the command page through the memory with a page\n" - "size of the last used effective length (256 bytes default)\n" + "size of the last used effective length (%d bytes default)\n", default_read_size ); return NULL; } - enum { read_size = 256 }; const char *memstr; if(argc > 1) memstr = argv[1]; @@ -277,7 +312,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, cx->term_rmem[i].mem = mem; if(cx->term_rmem[i].mem == mem) { if(cx->term_rmem[i].len == 0) - cx->term_rmem[i].len = maxsize > read_size? read_size: maxsize; + cx->term_rmem[i].len = maxsize > default_read_size? default_read_size: maxsize; break; } } @@ -327,15 +362,9 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, if (len < 0) len = maxsize + len + 1 - cx->term_rmem[i].addr; - if (len == 0) { - if(memp) - *memp = mem; - if(baddr) - *baddr = 0; - if(blen) - *blen = 0; - return mmt_malloc(16); - } + if (len == 0) + goto nocontent; + if (len < 0) { pmsg_error("(%s) invalid effective length %d\n", cmd, len); return NULL; @@ -356,39 +385,75 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, term_out(">>> %s %s 0x%x 0x%x\n", cmd, cx->term_rmem[i].mem->desc, cx->term_rmem[i].addr, cx->term_rmem[i].len); + int toread = cx->term_rmem[i].len; + int whence = cx->term_rmem[i].addr; + int before = 0, after = 0; + if(is_disasm) { // Read a few bytes before/after & don't wrap round + if(whence >= 2) + before = 2, whence -= 2, toread += 2; + if(whence + toread > maxsize) // Clip to end of memory + toread = maxsize - whence; + int gap = maxsize - whence - toread; + after = gap >= 7? 7: gap < 0? 0: gap; + toread += after; + if(toread-before < 2) + goto nocontent; + } + report_progress(0, 1, "Reading"); - for (int j = 0; j < cx->term_rmem[i].len; j++) { - int addr = (cx->term_rmem[i].addr + j) % mem->size; + for (int j = 0; j < toread; j++) { + int addr = (whence + j) % mem->size; int rc = pgm->read_byte_cached(pgm, p, cx->term_rmem[i].mem, addr, &buf[j]); if (rc != 0) { report_progress(1, -1, NULL); pmsg_error("(%s) error reading %s address 0x%05lx of part %s\n", cmd, mem->desc, - (long) cx->term_rmem[i].addr + j, p->desc); + (long) whence + j, p->desc); if (rc == -1) imsg_error("%*sread operation not supported on memory %s\n", 7, "", mem->desc); mmt_free(buf); return NULL; } - report_progress(j, cx->term_rmem[i].len, NULL); + report_progress(j, toread, NULL); } report_progress(1, 1, NULL); - if(memp) - *memp = mem; - if(baddr) - *baddr = cx->term_rmem[i].addr; - if(blen) - *blen = cx->term_rmem[i].len; + if(is_disasm) { // Adjust length so buffer does not split opcodes + int i = before, end = toread-after, wend = after? end: end-1; + while(i < wend) + i += is_opcode32(buf[i] | buf[i+1]<<8)? 4: 2; + if(i < end) // Odd length: shorten by one byte + after += end-i; + else if(i > end && after >= i-end) // Increase length to accommodate last 32-bit opcode + after -= i-end; + else if(i > end) // Reduce length + after += i-end; + } - cx->term_rmem[i].addr = (cx->term_rmem[i].addr + cx->term_rmem[i].len) % maxsize; + if(memp) *memp = mem; + if(baddr) *baddr = whence + before; + if(blen) *blen = toread - before - after; + if(prequel) *prequel = before; + if(sequel) *sequel = after; + + // Memorise where to start next time + cx->term_rmem[i].addr = (whence + toread - after) % maxsize; return buf; + +nocontent: + if(memp) *memp = mem; + if(baddr) *baddr = 0; + if(blen) *blen = 0; + if(prequel) *prequel = 0; + if(sequel) *sequel = 0; + + return mmt_malloc(16); } static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { int addr, len; const AVRMEM *mem = NULL; - uint8_t *buf = readbuf(pgm, p, argc, argv, &mem, &addr, &len); + uint8_t *buf = readbuf(pgm, p, argc, argv, &mem, &addr, &len, NULL, NULL); if(!buf) return -1; @@ -400,66 +465,8 @@ static int cmd_dump(const PROGRAMMER *pgm, const AVRPART *p, int argc, const cha return 0; } -static int get_avr_archlevel(const AVRPART *p) { - int ret = - p->prog_modes & PM_UPDI? PART_AVR_XT: - p->prog_modes & PM_PDI? PART_AVR_XM: - p->prog_modes & PM_TPI? PART_AVR_RC: 0; - - if(!ret) { // Non-TPI classic part - switch(p->archnum) { - case 1: - ret = PART_AVR1; - break; - default: // If AVRDUE doesn't know, it's probably rare & old - case 2: - ret = PART_AVR2; - break; - case 25: - ret = PART_AVR25; - break; - case 3: case 31: case 35: // Sic - ret = PART_AVR3; - break; - break; - case 4: - ret = PART_AVR4; - break; - case 5: - ret = PART_AVR5; - break; - case 51: - ret = PART_AVR51; - break; - case 6: - ret = PART_AVR6; - } - } - - AVRMEM *mem = avr_locate_flash(p); - if(mem) { // Add opcodes needed for large parts in any case - if(mem->size > 8192) - ret |= OP_AVR_M; // JMP, CALL - if(mem->size > 65536) - ret |= OP_AVR_L; // ELPM - if(mem->size > 128*1024) - ret |= OP_AVR_XL; // EIJMP, EICALL - } - - return ret; -} - -static AVR_cycle_index get_avr_cycle_index(const AVRPART *p) { - return - p->prog_modes & PM_UPDI? OP_AVRxt: - p->prog_modes & PM_PDI? OP_AVRxm: - p->prog_modes & PM_TPI? OP_AVRrc: OP_AVRe; -} - - static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { - int addr, len; - const AVRMEM *mem = NULL; + int addr, len, leadin, leadout; uint8_t *buf; int help = 0, invalid = 0, itemac = 1, chr; @@ -469,20 +476,17 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.Show_Opcodes = 1; cx->dis_opts.Show_Comments = 1; cx->dis_opts.Show_Cycles = 0; - cx->dis_opts.Tagfile = NULL; - cx->dis_opts.CodeStyle = CODESTYLE_AVRGCC; // CODESTYLE_AVR_INSTRUCTION_SET + cx->dis_opts.avrgcc_style = 1; cx->dis_opts.Process_Labels = 1; - mem = avr_locate_flash(p); - cx->dis_opts.FlashSize = mem? mem->size: 0; - cx->dis_opts.AVR_Level = get_avr_archlevel(p); - cx->dis_opts.cycle_index = get_avr_cycle_index(p); + cx->dis_opts.Tagfile = NULL; + cx->dis_opts.avrlevel = avr_get_archlevel(p); disasm_init(p); cx->dis_initopts++; } for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; - if(*(q = argv[++ai]) != '-' || !q[1]) + if(*(q = argv[++ai]) != '-' || !q[1] || looks_like_number(q)) argv[itemac++] = argv[ai]; else { while(*++q) { @@ -504,7 +508,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.Show_Cycles = islower(chr); break; case 's': case 'S': - cx->dis_opts.CodeStyle = islower(chr)? CODESTYLE_AVRGCC: CODESTYLE_AVR_INSTRUCTION_SET; + cx->dis_opts.avrgcc_style = islower(chr); break; case 'l': case 'L': cx->dis_opts.Process_Labels = islower(chr); @@ -513,10 +517,10 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c disasm_zap_JumpCalls(); break; case 'd': - cx->dis_opts.AVR_Level = PART_ALL | OP_AVR_ILL; + cx->dis_opts.avrlevel = PART_ALL | OP_AVR_ILL; break; case 'D': - cx->dis_opts.AVR_Level = get_avr_archlevel(p); + cx->dis_opts.avrlevel = avr_get_archlevel(p); break; case 't': if(*++q == '=') @@ -537,7 +541,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c if(help || invalid) { const char *help[] = { "disasm", "-?", NULL, }; - readbuf(pgm, p, 2, help, NULL, NULL, NULL); + readbuf(pgm, p, 2, help, NULL, NULL, NULL, NULL, NULL); return -1; } @@ -545,13 +549,13 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c if(disasm_init_tagfile(p, cx->dis_opts.Tagfile) < 0) return -1; - buf = readbuf(pgm, p, argc, argv, &mem, &addr, &len); + buf = readbuf(pgm, p, argc, argv, NULL, &addr, &len, &leadin, &leadout); if(!buf) return -1; if(len > 0) - disasm((char *) buf, len, addr); + disasm((char *) buf+leadin, len, addr, leadin, leadout); lterm_out(""); mmt_free(buf); From 41c18a2d18ac61ffc094e8d5f67ef3a115ace4c3 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 12:50:46 +0100 Subject: [PATCH 336/422] Warn when opcodes have undefined results, eg, ld r26, X+ --- src/avr_opcodes.c | 30 +++++++++++++++--------------- src/disasm.c | 34 +++++++++++++++++++++++----------- src/libavrdude.h | 42 +++++++++++++++++++++++++----------------- 3 files changed, 63 insertions(+), 43 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 4a0e35e6..4ef94fb9 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -312,19 +312,19 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(ld_1), 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "--------", {"2", "2", "2", "1/2"}, ""}, - {OP_ID(ld_2), 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL, + {OP_ID(ld_2), 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL|OTY_XWRN, "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X), X <-- X + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OP_ID(ld_3), 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL, + {OP_ID(ld_3), 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL|OTY_XWRN, "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X - 1, Rd <-- (X)", "--------", {"2", "3", "2", "2/3"}, ""}, {OP_ID(ld_4), 0xfe0f, 0x8008, 1, OP_AVR2, "1000 000d dddd 1000", OTY_XFRX|OTY_RALL, "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Y+0"}, - {OP_ID(ld_5), 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL, + {OP_ID(ld_5), 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL|OTY_YWRN, "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y), Y <-- Y + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OP_ID(ld_6), 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL, + {OP_ID(ld_6), 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL|OTY_YWRN, "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y - 1 Rd <-- (Y)", "--------", {"2", "3", "2", "2/3"}, ""}, {OP_ID(ldd_1), 0xd208, 0x8008, 1, OP_AVR2nRC, "10q0 qq0d dddd 1qqq", OTY_XFRX|OTY_RALL, @@ -333,10 +333,10 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(ld_7), 0xfe0f, 0x8000, 1, OP_AVR1, "1000 000d dddd 0000", OTY_XFRX|OTY_RALL, "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Z+0"}, - {OP_ID(ld_8), 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL, + {OP_ID(ld_8), 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL|OTY_ZWRN, "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OP_ID(ld_9), 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL, + {OP_ID(ld_9), 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL|OTY_ZWRN, "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z - 1, Rd <-- (Z)", "--------", {"2", "3", "2", "2/3"}, ""}, {OP_ID(ldd_2), 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, @@ -348,19 +348,19 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(st_1), 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "--------", {"2", "1", "1", "1"}, ""}, - {OP_ID(st_2), 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL, + {OP_ID(st_2), 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL|OTY_XWRN, "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OP_ID(st_3), 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL, + {OP_ID(st_3), 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL|OTY_XWRN, "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X - 1, (X) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OP_ID(st_4), 0xfe0f, 0x8208, 1, OP_AVR2, "1000 001r rrrr 1000", OTY_XFRX|OTY_RALL, "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Y+0, Rr"}, - {OP_ID(st_5), 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL, + {OP_ID(st_5), 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL|OTY_YWRN, "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OP_ID(st_6), 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL, + {OP_ID(st_6), 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL|OTY_YWRN, "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y - 1, (Y) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OP_ID(std_1), 0xd208, 0x8208, 1, OP_AVR2nRC, "10q0 qq1r rrrr 1qqq", OTY_XFRX|OTY_RALL, @@ -369,10 +369,10 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(st_7), 0xfe0f, 0x8200, 1, OP_AVR1, "1000 001r rrrr 0000", OTY_XFRX|OTY_RALL, "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Z+0, Rr"}, - {OP_ID(st_8), 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL, + {OP_ID(st_8), 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL|OTY_ZWRN, "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr, Z <-- Z + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OP_ID(st_9), 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL, + {OP_ID(st_9), 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL|OTY_ZWRN, "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z - 1, (Z) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OP_ID(std_2), 0xd208, 0x8200, 1, OP_AVR2nRC, "10q0 qq1r rrrr 0qqq", OTY_XFRX|OTY_RALL, @@ -384,7 +384,7 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(lpm_2), 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OP_ID(lpm_3), 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL, + {OP_ID(lpm_3), 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL|OTY_ZWRN, "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(elpm_1), 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, @@ -393,7 +393,7 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(elpm_2), 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OP_ID(elpm_3), 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL, + {OP_ID(elpm_3), 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL|OTY_ZWRN, "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(spm), 0xffff, 0x95e8, 1, OP_AVR25, "1001 0101 1110 1000", OTY_XFRX, @@ -589,7 +589,7 @@ const AVR_opcode_data avr_opcodes[164] = { {"1-3", "1-3", "1-3", "1/2"}, ""}, }; -// Return whether or not the giveb 16-bit opcode has a 16-bit address argument +// Return whether or not the given 16-bit opcode has a 16-bit address argument int is_opcode32(int op) { return (op & 0xfe0e) == 0x940e || // call diff --git a/src/disasm.c b/src/disasm.c index e3a4ef7b..7c7ad5cc 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -152,7 +152,7 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm // Apply register formula int regword = 0; - switch(oc->type & OTY_RMASK) { + switch(oc->type & OTY_REG_MASK) { case OTY_REVN: // Even registers r0, r2, ..., r30 Rd *= 2, Rr *= 2; regword = 1; // movw @@ -175,6 +175,27 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm Ra = (Ra & 0xf) | ((Ra >> 1) & 0x30) | ((Ra & 0x10) << 2) | (((Ra & 0x10) ^ 0x10) << 3); } + int awd = cx->dis_addrwidth, swd = cx->dis_sramwidth; + snprintf(line->code, 256, "%-7s ", oc->opcode); + char *c = line->code + strlen(line->code); + *line->comment = 0; + + // Check for opcodes with undefined results + switch(oc->type & OTY_WARN_MASK) { + case OTY_XWRN: + if(Rd == 26 || Rd == 27 || Rr == 26 || Rr == 27) + add_comment(line, "Warning: the result of this operation is undefined\n"); + break; + case OTY_YWRN: + if(Rd == 28 || Rd == 29 || Rr == 28 || Rr == 29) + add_comment(line, "Warning: the result of this operation is undefined\n"); + break; + case OTY_ZWRN: + if(Rd == 30 || Rd == 31 || Rr == 30 || Rr == 31) + add_comment(line, "Warning: the result of this operation is undefined\n"); + break; + } + int target = 0, offset = 0, is_jumpcall = 0, is_relative = 0; int is_function = !!(oc->type & OTY_EXTERNAL); // call/rcall affects stack memory const char *kmemaddr = NULL, *memaddr, *regname; @@ -207,16 +228,8 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm Register_JumpCall(addr, target, mnemo, is_function); is_jumpcall = 1; break; - default: - pmsg_warning("OPCODE_%s has an unexpected number %d of k bits\n", - oc->idname, Nk); } - int awd = cx->dis_addrwidth, swd = cx->dis_sramwidth; - snprintf(line->code, 256, "%-7s ", oc->opcode); - char *c = line->code + strlen(line->code); - *line->comment = 0; - for(const char *o = oc->operands; *o && c-line->code < 255; o++) { switch(*o) { case 'R': @@ -370,8 +383,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { Pos += oplen; } else { - term_out(".word 0x%02x%02x ; Invalid opcode at 0x%04x\n", - buf[Pos + 1] & 0xff, buf[Pos] & 0xff, disasm_wrap(Pos + addr)); + term_out(".word 0x%02x%02x ; Invalid opcode\n", buf[Pos+1] & 0xff, buf[Pos] & 0xff); Pos += 2; } } diff --git a/src/libavrdude.h b/src/libavrdude.h index 5c4f0be2..6d12beb6 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1583,30 +1583,38 @@ typedef enum { #define PART_ALL (PART_AVR_XM|OP_AVR_L|OP_AVR_XL) // All but RC (the latter conflicts) // Opcode types -#define OTY_RMASK 7 // Register formula mask +#define OTY_REG_MASK 7 // Register formula mask #define OTY_RNONE 0 // No registers addressed in this opcode #define OTY_RALL 1 // Opcode can use all 32 registers (both Rd, Rr) #define OTY_REVN 2 // Opcode only uses even registers (Rd *= 2, Rr *= 2) #define OTY_RUPP 3 // Opcode only uses upper registers (Rd += 16, Rr += 16) #define OTY_RW24 4 // Opcode only uses r24, r26, r28, r30 (Rd = Rd *2 + 24) -#define OTY_EXTERNAL 0x010 // Opcode might r/w either I/O region or memory -#define OTY_ALBI 0x020 // Arithmetic, logic or bitwise operation -#define OTY_ALBX 0x030 // Arithmetic, logic or bitwise operation (external) -#define OTY_XFRI 0x040 // Data transfer (only affecting registers) -#define OTY_XFRX 0x050 // Data transfer (between external I/O or memory and regs) -#define OTY_JMPI 0x080 // Jump to potentially anywhere in flash (jmp, ijmp, eijmp) -#define OTY_JMPX 0x090 // Jump to potentially anywhere in flash (calls and ret/i) -#define OTY_RJMI 0x100 // Relative jump rjmp, range [-4094, 4096] bytes -#define OTY_RJMX 0x110 // Relative call rcall, range [-4094, 4096] bytes -#define OTY_BRAI 0x200 // Conditional branch, range [-126, 128] bytes -#define OTY_SKPI 0x400 // Conditional skip, range [0, 4] bytes (cpse, sbrc, sbrs) -#define OTY_SKPX 0x410 // Conditional skip, range [0, 4] bytes (sbic, sbis) -#define OTY_MCUI 0x800 // nop and wdr -#define OTY_MCUX 0x810 // sleep and break +#define OTY_EXTERNAL 0x008 // Opcode might r/w either I/O region or memory -#define OTY_ALIAS 0x1000 // Opcode is a strict alias for another one, eg, sbr == ori -#define OTY_CONSTRAINT 0x2000 // Opcode has constraints: Rr == Rd (tst, clr, lsl, rol) +#define OTY_TYPE_MASK 0x78 // OPCODE type mask +#define OTY_ITYPE_MASK 0x70 // OPCODE type mask matching OTY_xxxI types +#define OTY_MCUI 0x00 // nop and wdr +#define OTY_MCUX 0x08 // sleep and break +#define OTY_ALBI 0x10 // Arithmetic, logic or bitwise operation +#define OTY_ALBX 0x18 // Arithmetic, logic or bitwise operation (external) +#define OTY_XFRI 0x20 // Data transfer (only affecting registers) +#define OTY_XFRX 0x28 // Data transfer (between external I/O or memory and regs) +#define OTY_JMPI 0x30 // Jump to potentially anywhere in flash (jmp, ijmp, eijmp) +#define OTY_JMPX 0x38 // Jump to potentially anywhere in flash (calls and ret/i) +#define OTY_RJMI 0x40 // Relative jump rjmp, range [-4094, 4096] bytes +#define OTY_RJMX 0x48 // Relative call rcall, range [-4094, 4096] bytes +#define OTY_BRAI 0x50 // Conditional branch, range [-126, 128] bytes +#define OTY_SKPI 0x60 // Conditional skip, range [0, 4] bytes (cpse, sbrc, sbrs) +#define OTY_SKPX 0x68 // Conditional skip, range [0, 4] bytes (sbic, sbis) + +#define OTY_ALIAS 0x100 // Opcode is a strict alias for another one, eg, sbr == ori +#define OTY_CONSTRAINT 0x200 // Opcode has constraints: Rr == Rd (tst, clr, lsl, rol) + +#define OTY_WARN_MASK 0xc00 // OPCODE warning mask +#define OTY_XWRN 0x400 // Operand register must not be r27/r28 +#define OTY_YWRN 0x800 // Operand register must not be r29/r30 +#define OTY_ZWRN 0xc00 // Operand register must not be r29/r30 typedef struct { AVR_opcode mnemo; // Eg, OPCODE_add From 08ab9cba0ea280cbe2c9321bb4b1ae802ca470e7 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 14:44:08 +0100 Subject: [PATCH 337/422] assign OTY_JMPI to icall (no sram or I/O access) --- src/avr_opcodes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 4ef94fb9..7642bdee 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -193,7 +193,7 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(rcall), 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, "rcall", "k", "Relative Call Subroutine", "PC <-- PC + k + 1", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, - {OP_ID(icall), 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPX, + {OP_ID(icall), 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPI, "icall", "", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, ""}, {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, @@ -548,7 +548,7 @@ const AVR_opcode_data avr_opcodes[164] = { {OP_ID(u_nop_7), 0xfe0f, 0x920b, 1, OP_AVR_ILL, "1001 001x xxxx 1011", OTY_MCUI, "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPX, + {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPI, "u/icall", "", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, {OP_ID(u_eicall), 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, From 1eeaae5740491b54b76e6647e47afa4d8d145430 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 14:45:12 +0100 Subject: [PATCH 338/422] Warn if destination of jmp/call is outside flash --- src/disasm.c | 40 ++++++++++++++++++++-------------------- src/libavrdude.h | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 7c7ad5cc..48d7bc2a 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -37,8 +37,8 @@ // Wrap around flash int disasm_wrap(int addr) { - if(cx->dis_flashsz) - addr &= cx->dis_flashsz-1; + if(cx->dis_flashsz2) + addr &= cx->dis_flashsz2-1; return addr; } @@ -184,15 +184,15 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm switch(oc->type & OTY_WARN_MASK) { case OTY_XWRN: if(Rd == 26 || Rd == 27 || Rr == 26 || Rr == 27) - add_comment(line, "Warning: the result of this operation is undefined\n"); + add_comment(line, "Warning: the result of this operation is undefined"); break; case OTY_YWRN: if(Rd == 28 || Rd == 29 || Rr == 28 || Rr == 29) - add_comment(line, "Warning: the result of this operation is undefined\n"); + add_comment(line, "Warning: the result of this operation is undefined"); break; case OTY_ZWRN: if(Rd == 30 || Rd == 31 || Rr == 30 || Rr == 31) - add_comment(line, "Warning: the result of this operation is undefined\n"); + add_comment(line, "Warning: the result of this operation is undefined"); break; } @@ -223,7 +223,10 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm kmemaddr = Tagfile_Resolve_Mem_Address(Rk); break; case 22: - target = disasm_wrap(2*Rk); + if(cx->dis_flashsz && 2*Rk > cx->dis_flashsz) + add_comment(line, + str_ccprintf("Warning: destination outside flash [0, 0x%0*x]", awd, cx->dis_flashsz-1)); + target = 2*Rk; // disasm_wrap(2*Rk); if(pass == 1) Register_JumpCall(addr, target, mnemo, is_function); is_jumpcall = 1; @@ -368,22 +371,17 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { term_out(" "); } - if(line.code[0] == 0) { - // No code was generated? - term_out("; opcode %s not implemented\n", avr_opcodes[mnemo].idname); - } else { - if(!line.comment[0] || !cx->dis_opts.Show_Comments) { - term_out("%s\n", line.code); - } else { - term_out("%-23s ; %s\n", line.code, line.comment); - } - } - if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) // @@@ + if(!*line.comment || !cx->dis_opts.Show_Comments) + term_out("%s\n", line.code); + else + term_out("%-23s ; %s\n", line.code, line.comment); + if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) term_out("\n"); Pos += oplen; } else { - term_out(".word 0x%02x%02x ; Invalid opcode\n", buf[Pos+1] & 0xff, buf[Pos] & 0xff); + term_out("%-23s ; Invalid opcode\n", + str_ccprintf(".word 0x%02x%02x", buf[Pos+1] & 0xff, buf[Pos] & 0xff)); Pos += 2; } } @@ -401,13 +399,15 @@ int disasm_init(const AVRPART *p) { return -1; } - cx->dis_flashsz = 0; // Flash size rounded up to next power of two + cx->dis_flashsz = 0; // Flash size + cx->dis_flashsz2 = 0; // Flash size rounded up to next power of two cx->dis_addrwidth = 4; // Number of hex digits needed for flash addresses cx->dis_sramwidth = 3; // Number of hex digits needed for sram addresses if((mem = avr_locate_flash(p)) && mem->size > 1) { int nbits = intlog2(mem->size - 1) + 1; - cx->dis_flashsz = 1 << nbits; + cx->dis_flashsz = mem->size; + cx->dis_flashsz2 = 1 << nbits; cx->dis_addrwidth = (nbits+3)/4; } diff --git a/src/libavrdude.h b/src/libavrdude.h index 6d12beb6..b08cd0e4 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1840,7 +1840,7 @@ typedef struct { int reccount; // Static variables from disasm*.c - int dis_initopts, dis_flashsz, dis_addrwidth, dis_sramwidth, dis_cycle_index; + int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth, dis_cycle_index; Disasm_options dis_opts; int dis_JumpCallN, dis_CodeLabelN, dis_PGMLabelN, dis_MemLabelN, dis_IORegisterN; Disasm_JumpCall *dis_JumpCalls; From aebf970d0c4892ffa2f324b75bbf088c96ad9229 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 22 Jul 2024 17:31:07 +0200 Subject: [PATCH 339/422] Add -xautoreset option for the AVR109 programmer --- src/butterfly.c | 58 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/src/butterfly.c b/src/butterfly.c index 1337faec..a6d5fdc8 100644 --- a/src/butterfly.c +++ b/src/butterfly.c @@ -60,6 +60,7 @@ struct pdata int ctype; // Cache one byte for flash unsigned char cvalue; unsigned long caddr; + bool autoreset; }; #define PDATA(pgm) ((struct pdata *)(pgm->cookie)) @@ -361,9 +362,8 @@ static void butterfly_enable(PROGRAMMER *pgm, const AVRPART *p) { static int butterfly_open(PROGRAMMER *pgm, const char *port) { union pinfo pinfo; pgm->port = port; - /* - * If baudrate was not specified use 19200 Baud - */ + + // If baudrate was not specified use 19200 Baud if(pgm->baudrate == 0) { pgm->baudrate = 19200; } @@ -373,9 +373,22 @@ static int butterfly_open(PROGRAMMER *pgm, const char *port) { return -1; } - /* - * drain any extraneous input - */ + if(PDATA(pgm)->autoreset) { + // This code assumes a negative-logic USB to TTL serial adapter + // Set RTS/DTR high to discharge the series-capacitor, if present + imsg_notice2("Toggling the DTR/RTS lines to trigger a hardware reset\n"); + serial_set_dtr_rts(&pgm->fd, 0); + usleep(250 * 1000); + // Pull the RTS/DTR line low to reset AVR + serial_set_dtr_rts(&pgm->fd, 1); + // Max 100 us: charging a cap longer creates a high reset spike above Vcc + usleep(100); + // Set the RTS/DTR line back to high, so direct connection to reset works + serial_set_dtr_rts(&pgm->fd, 0); + usleep(100 * 1000); + } + + // Drain any extraneous input (void) butterfly_drain(pgm, 0); return 0; @@ -681,6 +694,37 @@ static int butterfly_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, con return 3; } +static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { + const char *extended_param; + int rv = 0; + + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); + + if(str_starts(extended_param, "autoreset")) { + if(!str_eq(extended_param, "autoreset")) { + pmsg_error("invalid -xautoreset value %s. Use -xautoreset\n", extended_param); + rv = -1; + break; + } + PDATA(pgm)->autoreset = true; + continue; + } + + if (str_eq(extended_param, "help")) { + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xautoreset Toggle RTS/DTR lines on port open to issue a hardware reset\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + exit(0); + } + + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; + } + + return rv; +} + const char butterfly_desc[] = "Atmel Butterfly evaluation board; Atmel AppNotes AVR109, AVR911"; void butterfly_initpgm(PROGRAMMER *pgm) { @@ -714,7 +758,7 @@ void butterfly_initpgm(PROGRAMMER *pgm) { pgm->paged_load = butterfly_paged_load; pgm->read_sig_bytes = butterfly_read_sig_bytes; - + pgm->parseextparams = butterfly_parseextparms; pgm->setup = butterfly_setup; pgm->teardown = butterfly_teardown; pgm->flag = 0; From 1721a7725953943bd86ac48a69820c84c5552462 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 16:33:00 +0100 Subject: [PATCH 340/422] Rename Type variables/component for self-documentation --- src/disasm_jumpcall.c | 16 ++++++------ src/disasm_private.h | 2 +- src/disasm_tagfile.c | 59 ++++++++++++++++++++----------------------- src/libavrdude.h | 4 +-- 4 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index 113929e0..c22ab085 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -75,24 +75,24 @@ static int JC_Comparison(const void *Element1, const void *Element2) { return -1; } -static void Correct_Label_Types(void) { +static void Correct_Label_IsFunct(void) { int i, j; int LastIdx = 0; int LastDest = cx->dis_JumpCalls[0].To; - char CurType = cx->dis_JumpCalls[0].FunctionCall; + char CurIsFunct = cx->dis_JumpCalls[0].FunctionCall; for(i = 1; i < cx->dis_JumpCallN; i++) { if(cx->dis_JumpCalls[i].To != LastDest) { for(j = LastIdx; j < i; j++) - cx->dis_JumpCalls[j].FunctionCall = CurType; + cx->dis_JumpCalls[j].FunctionCall = CurIsFunct; LastIdx = i; LastDest = cx->dis_JumpCalls[i].To; - CurType = 0; + CurIsFunct = 0; } - CurType = CurType || cx->dis_JumpCalls[i].FunctionCall; + CurIsFunct = CurIsFunct || cx->dis_JumpCalls[i].FunctionCall; } for(j = LastIdx; j < cx->dis_JumpCallN; j++) - cx->dis_JumpCalls[j].FunctionCall = CurType; + cx->dis_JumpCalls[j].FunctionCall = CurIsFunct; } void Enumerate_Labels(void) { @@ -105,7 +105,7 @@ void Enumerate_Labels(void) { return; qsort(cx->dis_JumpCalls, cx->dis_JumpCallN, sizeof(Disasm_JumpCall), JC_Comparison); - Correct_Label_Types(); + Correct_Label_IsFunct(); Destination = cx->dis_JumpCalls[0].To; if(cx->dis_JumpCalls[0].FunctionCall) @@ -165,7 +165,7 @@ void Print_JumpCalls(int Position) { if(LabelComment == NULL) { term_out("%s:\n", LabelName); } else { - term_out("%s: ; %s\n", LabelName, LabelComment); + term_out("%-23s ; %s\n", str_ccprintf("%s:", LabelName), LabelComment); } } } diff --git a/src/disasm_private.h b/src/disasm_private.h index 3df3de50..8dcaecc3 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -42,7 +42,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); const char *Resolve_IO_Register(int Number); void Emit_Used_IO_Registers(); -void Register_JumpCall(int From, int To, int Type, unsigned char FunctionCall); +void Register_JumpCall(int From, int To, int mnemo, unsigned char FunctionCall); void Enumerate_Labels(); const char *Get_Label_Name(int Destination, char **LabelComment); void Print_JumpCalls(int Position); diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index 02e08fd6..3e3e9f66 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -85,7 +85,7 @@ static void zap_MemLabels() { } -static void Add_LabelTag(int Address, const char *LabelText, const char *LabelComment) { +static void Add_Code_Tag(int Address, const char *LabelText, const char *LabelComment) { cx->dis_CodeLabelN++; cx->dis_CodeLabels = (Disasm_CodeLabel *) mmt_realloc(cx->dis_CodeLabels, sizeof(Disasm_CodeLabel) * cx->dis_CodeLabelN); @@ -94,28 +94,28 @@ static void Add_LabelTag(int Address, const char *LabelText, const char *LabelCo cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].Comment = LabelComment? mmt_strdup(LabelComment): NULL; } -static void Add_PGM_Tag(int Address, char Type, unsigned int Count, const char *Comment) { +static void Add_PGM_Tag(int Address, char subtype, unsigned int Count, const char *Comment) { cx->dis_PGMLabelN++; cx->dis_PGMLabels = (Disasm_PGMLabel *) mmt_realloc(cx->dis_PGMLabels, sizeof(Disasm_PGMLabel) * cx->dis_PGMLabelN); cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Address = Address; - cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Type = Type; + cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].subtype = subtype; cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Count = Count; cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Comment = Comment? mmt_strdup(Comment): NULL; } -static void Add_Mem_Tag(int Address, char Type, unsigned int Count, const char *Comment) { +static void Add_Mem_Tag(int Address, char subtype, unsigned int Count, const char *Comment) { cx->dis_MemLabelN++; cx->dis_MemLabels = (Disasm_MemLabel *) mmt_realloc(cx->dis_MemLabels, sizeof(Disasm_MemLabel) * cx->dis_MemLabelN); cx->dis_MemLabels[cx->dis_MemLabelN - 1].Address = Address; - cx->dis_MemLabels[cx->dis_MemLabelN - 1].Type = Type; + cx->dis_MemLabels[cx->dis_MemLabelN - 1].subtype = subtype; cx->dis_MemLabels[cx->dis_MemLabelN - 1].Count = Count; cx->dis_MemLabels[cx->dis_MemLabelN - 1].Comment = Comment? mmt_strdup(Comment): NULL; } static int Tagfile_Readline(char *Line, int LineNo) { - char *Token, Type, Subtype; + char *Token, Type, Subtype, *Name; int Address, Count; const char *errptr; @@ -125,9 +125,6 @@ static int Tagfile_Readline(char *Line, int LineNo) { Token = strtok(Line, " \t\n"); if(LineError(Token, "nonempty line", LineNo)) return -1; - - - // Token now holds an address, determine if hex or dec Address = str_int(Token, STR_INT32, &errptr); if(errptr) { pmsg_error("address %s: %s\n", Token, errptr); @@ -138,25 +135,27 @@ static int Tagfile_Readline(char *Line, int LineNo) { if(LineError(Token, "no second argument", LineNo)) return -1; if(strlen(Token) != 1) { - LineError(NULL, "second argument too long", LineNo); + LineError(NULL, "second argument should be a type (L, P or M)", LineNo); return -1; } - Type = Token[0]; + Token = strtok(NULL, " \t\n"); if(LineError(Token, "no third argument", LineNo)) return -1; if(Type == 'L') { - char *LabelName = Token; - - Token = strtok(NULL, " \t\n"); - Add_LabelTag(Address, LabelName, Token); + Name = Token; // Name, comment is optional + Add_Code_Tag(Address, Name, strtok(NULL, "\t\n")); return 0; } if(LineError(Token, "no fourth argument", LineNo)) return -1; + if(strlen(Token) != 1) { + LineError(NULL, "fourth argument should be a subtype (B, W, A or S)", LineNo); + return -1; + } Subtype = Token[0]; // Either B(yte), W(ord), A(utoterminated string) or S(tring) @@ -174,12 +173,10 @@ static int Tagfile_Readline(char *Line, int LineNo) { Subtype = TYPE_STRING; break; default: - Subtype = 0; - } - if(!Subtype) { - LineError(NULL, "invalid type (expected one of L, B, W, A or S)", LineNo); + LineError(NULL, "invalid subtype (expected one of B, W, A or S)", LineNo); return -1; } + if((Type == 'M') && ((Subtype != TYPE_BYTE) && (Subtype != TYPE_WORD))) { LineError(NULL, "memory labels can only be of type B or W", LineNo); return -1; @@ -191,17 +188,16 @@ static int Tagfile_Readline(char *Line, int LineNo) { pmsg_error("count %s: %s\n", Token, errptr); return -1; } - if(Count < 1) { - LineError(NULL, "invalid count given", LineNo); + LineError(NULL, str_ccprintf("invalid count %d given", Count), LineNo); return -1; } - Token = strtok(NULL, " \t\n"); + Name = strtok(NULL, " \t\n"); if(Type == 'P') { - Add_PGM_Tag(Address, Subtype, Count, Token); + Add_PGM_Tag(Address, Subtype, Count, Name); } else if(Type == 'M') { - Add_Mem_Tag(Address, Subtype, Count, Token); + Add_Mem_Tag(Address, Subtype, Count, Name); } else { pmsg_error("invalid tag type %c\n", Type); return -1; @@ -318,7 +314,7 @@ int Tagfile_FindPGMAddress(int Address) { const char *Tagfile_Resolve_Mem_Address(int Address) { for(int i = 0; i < cx->dis_MemLabelN && cx->dis_MemLabels[i].Address <= Address; i++) { int Start = cx->dis_MemLabels[i].Address; - int Size = cx->dis_MemLabels[i].Type == TYPE_WORD? 2: 1; + int Size = cx->dis_MemLabels[i].subtype == TYPE_WORD? 2: 1; int End = cx->dis_MemLabels[i].Address + cx->dis_MemLabels[i].Count * Size - 1; if(Address >= Start && Address <= End) { @@ -400,7 +396,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { if(Index == -1) return 0; - switch (cx->dis_PGMLabels[Index].Type) { + switch (cx->dis_PGMLabels[Index].subtype) { case TYPE_BYTE: ProcessingFunction = Tagfile_Process_Byte; break; @@ -416,7 +412,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { } term_out("; Inline PGM data: %d ", cx->dis_PGMLabels[Index].Count); - switch (cx->dis_PGMLabels[Index].Type) { + switch (cx->dis_PGMLabels[Index].subtype) { case TYPE_BYTE: term_out("byte"); break; @@ -434,12 +430,11 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { term_out("s"); term_out(" starting at 0x%0*x", cx->dis_addrwidth, disasm_wrap(Position + offset)); - if(cx->dis_PGMLabels[Index].Comment != NULL) { + if(cx->dis_PGMLabels[Index].Comment) term_out(" (%s)", cx->dis_PGMLabels[Index].Comment); - } term_out("\n"); - if((cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].Type == TYPE_STRING)) { + if((cx->dis_PGMLabels[Index].subtype == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].subtype == TYPE_STRING)) { if(cx->dis_PGMLabels[Index].Comment != NULL) { snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_PGMLabels[Index].Comment); Sanitize_String(Buffer); @@ -452,7 +447,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { for(unsigned i = 0; i < cx->dis_PGMLabels[Index].Count; i++) BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, offset, i, Buffer); - if(cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) { + if(cx->dis_PGMLabels[Index].subtype == TYPE_ASTRING) { // Autoaligned string if((BytesAdvanced % 2) != 0) { // Not yet aligned correctly @@ -504,7 +499,7 @@ void disasm_init_regfile(const AVRPART *p) { nio = 0; for(int i = 0; i< nr; i++) { cx->dis_MemLabels[i].Address = offset + rf[i].addr; - cx->dis_MemLabels[i].Type = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; + cx->dis_MemLabels[i].subtype = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; cx->dis_MemLabels[i].Count = rf[i].size > 2? rf[i].size: 1; cx->dis_MemLabels[i].Comment = regname(rf[i].reg, -1); diff --git a/src/libavrdude.h b/src/libavrdude.h index b08cd0e4..c854c7bb 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1481,14 +1481,14 @@ typedef struct { typedef struct { int Address; - char Type; + int subtype; unsigned int Count; char *Comment; } Disasm_PGMLabel; typedef struct { int Address; - char Type; + int subtype; unsigned int Count; char *Comment; } Disasm_MemLabel; From 4d9ee7aa0f8ca2b4f2968c06ffa2a6778aca4a08 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 17:08:41 +0100 Subject: [PATCH 341/422] Rename Type/Comment/Name components for clarity --- src/disasm.c | 2 +- src/disasm_private.h | 6 +-- src/disasm_tagfile.c | 122 +++++++++++++++++++++---------------------- src/libavrdude.h | 29 ++++++---- 4 files changed, 84 insertions(+), 75 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 48d7bc2a..6d59f20e 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -317,7 +317,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { Pos = 0; for(int i = 0; i < cx->dis_IORegisterN; i++) - cx->dis_IORegisters[i].Used = 0; + cx->dis_IORegisters[i].used = 0; if(cx->dis_opts.Process_Labels || cx->dis_opts.avrgcc_style) { // Preprocess to gather jump labels or to gain knowledge about registers which are being used diff --git a/src/disasm_private.h b/src/disasm_private.h index 8dcaecc3..36c27113 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -33,11 +33,11 @@ void disasm_init_regfile(const AVRPART *p); int disasm_wrap(int addr); -int Tagfile_FindLabelAddress(int Address); +int Tagfile_FindLabelAddress(int address); char *Tagfile_GetLabel(int TagIndex); char *Tagfile_GetLabelComment(int TagIndex); -int Tagfile_FindPGMAddress(int Address); -const char *Tagfile_Resolve_Mem_Address(int Address); +int Tagfile_FindPGMAddress(int address); +const char *Tagfile_Resolve_Mem_Address(int address); int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); const char *Resolve_IO_Register(int Number); void Emit_Used_IO_Registers(); diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index 3e3e9f66..ac9027cf 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -45,7 +45,7 @@ static int LineError(const char *Token, const char *Message, int LineNo) { static void zap_IORegisters() { if(cx->dis_IORegisters) { for(int i = 0; i < cx->dis_IORegisterN; i++) - mmt_free(cx->dis_IORegisters[i].Name); + mmt_free(cx->dis_IORegisters[i].name); mmt_free(cx->dis_IORegisters); cx->dis_IORegisters = NULL; } @@ -55,8 +55,8 @@ static void zap_IORegisters() { static void zap_CodeLabels() { if(cx->dis_CodeLabels) { for(int i = 0; i < cx->dis_CodeLabelN; i++) { - mmt_free(cx->dis_CodeLabels[i].Comment); - mmt_free(cx->dis_CodeLabels[i].Text); + mmt_free(cx->dis_CodeLabels[i].comment); + mmt_free(cx->dis_CodeLabels[i].name); } mmt_free(cx->dis_CodeLabels); cx->dis_CodeLabels = NULL; @@ -67,7 +67,7 @@ static void zap_CodeLabels() { static void zap_PGMLabels() { if(cx->dis_PGMLabels) { for(int i = 0; i < cx->dis_PGMLabelN; i++) - mmt_free(cx->dis_PGMLabels[i].Comment); + mmt_free(cx->dis_PGMLabels[i].name); mmt_free(cx->dis_PGMLabels); cx->dis_PGMLabels = NULL; } @@ -77,7 +77,7 @@ static void zap_PGMLabels() { static void zap_MemLabels() { if(cx->dis_MemLabels) { for(int i = 0; i < cx->dis_MemLabelN; i++) - mmt_free(cx->dis_MemLabels[i].Comment); + mmt_free(cx->dis_MemLabels[i].name); mmt_free(cx->dis_MemLabels); cx->dis_MemLabels = NULL; } @@ -85,38 +85,38 @@ static void zap_MemLabels() { } -static void Add_Code_Tag(int Address, const char *LabelText, const char *LabelComment) { +static void Add_Code_Tag(int address, const char *name, const char *comment) { cx->dis_CodeLabelN++; cx->dis_CodeLabels = (Disasm_CodeLabel *) mmt_realloc(cx->dis_CodeLabels, sizeof(Disasm_CodeLabel) * cx->dis_CodeLabelN); - cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].Address = Address; - cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].Text = LabelText? mmt_strdup(LabelText): NULL; - cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].Comment = LabelComment? mmt_strdup(LabelComment): NULL; + cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].address = address; + cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].name = name? mmt_strdup(name): NULL; + cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].comment = comment? mmt_strdup(comment): NULL; } -static void Add_PGM_Tag(int Address, char subtype, unsigned int Count, const char *Comment) { +static void Add_PGM_Tag(int address, char subtype, unsigned int Count, const char *name) { cx->dis_PGMLabelN++; cx->dis_PGMLabels = (Disasm_PGMLabel *) mmt_realloc(cx->dis_PGMLabels, sizeof(Disasm_PGMLabel) * cx->dis_PGMLabelN); - cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Address = Address; + cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].address = address; cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].subtype = subtype; cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Count = Count; - cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Comment = Comment? mmt_strdup(Comment): NULL; + cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].name = name? mmt_strdup(name): NULL; } -static void Add_Mem_Tag(int Address, char subtype, unsigned int Count, const char *Comment) { +static void Add_Mem_Tag(int address, char subtype, unsigned int Count, const char *name) { cx->dis_MemLabelN++; cx->dis_MemLabels = (Disasm_MemLabel *) mmt_realloc(cx->dis_MemLabels, sizeof(Disasm_MemLabel) * cx->dis_MemLabelN); - cx->dis_MemLabels[cx->dis_MemLabelN - 1].Address = Address; + cx->dis_MemLabels[cx->dis_MemLabelN - 1].address = address; cx->dis_MemLabels[cx->dis_MemLabelN - 1].subtype = subtype; cx->dis_MemLabels[cx->dis_MemLabelN - 1].Count = Count; - cx->dis_MemLabels[cx->dis_MemLabelN - 1].Comment = Comment? mmt_strdup(Comment): NULL; + cx->dis_MemLabels[cx->dis_MemLabelN - 1].name = name? mmt_strdup(name): NULL; } static int Tagfile_Readline(char *Line, int LineNo) { char *Token, Type, Subtype, *Name; - int Address, Count; + int address, Count; const char *errptr; if(Line[0] == '#' || strlen(Line) <= 1) @@ -125,7 +125,7 @@ static int Tagfile_Readline(char *Line, int LineNo) { Token = strtok(Line, " \t\n"); if(LineError(Token, "nonempty line", LineNo)) return -1; - Address = str_int(Token, STR_INT32, &errptr); + address = str_int(Token, STR_INT32, &errptr); if(errptr) { pmsg_error("address %s: %s\n", Token, errptr); return -1; @@ -146,7 +146,7 @@ static int Tagfile_Readline(char *Line, int LineNo) { if(Type == 'L') { Name = Token; // Name, comment is optional - Add_Code_Tag(Address, Name, strtok(NULL, "\t\n")); + Add_Code_Tag(address, Name, strtok(NULL, "\t\n")); return 0; } @@ -195,9 +195,9 @@ static int Tagfile_Readline(char *Line, int LineNo) { Name = strtok(NULL, " \t\n"); if(Type == 'P') { - Add_PGM_Tag(Address, Subtype, Count, Name); + Add_PGM_Tag(address, Subtype, Count, Name); } else if(Type == 'M') { - Add_Mem_Tag(Address, Subtype, Count, Name); + Add_Mem_Tag(address, Subtype, Count, Name); } else { pmsg_error("invalid tag type %c\n", Type); return -1; @@ -211,9 +211,9 @@ static int CodeLabelSort(const void *A, const void *B) { X = (const Disasm_CodeLabel *) A; Y = (const Disasm_CodeLabel *) B; - if(X->Address == Y->Address) + if(X->address == Y->address) return 0; - if(X->Address < Y->Address) + if(X->address < Y->address) return -1; return 1; } @@ -223,9 +223,9 @@ static int PGMLabelSort(const void *A, const void *B) { X = (const Disasm_PGMLabel *) A; Y = (const Disasm_PGMLabel *) B; - if(X->Address == Y->Address) + if(X->address == Y->address) return 0; - if(X->Address < Y->Address) + if(X->address < Y->address) return -1; return 1; } @@ -235,9 +235,9 @@ static int MemLabelSort(const void *A, const void *B) { X = (const Disasm_MemLabel *) A; Y = (const Disasm_MemLabel *) B; - if(X->Address == Y->Address) + if(X->address == Y->address) return 0; - if(X->Address < Y->Address) + if(X->address < Y->address) return -1; return 1; } @@ -281,11 +281,11 @@ error: return -1; } -int Tagfile_FindLabelAddress(int Address) { +int Tagfile_FindLabelAddress(int address) { Disasm_CodeLabel Goal; Disasm_CodeLabel *Result; - Goal.Address = Address; + Goal.address = address; Result = bsearch(&Goal, cx->dis_CodeLabels, cx->dis_CodeLabelN, sizeof(Disasm_CodeLabel), CodeLabelSort); if(Result == NULL) return -1; @@ -293,41 +293,41 @@ int Tagfile_FindLabelAddress(int Address) { } char *Tagfile_GetLabel(int TagIndex) { - return cx->dis_CodeLabels[TagIndex].Text; + return cx->dis_CodeLabels[TagIndex].name; } char *Tagfile_GetLabelComment(int TagIndex) { - return cx->dis_CodeLabels[TagIndex].Comment; + return cx->dis_CodeLabels[TagIndex].comment; } -int Tagfile_FindPGMAddress(int Address) { +int Tagfile_FindPGMAddress(int address) { Disasm_PGMLabel Goal; Disasm_PGMLabel *Result; - Goal.Address = Address; + Goal.address = address; Result = bsearch(&Goal, cx->dis_PGMLabels, cx->dis_PGMLabelN, sizeof(Disasm_PGMLabel), PGMLabelSort); if(Result == NULL) return -1; return Result - cx->dis_PGMLabels; } -const char *Tagfile_Resolve_Mem_Address(int Address) { - for(int i = 0; i < cx->dis_MemLabelN && cx->dis_MemLabels[i].Address <= Address; i++) { - int Start = cx->dis_MemLabels[i].Address; +const char *Tagfile_Resolve_Mem_Address(int address) { + for(int i = 0; i < cx->dis_MemLabelN && cx->dis_MemLabels[i].address <= address; i++) { + int Start = cx->dis_MemLabels[i].address; int Size = cx->dis_MemLabels[i].subtype == TYPE_WORD? 2: 1; - int End = cx->dis_MemLabels[i].Address + cx->dis_MemLabels[i].Count * Size - 1; + int End = cx->dis_MemLabels[i].address + cx->dis_MemLabels[i].Count * Size - 1; - if(Address >= Start && Address <= End) { + if(address >= Start && address <= End) { if(cx->dis_MemLabels[i].Count == 1) { // Single variable if(Size == 1) - return str_ccprintf("%s", cx->dis_MemLabels[i].Comment); - return str_ccprintf("_%s8(%s)", Address == Start? "lo": "hi", cx->dis_MemLabels[i].Comment); + return str_ccprintf("%s", cx->dis_MemLabels[i].name); + return str_ccprintf("_%s8(%s)", address == Start? "lo": "hi", cx->dis_MemLabels[i].name); } // Array if(Size == 1) - return str_ccprintf("%s[%d]", cx->dis_MemLabels[i].Comment, Address - Start); - return str_ccprintf("_%s8(%s[%d])", (Address-Start)%2? "hi": "lo", cx->dis_MemLabels[i].Comment, - (Address - Start)/2); + return str_ccprintf("%s[%d]", cx->dis_MemLabels[i].name, address - Start); + return str_ccprintf("_%s8(%s[%d])", (address-Start)%2? "hi": "lo", cx->dis_MemLabels[i].name, + (address - Start)/2); } } @@ -430,13 +430,13 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { term_out("s"); term_out(" starting at 0x%0*x", cx->dis_addrwidth, disasm_wrap(Position + offset)); - if(cx->dis_PGMLabels[Index].Comment) - term_out(" (%s)", cx->dis_PGMLabels[Index].Comment); + if(cx->dis_PGMLabels[Index].name) + term_out(" (%s)", cx->dis_PGMLabels[Index].name); term_out("\n"); if((cx->dis_PGMLabels[Index].subtype == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].subtype == TYPE_STRING)) { - if(cx->dis_PGMLabels[Index].Comment != NULL) { - snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_PGMLabels[Index].Comment); + if(cx->dis_PGMLabels[Index].name != NULL) { + snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_PGMLabels[Index].name); Sanitize_String(Buffer); } else { snprintf(Buffer, sizeof(Buffer), "%x", disasm_wrap(Position + offset)); @@ -498,27 +498,27 @@ void disasm_init_regfile(const AVRPART *p) { offset = mem->offset; nio = 0; for(int i = 0; i< nr; i++) { - cx->dis_MemLabels[i].Address = offset + rf[i].addr; + cx->dis_MemLabels[i].address = offset + rf[i].addr; cx->dis_MemLabels[i].subtype = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; cx->dis_MemLabels[i].Count = rf[i].size > 2? rf[i].size: 1; - cx->dis_MemLabels[i].Comment = regname(rf[i].reg, -1); + cx->dis_MemLabels[i].name = regname(rf[i].reg, -1); if(rf[i].addr < 0x40) { if(rf[i].size == 1) { - cx->dis_IORegisters[nio].Name = regname(rf[i].reg, -1); - cx->dis_IORegisters[nio].Address = rf[i].addr; + cx->dis_IORegisters[nio].name = regname(rf[i].reg, -1); + cx->dis_IORegisters[nio].address = rf[i].addr; nio++; } else if(rf[i].size == 2) { - cx->dis_IORegisters[nio].Name = regname(rf[i].reg, 'l'); - cx->dis_IORegisters[nio].Address = rf[i].addr; + cx->dis_IORegisters[nio].name = regname(rf[i].reg, 'l'); + cx->dis_IORegisters[nio].address = rf[i].addr; nio++; - cx->dis_IORegisters[nio].Name = regname(rf[i].reg, 'h'); - cx->dis_IORegisters[nio].Address = rf[i].addr+1; + cx->dis_IORegisters[nio].name = regname(rf[i].reg, 'h'); + cx->dis_IORegisters[nio].address = rf[i].addr+1; nio++; } else if(rf[i].size > 2) { for(int k = 0; k < rf[i].size; k++) { - cx->dis_IORegisters[nio].Name = regname(rf[i].reg, k); - cx->dis_IORegisters[nio].Address = rf[i].addr + k; + cx->dis_IORegisters[nio].name = regname(rf[i].reg, k); + cx->dis_IORegisters[nio].address = rf[i].addr + k; nio++; } } @@ -532,9 +532,9 @@ void disasm_init_regfile(const AVRPART *p) { const char *Resolve_IO_Register(int Number) { for(int i = 0; i < cx->dis_IORegisterN; i++) { - if(cx->dis_IORegisters[i].Address == Number) { - cx->dis_IORegisters[i].Used = 1; - return cx->dis_IORegisters[i].Name; + if(cx->dis_IORegisters[i].address == Number) { + cx->dis_IORegisters[i].used = 1; + return cx->dis_IORegisters[i].name; } } @@ -543,6 +543,6 @@ const char *Resolve_IO_Register(int Number) { void Emit_Used_IO_Registers() { for(int i = 0; i < cx->dis_IORegisterN; i++) - if(cx->dis_IORegisters[i].Used) - term_out(".equ %s, 0x%02x\n", cx->dis_IORegisters[i].Name, cx->dis_IORegisters[i].Address); + if(cx->dis_IORegisters[i].used) + term_out(".equ %s, 0x%02x\n", cx->dis_IORegisters[i].name, cx->dis_IORegisters[i].address); } diff --git a/src/libavrdude.h b/src/libavrdude.h index c854c7bb..c9ea9fd9 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1474,31 +1474,40 @@ typedef struct { } Disasm_JumpCall; typedef struct { - int Address; - char *Text; - char *Comment; + int address; + char *name; + char *comment; } Disasm_CodeLabel; typedef struct { - int Address; + int address; int subtype; unsigned int Count; - char *Comment; + char *name; } Disasm_PGMLabel; typedef struct { - int Address; + int address; int subtype; unsigned int Count; - char *Comment; + char *name; } Disasm_MemLabel; typedef struct { - int Address; - char *Name; - unsigned char Used; + int address; + char *name; + unsigned char used; } Disasm_IO_Register; +typedef struct { + char *name, *comment; + int address; + int type; // I: I/O vars, M: mem vars, L: labels, P: PGM vars + int subtype; // B: byte, W: word, A: autoterminated string, S: string + int count; // array length for tag file variables + int used; // Whether used by disassembly process +} Disasm_symbol; + // Order of enums must align with avr_opcodes[] table order typedef enum { OPCODE_NONE = -1, From 5e4a9a7616cddba9167b61206349b110e46e070a Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 22 Jul 2024 19:27:22 +0200 Subject: [PATCH 342/422] Add -xno_autoreset for the -c arduino programmer --- src/arduino.c | 84 ++++++++++++++++++++++++++++++++++++++------------- src/stk500.c | 2 +- src/stk500.h | 3 ++ 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index 70072da7..73a0bd70 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -37,6 +37,45 @@ #include "stk500.h" #include "arduino.h" +static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { + const char *extended_param; + int attempts; + int rv = 0; + + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); + + if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) { + PDATA(pgm)->retry_attempts = attempts; + pmsg_info("setting number of retry attempts to %d\n", attempts); + continue; + } + + if(str_starts(extended_param, "no_autoreset")) { + if(!str_eq(extended_param, "no_autoreset")) { + pmsg_error("invalid -xno_autoreset value %s. Use -xno_autoreset\n", extended_param); + rv = -1; + break; + } + PDATA(pgm)->autoreset = false; + continue; + } + + if (str_eq(extended_param, "help")) { + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xattempts= Specify no. connection retry attempts\n"); + msg_error(" -xno_autoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return LIBAVRDUDE_EXIT; + } + + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; + } + + return rv; +} + /* read signature bytes - arduino version */ static int arduino_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m) { unsigned char buf[32]; @@ -85,28 +124,28 @@ static int arduino_open(PROGRAMMER *pgm, const char *port) { return -1; } - // This code assumes a negative-logic USB to TTL serial adapter - // Set RTS/DTR high to discharge the series-capacitor, if present - serial_set_dtr_rts(&pgm->fd, 0); - /* - * Long wait needed for optiboot: otherwise the second of two bootloader - * calls in quick succession fails: - * - * avrdude -c arduino -qqp m328p -U x.hex; avrdude -c arduino -qqp m328p -U x.hex - */ - usleep(250 * 1000); - // Pull the RTS/DTR line low to reset AVR - serial_set_dtr_rts(&pgm->fd, 1); - // Max 100 us: charging a cap longer creates a high reset spike above Vcc - usleep(100); - // Set the RTS/DTR line back to high, so direct connection to reset works - serial_set_dtr_rts(&pgm->fd, 0); + if(PDATA(pgm)->autoreset) { + // This code assumes a negative-logic USB to TTL serial adapter + // Set RTS/DTR high to discharge the series-capacitor, if present + serial_set_dtr_rts(&pgm->fd, 0); + /* + * Long wait needed for optiboot: otherwise the second of two bootloader + * calls in quick succession fails: + * + * avrdude -c arduino -qqp m328p -U x.hex; avrdude -c arduino -qqp m328p -U x.hex + */ + usleep(250 * 1000); + // Pull the RTS/DTR line low to reset AVR + serial_set_dtr_rts(&pgm->fd, 1); + // Max 100 us: charging a cap longer creates a high reset spike above Vcc + usleep(100); + // Set the RTS/DTR line back to high, so direct connection to reset works + serial_set_dtr_rts(&pgm->fd, 0); - usleep(100 * 1000); + usleep(100 * 1000); + } - /* - * drain any extraneous input - */ + // Drain any extraneous input stk500_drain(pgm, 0); if (stk500_getsync(pgm) < 0) @@ -115,7 +154,7 @@ static int arduino_open(PROGRAMMER *pgm, const char *port) { return 0; } -static void arduino_close(PROGRAMMER * pgm) +static void arduino_close(PROGRAMMER *pgm) { serial_close(&pgm->fd); pgm->fd.ifd = -1; @@ -131,9 +170,12 @@ void arduino_initpgm(PROGRAMMER *pgm) { stk500_initpgm(pgm); strcpy(pgm->type, "Arduino"); + PDATA(&pgm)->autoreset = true; // Auto-reset enabled by default + pgm->read_sig_bytes = arduino_read_sig_bytes; pgm->open = arduino_open; pgm->close = arduino_close; + pgm->parseextparams = arduino_parseextparms; cx->avr_disableffopt = 1; // Disable trailing 0xff removal } diff --git a/src/stk500.c b/src/stk500.c index d3a4b0b6..a7c5657e 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -116,7 +116,7 @@ int stk500_getsync(const PROGRAMMER *pgm) { for (attempt = 0; attempt < max_sync_attempts; attempt++) { // Restart Arduino bootloader for every sync attempt - if (str_eq(pgm->type, "Arduino") && attempt > 0) { + if (PDATA(pgm)->autoreset && attempt > 0) { // This code assumes a negative-logic USB to TTL serial adapter // Pull the RTS/DTR line low to reset AVR: it is still high from open()/last attempt serial_set_dtr_rts(&pgm->fd, 1); diff --git a/src/stk500.h b/src/stk500.h index 6c9b8188..50984a51 100644 --- a/src/stk500.h +++ b/src/stk500.h @@ -60,6 +60,9 @@ struct pdata { double fosc_data; unsigned xtal; // Set STK500 XTAL frequency + + // Flag to enable/disable autoreset for the arduino programmer + bool autoreset; }; #define PDATA(pgm) ((struct pdata *)(pgm->cookie)) From 20cb01d4c8dbf30b558a7bdba8742f2c79eff1d4 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 19:40:36 +0100 Subject: [PATCH 343/422] Consolidate CodeLabel, PGMLabel, MemLabel and IO_Register into one symbols struct --- src/disasm.c | 98 +++++----- src/disasm_jumpcall.c | 18 +- src/disasm_private.h | 6 +- src/disasm_tagfile.c | 426 ++++++++++++++++-------------------------- src/libavrdude.h | 27 +-- 5 files changed, 214 insertions(+), 361 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 6d59f20e..c76ecc77 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -21,7 +21,6 @@ /* $Id$ */ - #include #include #include @@ -98,9 +97,14 @@ static unsigned bitcount(unsigned n) { } void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm_line *line, int pass) { - const AVR_opcode_data *oc = avr_opcodes+mnemo; memset(line, 0, sizeof*line); + if(mnemo < 0) { + add_comment(line, "Invalid opcode"); + snprintf(line->code, 256, ".word 0x%02x%02x", buf[1] & 0xff, buf[0] & 0xff); + return; + } + const AVR_opcode_data *oc = avr_opcodes+mnemo; int regs[128] = {0}, bits[128] = {0}; unsigned bmask = 0x8000; for(const char *p = oc->bits; *p && bmask; p++) { @@ -178,7 +182,6 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm int awd = cx->dis_addrwidth, swd = cx->dis_sramwidth; snprintf(line->code, 256, "%-7s ", oc->opcode); char *c = line->code + strlen(line->code); - *line->comment = 0; // Check for opcodes with undefined results switch(oc->type & OTY_WARN_MASK) { @@ -309,81 +312,66 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm * After the location buf+readlen there are leadout bytes available (0 -4) */ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { - int Pos; - int opcode, mnemo, oplen; - int i; + int pos, opcode, mnemo, oplen; Disasm_line line; + int awd = cx->dis_addrwidth; - Pos = 0; - - for(int i = 0; i < cx->dis_IORegisterN; i++) - cx->dis_IORegisters[i].used = 0; + pos = 0; + for(int i = 0; i < cx->dis_symbolN; i++) + if(cx->dis_symbols[i].type == 'I') + cx->dis_symbols[i].used = 0; if(cx->dis_opts.Process_Labels || cx->dis_opts.avrgcc_style) { // Preprocess to gather jump labels or to gain knowledge about registers which are being used - while(Pos < buflen) { - opcode = (buf[Pos] & 0xff) | (buf[Pos+1] & 0xff)<<8; + while(pos < buflen) { + opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); - oplen = 2*avr_opcodes[mnemo].nwords; - if(mnemo == -1) { - Pos += 2; - } else { - disassemble(buf + Pos, disasm_wrap(Pos + addr), opcode, mnemo, &line, 1); - Pos += oplen; - } + disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line, 1); + pos += mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords; } Enumerate_Labels(); - Pos = 0; + pos = 0; } if(cx->dis_opts.avrgcc_style) Emit_Used_IO_Registers(); - while(Pos < buflen) { + while(pos < buflen) { // Check if this is actually code or maybe only data from tagfile - int Added = Tagfile_Process_Data(buf, Pos, addr); - if(Added) { - Pos += Added; + int added = Tagfile_Process_Data(buf, pos, addr); + if(added) { + pos += added; continue; } - opcode = (buf[Pos] & 0xff) | (buf[Pos+1] & 0xff)<<8; + opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); - oplen = 2*avr_opcodes[mnemo].nwords; + oplen = mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords; - if(mnemo != -1) { - disassemble(buf + Pos, disasm_wrap(Pos + addr), opcode, mnemo, &line, 2); + disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line, 2); - if(cx->dis_opts.Process_Labels) - Print_JumpCalls(disasm_wrap(Pos + addr)); + if(cx->dis_opts.Process_Labels) + Print_JumpCalls(disasm_wrap(pos + addr)); - if(cx->dis_opts.Show_Addresses) - term_out("%4x: ", disasm_wrap(Pos + addr)); - if(cx->dis_opts.Show_Cycles) - term_out("[%-3s] ", avr_opcodes[mnemo].clock[cx->dis_cycle_index]); + if(cx->dis_opts.Show_Addresses) + term_out("%*x: ", awd, disasm_wrap(pos + addr)); + if(cx->dis_opts.Show_Cycles) + term_out("[%-3s] ", mnemo < 0? "---": avr_opcodes[mnemo].clock[cx->dis_cycle_index]); - if(cx->dis_opts.Show_Opcodes) { - // Now display the Opcode - for(i = 0; i < oplen; i++) - term_out("%02x ", buf[Pos + i] & 0xff); - term_out(" "); - for(i = 0; i < 5 - oplen; i++) - term_out(" "); - } - - if(!*line.comment || !cx->dis_opts.Show_Comments) - term_out("%s\n", line.code); - else - term_out("%-23s ; %s\n", line.code, line.comment); - if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) - term_out("\n"); - - Pos += oplen; - } else { - term_out("%-23s ; Invalid opcode\n", - str_ccprintf(".word 0x%02x%02x", buf[Pos+1] & 0xff, buf[Pos] & 0xff)); - Pos += 2; + if(cx->dis_opts.Show_Opcodes) { + for(int i = 0; i < 5; i++) + term_out(i < oplen? "%02x ": " ", buf[pos + i] & 0xff); + term_out(" "); } + + if(!*line.comment || !cx->dis_opts.Show_Comments) + term_out("%s\n", line.code); + else + term_out("%-23s ; %s\n", line.code, line.comment); + if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) + term_out("\n"); + + pos += oplen; } return 0; diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c index c22ab085..ce093236 100644 --- a/src/disasm_jumpcall.c +++ b/src/disasm_jumpcall.c @@ -127,21 +127,19 @@ void Enumerate_Labels(void) { } } -const char *Get_Label_Name(int Destination, char **LabelComment) { - int TagIndex; - - TagIndex = Tagfile_FindLabelAddress(Destination); - if(TagIndex != -1) { - if(LabelComment) - *LabelComment = Tagfile_GetLabelComment(TagIndex); - return str_ccprintf("%s", Tagfile_GetLabel(TagIndex)); +const char *Get_Label_Name(int destination, char **comment) { + int index = disasm_find_symbol('L', destination); + if(index >= 0) { + if(comment) + *comment = Tagfile_GetLabelComment(index); + return str_ccprintf("%s", Tagfile_GetLabel(index)); } for(int i = 0; i < cx->dis_JumpCallN; i++) - if(cx->dis_JumpCalls[i].To == Destination) + if(cx->dis_JumpCalls[i].To == destination) return str_ccprintf("%s%d", cx->dis_JumpCalls[i].FunctionCall? "Function": "Label", cx->dis_JumpCalls[i].LabelNumber); - return "UNKNOWN"; + return "unknown"; } // Show all references which refer to "Position" as destination diff --git a/src/disasm_private.h b/src/disasm_private.h index 36c27113..9ce78dba 100644 --- a/src/disasm_private.h +++ b/src/disasm_private.h @@ -33,9 +33,9 @@ void disasm_init_regfile(const AVRPART *p); int disasm_wrap(int addr); -int Tagfile_FindLabelAddress(int address); -char *Tagfile_GetLabel(int TagIndex); -char *Tagfile_GetLabelComment(int TagIndex); +int disasm_find_symbol(int type, int address); +char *Tagfile_GetLabel(int index); +char *Tagfile_GetLabelComment(int index); int Tagfile_FindPGMAddress(int address); const char *Tagfile_Resolve_Mem_Address(int address); int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c index ac9027cf..24a5b981 100644 --- a/src/disasm_tagfile.c +++ b/src/disasm_tagfile.c @@ -34,246 +34,172 @@ #include "libavrdude.h" #include "disasm_private.h" -static int LineError(const char *Token, const char *Message, int LineNo) { - if((Token == NULL) || (strlen(Token) == 0)) { - pmsg_error("%s in tagfile, line %d\n", Message, LineNo); +static void zap_symbols() { + if(cx->dis_symbols) { + for(int i = 0; i < cx->dis_symbolN; i++) { + mmt_free(cx->dis_symbols[i].comment); + mmt_free(cx->dis_symbols[i].name); + } + mmt_free(cx->dis_symbols); + cx->dis_symbols = NULL; + } + cx->dis_symbolN = 0; +} + +static int symbol_sort(const void *v1, const void *v2) { + const Disasm_symbol *p1 = v1, *p2 = v2; + int diff; + + if((diff = p1->type - p2->type)) + return diff; + return p1->address - p2->address; +} + +int disasm_find_symbol(int type, int address) { + Disasm_symbol key, *found; + + key.type = type; + key.address = address; + found = bsearch(&key, cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); + + return found? found - cx->dis_symbols: -1; +} + +static void add_symbol(int address, int type, int subtype, int count, const char *name, const char *comment) { + int N = cx->dis_symbolN++; + + cx->dis_symbols = (Disasm_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Disasm_symbol) * (N+1)); + cx->dis_symbols[N].address = address; + cx->dis_symbols[N].type = type; + cx->dis_symbols[N].subtype = subtype; + cx->dis_symbols[N].count = count; + cx->dis_symbols[N].used = 0; + cx->dis_symbols[N].name = name? mmt_strdup(name): NULL; + cx->dis_symbols[N].comment = comment? mmt_strdup(comment): NULL; +} + +static int LineError(const char *token, const char *message, int lineno) { + if((token == NULL) || (strlen(token) == 0)) { + pmsg_error("%s in tagfile, line %d\n", message, lineno); return 1; } return 0; } -static void zap_IORegisters() { - if(cx->dis_IORegisters) { - for(int i = 0; i < cx->dis_IORegisterN; i++) - mmt_free(cx->dis_IORegisters[i].name); - mmt_free(cx->dis_IORegisters); - cx->dis_IORegisters = NULL; - } - cx->dis_IORegisterN = 0; -} - -static void zap_CodeLabels() { - if(cx->dis_CodeLabels) { - for(int i = 0; i < cx->dis_CodeLabelN; i++) { - mmt_free(cx->dis_CodeLabels[i].comment); - mmt_free(cx->dis_CodeLabels[i].name); - } - mmt_free(cx->dis_CodeLabels); - cx->dis_CodeLabels = NULL; - } - cx->dis_CodeLabelN = 0; -} - -static void zap_PGMLabels() { - if(cx->dis_PGMLabels) { - for(int i = 0; i < cx->dis_PGMLabelN; i++) - mmt_free(cx->dis_PGMLabels[i].name); - mmt_free(cx->dis_PGMLabels); - cx->dis_PGMLabels = NULL; - } - cx->dis_PGMLabelN = 0; -} - -static void zap_MemLabels() { - if(cx->dis_MemLabels) { - for(int i = 0; i < cx->dis_MemLabelN; i++) - mmt_free(cx->dis_MemLabels[i].name); - mmt_free(cx->dis_MemLabels); - cx->dis_MemLabels = NULL; - } - cx->dis_MemLabelN = 0; -} - - -static void Add_Code_Tag(int address, const char *name, const char *comment) { - cx->dis_CodeLabelN++; - - cx->dis_CodeLabels = (Disasm_CodeLabel *) mmt_realloc(cx->dis_CodeLabels, sizeof(Disasm_CodeLabel) * cx->dis_CodeLabelN); - cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].address = address; - cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].name = name? mmt_strdup(name): NULL; - cx->dis_CodeLabels[cx->dis_CodeLabelN - 1].comment = comment? mmt_strdup(comment): NULL; -} - -static void Add_PGM_Tag(int address, char subtype, unsigned int Count, const char *name) { - cx->dis_PGMLabelN++; - - cx->dis_PGMLabels = (Disasm_PGMLabel *) mmt_realloc(cx->dis_PGMLabels, sizeof(Disasm_PGMLabel) * cx->dis_PGMLabelN); - cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].address = address; - cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].subtype = subtype; - cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].Count = Count; - cx->dis_PGMLabels[cx->dis_PGMLabelN - 1].name = name? mmt_strdup(name): NULL; -} - -static void Add_Mem_Tag(int address, char subtype, unsigned int Count, const char *name) { - cx->dis_MemLabelN++; - - cx->dis_MemLabels = (Disasm_MemLabel *) mmt_realloc(cx->dis_MemLabels, sizeof(Disasm_MemLabel) * cx->dis_MemLabelN); - cx->dis_MemLabels[cx->dis_MemLabelN - 1].address = address; - cx->dis_MemLabels[cx->dis_MemLabelN - 1].subtype = subtype; - cx->dis_MemLabels[cx->dis_MemLabelN - 1].Count = Count; - cx->dis_MemLabels[cx->dis_MemLabelN - 1].name = name? mmt_strdup(name): NULL; -} - -static int Tagfile_Readline(char *Line, int LineNo) { - char *Token, Type, Subtype, *Name; - int address, Count; +static int Tagfile_Readline(char *line, int lineno) { + char *token, type, subtype, *name; + int address, count; const char *errptr; - if(Line[0] == '#' || strlen(Line) <= 1) + if(line[0] == '#' || strlen(line) <= 1) return 0; - Token = strtok(Line, " \t\n"); - if(LineError(Token, "nonempty line", LineNo)) + token = strtok(line, " \t\n"); + if(LineError(token, "nonempty line", lineno)) return -1; - address = str_int(Token, STR_INT32, &errptr); + address = str_int(token, STR_INT32, &errptr); if(errptr) { - pmsg_error("address %s: %s\n", Token, errptr); + pmsg_error("address %s: %s\n", token, errptr); return -1; } - Token = strtok(NULL, " \t\n"); - if(LineError(Token, "no second argument", LineNo)) + token = strtok(NULL, " \t\n"); + if(LineError(token, "no second argument", lineno)) return -1; - if(strlen(Token) != 1) { - LineError(NULL, "second argument should be a type (L, P or M)", LineNo); + if(strlen(token) != 1) { + LineError(NULL, "second argument should be a type (L, P or M)", lineno); return -1; } - Type = Token[0]; + type = token[0]; - Token = strtok(NULL, " \t\n"); - if(LineError(Token, "no third argument", LineNo)) + token = strtok(NULL, " \t\n"); + if(LineError(token, "no third argument", lineno)) return -1; - if(Type == 'L') { - Name = Token; // Name, comment is optional - Add_Code_Tag(address, Name, strtok(NULL, "\t\n")); + if(type == 'L') { + name = token; // Name, comment is optional + add_symbol(address, 'L', 0, 0, name, strtok(NULL, "\t\n")); return 0; } - if(LineError(Token, "no fourth argument", LineNo)) + if(LineError(token, "no fourth argument", lineno)) return -1; - if(strlen(Token) != 1) { - LineError(NULL, "fourth argument should be a subtype (B, W, A or S)", LineNo); + if(strlen(token) != 1) { + LineError(NULL, "fourth argument should be a subtype (B, W, A or S)", lineno); return -1; } - Subtype = Token[0]; + subtype = token[0]; // Either B(yte), W(ord), A(utoterminated string) or S(tring) - switch (Subtype) { + switch(subtype) { case 'B': - Subtype = TYPE_BYTE; + subtype = TYPE_BYTE; break; case 'W': - Subtype = TYPE_WORD; + subtype = TYPE_WORD; break; case 'A': - Subtype = TYPE_ASTRING; + subtype = TYPE_ASTRING; break; case 'S': - Subtype = TYPE_STRING; + subtype = TYPE_STRING; break; default: - LineError(NULL, "invalid subtype (expected one of B, W, A or S)", LineNo); + LineError(NULL, "invalid subtype (expected one of B, W, A or S)", lineno); return -1; } - if((Type == 'M') && ((Subtype != TYPE_BYTE) && (Subtype != TYPE_WORD))) { - LineError(NULL, "memory labels can only be of type B or W", LineNo); + if((type == 'M') && ((subtype != TYPE_BYTE) && (subtype != TYPE_WORD))) { + LineError(NULL, "memory labels can only be of type B or W", lineno); return -1; } - Token = strtok(NULL, " \t\n"); - Count = str_int(Token, STR_INT32, &errptr); + token = strtok(NULL, " \t\n"); + count = str_int(token, STR_INT32, &errptr); if(errptr) { - pmsg_error("count %s: %s\n", Token, errptr); + pmsg_error("count %s: %s\n", token, errptr); return -1; } - if(Count < 1) { - LineError(NULL, str_ccprintf("invalid count %d given", Count), LineNo); + if(count < 1) { + LineError(NULL, str_ccprintf("invalid count %d given", count), lineno); return -1; } - Name = strtok(NULL, " \t\n"); - if(Type == 'P') { - Add_PGM_Tag(address, Subtype, Count, Name); - } else if(Type == 'M') { - Add_Mem_Tag(address, Subtype, Count, Name); - } else { - pmsg_error("invalid tag type %c\n", Type); + name = strtok(NULL, " \t\n"); + if(type != 'P' && type != 'M') { + pmsg_error("invalid tag type %c (must be L, P or M)\n", type); return -1; } + add_symbol(address, type, subtype, count, name, NULL); return 0; } -static int CodeLabelSort(const void *A, const void *B) { - const Disasm_CodeLabel *X, *Y; - X = (const Disasm_CodeLabel *) A; - Y = (const Disasm_CodeLabel *) B; - if(X->address == Y->address) - return 0; - if(X->address < Y->address) - return -1; - return 1; -} - -static int PGMLabelSort(const void *A, const void *B) { - const Disasm_PGMLabel *X, *Y; - - X = (const Disasm_PGMLabel *) A; - Y = (const Disasm_PGMLabel *) B; - if(X->address == Y->address) - return 0; - if(X->address < Y->address) - return -1; - return 1; -} - -static int MemLabelSort(const void *A, const void *B) { - const Disasm_MemLabel *X, *Y; - - X = (const Disasm_MemLabel *) A; - Y = (const Disasm_MemLabel *) B; - if(X->address == Y->address) - return 0; - if(X->address < Y->address) - return -1; - return 1; -} - -static void Tagfile_SortLabels() { - qsort(cx->dis_CodeLabels, cx->dis_CodeLabelN, sizeof(Disasm_CodeLabel), CodeLabelSort); - qsort(cx->dis_PGMLabels, cx->dis_PGMLabelN, sizeof(Disasm_PGMLabel), PGMLabelSort); - qsort(cx->dis_MemLabels, cx->dis_MemLabelN, sizeof(Disasm_MemLabel), MemLabelSort); -} - -int disasm_init_tagfile(const AVRPART *p, const char *Filename) { - FILE *inf = fopen(Filename, "r"); - int LineNo = 1; +int disasm_init_tagfile(const AVRPART *p, const char *fname) { + FILE *inf = fopen(fname, "r"); + int lineno = 1; const char *errstr; if(!inf) { - pmsg_ext_error("cannot open tagfile %s: %s\n", Filename, strerror(errno)); + pmsg_ext_error("cannot open tagfile %s: %s\n", fname, strerror(errno)); return -1; } - zap_CodeLabels(); - zap_PGMLabels(); - zap_MemLabels(); + zap_symbols(); disasm_init_regfile(p); for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) - if(Tagfile_Readline(buffer, LineNo++) < 0) + if(Tagfile_Readline(buffer, lineno++) < 0) goto error; if(errstr) { - pmsg_error("read error in tag file %s: %s\n", Filename, errstr); + pmsg_error("read error in tag file %s: %s\n", fname, errstr); goto error; } fclose(inf); - Tagfile_SortLabels(); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); return 0; error: @@ -281,53 +207,36 @@ error: return -1; } -int Tagfile_FindLabelAddress(int address) { - Disasm_CodeLabel Goal; - Disasm_CodeLabel *Result; - - Goal.address = address; - Result = bsearch(&Goal, cx->dis_CodeLabels, cx->dis_CodeLabelN, sizeof(Disasm_CodeLabel), CodeLabelSort); - if(Result == NULL) - return -1; - return Result - cx->dis_CodeLabels; +char *Tagfile_GetLabel(int index) { + return cx->dis_symbols[index].name; } -char *Tagfile_GetLabel(int TagIndex) { - return cx->dis_CodeLabels[TagIndex].name; -} - -char *Tagfile_GetLabelComment(int TagIndex) { - return cx->dis_CodeLabels[TagIndex].comment; -} - -int Tagfile_FindPGMAddress(int address) { - Disasm_PGMLabel Goal; - Disasm_PGMLabel *Result; - - Goal.address = address; - Result = bsearch(&Goal, cx->dis_PGMLabels, cx->dis_PGMLabelN, sizeof(Disasm_PGMLabel), PGMLabelSort); - if(Result == NULL) - return -1; - return Result - cx->dis_PGMLabels; +char *Tagfile_GetLabelComment(int index) { + return cx->dis_symbols[index].comment; } const char *Tagfile_Resolve_Mem_Address(int address) { - for(int i = 0; i < cx->dis_MemLabelN && cx->dis_MemLabels[i].address <= address; i++) { - int Start = cx->dis_MemLabels[i].address; - int Size = cx->dis_MemLabels[i].subtype == TYPE_WORD? 2: 1; - int End = cx->dis_MemLabels[i].address + cx->dis_MemLabels[i].Count * Size - 1; + for(int i = 0; i < cx->dis_symbolN; i++) { + if(cx->dis_symbols[i].type != 'M') + continue; + if(cx->dis_symbols[i].address > address) + break; - if(address >= Start && address <= End) { - if(cx->dis_MemLabels[i].Count == 1) { // Single variable - if(Size == 1) - return str_ccprintf("%s", cx->dis_MemLabels[i].name); - return str_ccprintf("_%s8(%s)", address == Start? "lo": "hi", cx->dis_MemLabels[i].name); + int start = cx->dis_symbols[i].address; + int size = cx->dis_symbols[i].subtype == TYPE_WORD? 2: 1; + int end = cx->dis_symbols[i].address + cx->dis_symbols[i].count * size - 1; + + if(address >= start && address <= end) { + if(cx->dis_symbols[i].count == 1) { // Single variable + if(size == 1) + return str_ccprintf("%s", cx->dis_symbols[i].name); + return str_ccprintf("_%s8(%s)", address == start? "lo": "hi", cx->dis_symbols[i].name); } // Array - if(Size == 1) - return str_ccprintf("%s[%d]", cx->dis_MemLabels[i].name, address - Start); - return str_ccprintf("_%s8(%s[%d])", (address-Start)%2? "hi": "lo", cx->dis_MemLabels[i].name, - (address - Start)/2); + if(size == 1) + return str_ccprintf("%s[%d]", cx->dis_symbols[i].name, address - start); + return str_ccprintf("_%s8(%s[%d])", (address - start)%2? "hi": "lo", + cx->dis_symbols[i].name, (address - start)/2); } } @@ -388,15 +297,14 @@ static void Sanitize_String(char *String) { int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { int BytesAdvanced; - int Index; int (*ProcessingFunction)(const char *, int, int, int, const char *) = NULL; char Buffer[32]; - Index = Tagfile_FindPGMAddress(disasm_wrap(Position + offset)); - if(Index == -1) + int index = disasm_find_symbol('P', disasm_wrap(Position + offset)); + if(index < 0) return 0; - switch (cx->dis_PGMLabels[Index].subtype) { + switch(cx->dis_symbols[index].subtype) { case TYPE_BYTE: ProcessingFunction = Tagfile_Process_Byte; break; @@ -411,8 +319,8 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { break; } - term_out("; Inline PGM data: %d ", cx->dis_PGMLabels[Index].Count); - switch (cx->dis_PGMLabels[Index].subtype) { + term_out("; Inline PGM data: %d ", cx->dis_symbols[index].count); + switch(cx->dis_symbols[index].subtype) { case TYPE_BYTE: term_out("byte"); break; @@ -426,17 +334,17 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { term_out("string"); break; } - if(cx->dis_PGMLabels[Index].Count != 1) + if(cx->dis_symbols[index].count != 1) term_out("s"); term_out(" starting at 0x%0*x", cx->dis_addrwidth, disasm_wrap(Position + offset)); - if(cx->dis_PGMLabels[Index].name) - term_out(" (%s)", cx->dis_PGMLabels[Index].name); + if(cx->dis_symbols[index].name) + term_out(" (%s)", cx->dis_symbols[index].name); term_out("\n"); - if((cx->dis_PGMLabels[Index].subtype == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].subtype == TYPE_STRING)) { - if(cx->dis_PGMLabels[Index].name != NULL) { - snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_PGMLabels[Index].name); + if((cx->dis_symbols[index].subtype == TYPE_ASTRING) || (cx->dis_symbols[index].subtype == TYPE_STRING)) { + if(cx->dis_symbols[index].name != NULL) { + snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_symbols[index].name); Sanitize_String(Buffer); } else { snprintf(Buffer, sizeof(Buffer), "%x", disasm_wrap(Position + offset)); @@ -444,10 +352,10 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { } BytesAdvanced = 0; - for(unsigned i = 0; i < cx->dis_PGMLabels[Index].Count; i++) + for(int i = 0; i < cx->dis_symbols[index].count; i++) BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, offset, i, Buffer); - if(cx->dis_PGMLabels[Index].subtype == TYPE_ASTRING) { + if(cx->dis_symbols[index].subtype == TYPE_ASTRING) { // Autoaligned string if((BytesAdvanced % 2) != 0) { // Not yet aligned correctly @@ -465,11 +373,11 @@ int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { // Allocate, copy, append a suffix (H, L, 0...8 or nothing), make upper case and return -static char *regname(const char *reg, int suf) { +static char *regname(const char *pre, const char *reg, int suf) { char *ret = - suf <= -1? mmt_strdup(reg): - suf == 'h' || suf == 'l'? str_sprintf("%s%c", reg, suf): - str_sprintf("%s%d", reg, suf); + suf <= -1? str_sprintf("%s%s", pre, reg): + suf == 'h' || suf == 'l'? str_sprintf("%s%s%c", pre, reg, suf): + str_sprintf("%s%s%d", pre, reg, suf); for(char *s = ret; *s; s++) *s = *s == '.'? '_': isascii(*s & 0xff)? toupper(*s & 0xff): *s; @@ -477,64 +385,46 @@ static char *regname(const char *reg, int suf) { return ret; } -// Initialise cx->dis_IORegisters and cx->dis_MemLabels from part register file +// Initialise cx->dis_symbols from part register file void disasm_init_regfile(const AVRPART *p) { - int nr = 0, nio = 0, offset = 0; + int nr = 0, offset = 0; const Register_file *rf = avr_locate_register_file(p, &nr); if(rf) { - zap_MemLabels(); - zap_IORegisters(); - - // Count how many entries are needed - for(int i = 0; i< nr; i++) - if(rf[i].addr < 0x40 && rf[i].size > 0) - nio += rf[i].size; - cx->dis_IORegisters = mmt_malloc(nio*sizeof*cx->dis_IORegisters); - cx->dis_MemLabels = mmt_malloc(nr*sizeof*cx->dis_MemLabels); - AVRMEM *mem = avr_locate_io(p); if(mem) offset = mem->offset; - nio = 0; + const char *mpre = offset? "MEM_": ""; + const char *ipre = offset? "IO_": ""; for(int i = 0; i< nr; i++) { - cx->dis_MemLabels[i].address = offset + rf[i].addr; - cx->dis_MemLabels[i].subtype = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; - cx->dis_MemLabels[i].Count = rf[i].size > 2? rf[i].size: 1; - cx->dis_MemLabels[i].name = regname(rf[i].reg, -1); + int addr = offset + rf[i].addr; + int sub = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; + int count = rf[i].size > 2? rf[i].size: 1; + add_symbol(addr, 'M', sub, count, regname(mpre, rf[i].reg, -1), NULL); if(rf[i].addr < 0x40) { - if(rf[i].size == 1) { - cx->dis_IORegisters[nio].name = regname(rf[i].reg, -1); - cx->dis_IORegisters[nio].address = rf[i].addr; - nio++; - } else if(rf[i].size == 2) { - cx->dis_IORegisters[nio].name = regname(rf[i].reg, 'l'); - cx->dis_IORegisters[nio].address = rf[i].addr; - nio++; - cx->dis_IORegisters[nio].name = regname(rf[i].reg, 'h'); - cx->dis_IORegisters[nio].address = rf[i].addr+1; - nio++; + if(rf[i].size == 1) + add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, -1), NULL); + else if(rf[i].size == 2) { + add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, 'l'), NULL); + add_symbol(rf[i].addr+1, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, 'h'), NULL); } else if(rf[i].size > 2) { - for(int k = 0; k < rf[i].size; k++) { - cx->dis_IORegisters[nio].name = regname(rf[i].reg, k); - cx->dis_IORegisters[nio].address = rf[i].addr + k; - nio++; - } + for(int k = 0; k < rf[i].size; k++) + add_symbol(rf[i].addr+k, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, k), NULL); } } } - cx->dis_IORegisterN = nio; - cx->dis_MemLabelN = nr; - qsort(cx->dis_MemLabels, cx->dis_MemLabelN, sizeof(Disasm_MemLabel), MemLabelSort); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); } } const char *Resolve_IO_Register(int Number) { - for(int i = 0; i < cx->dis_IORegisterN; i++) { - if(cx->dis_IORegisters[i].address == Number) { - cx->dis_IORegisters[i].used = 1; - return cx->dis_IORegisters[i].name; + for(int i = 0; i < cx->dis_symbolN; i++) { + if(cx->dis_symbols[i].type != 'I') + continue; + if(cx->dis_symbols[i].address == Number) { + cx->dis_symbols[i].used = 1; + return cx->dis_symbols[i].name; } } @@ -542,7 +432,7 @@ const char *Resolve_IO_Register(int Number) { } void Emit_Used_IO_Registers() { - for(int i = 0; i < cx->dis_IORegisterN; i++) - if(cx->dis_IORegisters[i].used) - term_out(".equ %s, 0x%02x\n", cx->dis_IORegisters[i].name, cx->dis_IORegisters[i].address); + for(int i = 0; i < cx->dis_symbolN; i++) + if(cx->dis_symbols[i].used) + term_out(".equ %s, 0x%02x\n", cx->dis_symbols[i].name, cx->dis_symbols[i].address); } diff --git a/src/libavrdude.h b/src/libavrdude.h index c9ea9fd9..fc0d5a84 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1473,26 +1473,6 @@ typedef struct { int FunctionCall; } Disasm_JumpCall; -typedef struct { - int address; - char *name; - char *comment; -} Disasm_CodeLabel; - -typedef struct { - int address; - int subtype; - unsigned int Count; - char *name; -} Disasm_PGMLabel; - -typedef struct { - int address; - int subtype; - unsigned int Count; - char *name; -} Disasm_MemLabel; - typedef struct { int address; char *name; @@ -1851,12 +1831,9 @@ typedef struct { // Static variables from disasm*.c int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth, dis_cycle_index; Disasm_options dis_opts; - int dis_JumpCallN, dis_CodeLabelN, dis_PGMLabelN, dis_MemLabelN, dis_IORegisterN; + int dis_JumpCallN, dis_symbolN; Disasm_JumpCall *dis_JumpCalls; - Disasm_CodeLabel *dis_CodeLabels; - Disasm_PGMLabel *dis_PGMLabels; - Disasm_MemLabel *dis_MemLabels; - Disasm_IO_Register *dis_IORegisters; + Disasm_symbol *dis_symbols; // Static variables from usb_libusb.c #include "usbdevs.h" From 0d7524deebd8f8fdd1851e265efa7e61840192b3 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 22 Jul 2024 21:14:10 +0200 Subject: [PATCH 344/422] Add -xno_autoreset for the -c wiring programmer --- src/wiring.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/wiring.c b/src/wiring.c index 60b8f705..e5b8c06f 100644 --- a/src/wiring.c +++ b/src/wiring.c @@ -56,6 +56,7 @@ */ struct wiringpdata { int snoozetime, delay; + bool autoreset; }; @@ -106,10 +107,21 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { pmsg_notice2("%s(): delay set to %d ms\n", __func__, val); WIRINGPDATA(pgm)->delay = val; continue; - } else if (str_eq(extended_param, "help")) { + } + else if(str_starts(extended_param, "no_autoreset")) { + if(!str_eq(extended_param, "no_autoreset")) { + pmsg_error("invalid -xno_autoreset value %s. Use -xno_autoreset\n", extended_param); + rv = -1; + break; + } + WIRINGPDATA(pgm)->autoreset = false; + continue; + } + else if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); msg_error(" -xsnooze= Wait snooze [ms] before protocol sync after port open\n"); msg_error(" -xdelay= Add delay [ms] after reset, can be negative\n"); + msg_error(" -xno_autoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); msg_error(" -xhelp Show this help menu and exit\n"); return LIBAVRDUDE_EXIT;; } @@ -134,19 +146,19 @@ static int wiring_open(PROGRAMMER *pgm, const char *port) { if (WIRINGPDATA(pgm)->snoozetime > 0) { timetosnooze = WIRINGPDATA(pgm)->snoozetime; - pmsg_notice2("wiring_open(): snoozing for %d ms\n", timetosnooze); + pmsg_notice2("%s(): snoozing for %d ms\n", __func__, timetosnooze); while (timetosnooze--) usleep(1000); - pmsg_notice2("wiring_open(): done snoozing\n"); - } else { + pmsg_notice2("%s(): done snoozing\n", __func__); + } else if (WIRINGPDATA(pgm)->autoreset) { // This code assumes a negative-logic USB to TTL serial adapter // Set RTS/DTR high to discharge the series-capacitor, if present - pmsg_notice2("wiring_open(): releasing DTR/RTS\n"); + pmsg_notice2("%s(): releasing DTR/RTS\n", __func__); serial_set_dtr_rts(&pgm->fd, 0); usleep(50*1000); // Pull the RTS/DTR line low to reset AVR - pmsg_notice2("wiring_open(): asserting DTR/RTS\n"); + pmsg_notice2("%s(): asserting DTR/RTS\n", __func__); serial_set_dtr_rts(&pgm->fd, 1); // Max 100 us: charging a cap longer creates a high reset spike above Vcc @@ -170,8 +182,7 @@ static int wiring_open(PROGRAMMER *pgm, const char *port) { return 0; } -static void wiring_close(PROGRAMMER * pgm) -{ +static void wiring_close(PROGRAMMER *pgm) { serial_close(&pgm->fd); pgm->fd.ifd = -1; } @@ -184,9 +195,10 @@ void wiring_initpgm(PROGRAMMER *pgm) { stk500v2_initpgm(pgm); strcpy(pgm->type, "Wiring"); + WIRINGPDATA(&pgm)->autoreset = true; // Auto-reset enabled by default + pgm->open = wiring_open; pgm->close = wiring_close; - pgm->setup = wiring_setup; pgm->teardown = wiring_teardown; pgm->parseextparams = wiring_parseextparms; From 1fcc0d9f91a8d4f93dacfcd8338e626e6a8870e6 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 21:27:30 +0100 Subject: [PATCH 345/422] Consolidate disassm source into one file --- src/CMakeLists.txt | 3 - src/Makefile.am | 3 - src/avr_opcodes.c | 1 + src/disasm.c | 604 ++++++++++++++++++++++++++++++++++++++++-- src/disasm_jumpcall.c | 169 ------------ src/disasm_private.h | 50 ---- src/disasm_tagfile.c | 438 ------------------------------ src/libavrdude.h | 22 +- src/term.c | 42 +-- 9 files changed, 605 insertions(+), 727 deletions(-) delete mode 100644 src/disasm_jumpcall.c delete mode 100644 src/disasm_private.h delete mode 100644 src/disasm_tagfile.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 930819e5..776b8128 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -182,9 +182,6 @@ add_library(libavrdude crc16.c crc16.h disasm.c - disasm_private.h - disasm_jumpcall.c - disasm_tagfile.c dfu.c dfu.h dryrun.c diff --git a/src/Makefile.am b/src/Makefile.am index 9f2ca7e6..bc1a1b9e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -120,9 +120,6 @@ libavrdude_a_SOURCES = \ crc16.c \ crc16.h \ disasm.c \ - disasm_private.h \ - disasm_jumpcall.c \ - disasm_tagfile.c \ dfu.c \ dfu.h \ dryrun.c \ diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 7642bdee..bc55e758 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -74,6 +74,7 @@ * * s SREG bit number 0..7 (brbs, brbc, bset, bclr) * + * - Source: Table was curated from https://github.com/nlitsme/AVRInstructionSet */ const AVR_opcode_data avr_opcodes[164] = { diff --git a/src/disasm.c b/src/disasm.c index c76ecc77..4c6c4dac 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -1,9 +1,7 @@ /* * AVRDUDE - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2024 by Stefan Rueger - * - * Based on avrdisas (but heavily rewritten) * Copyright (C) 2007 Johannes Bauer + * Copyright (C) 2024 by Stefan Rueger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,27 +19,576 @@ /* $Id$ */ +/* + * The disassembly code originates from the avrdisas disassembler written in + * 2007 by Johannes Bauer. The current code has been ported by Stefan Rueger to + * - Enable disassembly of small memory chunks in AVRDUDE's terminal + * - Drive disassembly from the avr_opcode[] table + */ + #include +#include #include #include #include #include #include -#include +#include #include "avrdude.h" #include "libavrdude.h" -#include "disasm_private.h" +#define TYPE_BYTE 1 +#define TYPE_WORD 2 +#define TYPE_ASTRING 3 +#define TYPE_STRING 4 + + +static void zap_symbols() { + if(cx->dis_symbols) { + for(int i = 0; i < cx->dis_symbolN; i++) { + mmt_free(cx->dis_symbols[i].comment); + mmt_free(cx->dis_symbols[i].name); + } + mmt_free(cx->dis_symbols); + cx->dis_symbols = NULL; + } + cx->dis_symbolN = 0; +} + +static int symbol_sort(const void *v1, const void *v2) { + const Disasm_symbol *p1 = v1, *p2 = v2; + int diff; + + if((diff = p1->type - p2->type)) + return diff; + return p1->address - p2->address; +} + +static int find_symbol(int type, int address) { + Disasm_symbol key, *found; + + key.type = type; + key.address = address; + found = bsearch(&key, cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); + + return found? found - cx->dis_symbols: -1; +} + +static void add_symbol(int address, int type, int subtype, int count, const char *name, const char *comment) { + int N = cx->dis_symbolN++; + + cx->dis_symbols = (Disasm_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Disasm_symbol) * (N+1)); + cx->dis_symbols[N].address = address; + cx->dis_symbols[N].type = type; + cx->dis_symbols[N].subtype = subtype; + cx->dis_symbols[N].count = count; + cx->dis_symbols[N].used = 0; + cx->dis_symbols[N].name = name? mmt_strdup(name): NULL; + cx->dis_symbols[N].comment = comment? mmt_strdup(comment): NULL; +} + +static int LineError(const char *token, const char *message, int lineno) { + if((token == NULL) || (strlen(token) == 0)) { + pmsg_error("%s in tagfile, line %d\n", message, lineno); + return 1; + } + return 0; +} + +static int Tagfile_Readline(char *line, int lineno) { + char *token, type, subtype, *name; + int address, count; + const char *errptr; + + if(line[0] == '#' || strlen(line) <= 1) + return 0; + + token = strtok(line, " \t\n"); + if(LineError(token, "nonempty line", lineno)) + return -1; + address = str_int(token, STR_INT32, &errptr); + if(errptr) { + pmsg_error("address %s: %s\n", token, errptr); + return -1; + } + + token = strtok(NULL, " \t\n"); + if(LineError(token, "no second argument", lineno)) + return -1; + if(strlen(token) != 1) { + LineError(NULL, "second argument should be a type (L, P or M)", lineno); + return -1; + } + type = token[0]; + + token = strtok(NULL, " \t\n"); + if(LineError(token, "no third argument", lineno)) + return -1; + + if(type == 'L') { + name = token; // Name, comment is optional + add_symbol(address, 'L', 0, 0, name, strtok(NULL, "\t\n")); + return 0; + } + + if(LineError(token, "no fourth argument", lineno)) + return -1; + if(strlen(token) != 1) { + LineError(NULL, "fourth argument should be a subtype (B, W, A or S)", lineno); + return -1; + } + subtype = token[0]; + + // Either B(yte), W(ord), A(utoterminated string) or S(tring) + switch(subtype) { + case 'B': + subtype = TYPE_BYTE; + break; + case 'W': + subtype = TYPE_WORD; + break; + case 'A': + subtype = TYPE_ASTRING; + break; + case 'S': + subtype = TYPE_STRING; + break; + default: + LineError(NULL, "invalid subtype (expected one of B, W, A or S)", lineno); + return -1; + } + + if((type == 'M') && ((subtype != TYPE_BYTE) && (subtype != TYPE_WORD))) { + LineError(NULL, "memory labels can only be of type B or W", lineno); + return -1; + } + + token = strtok(NULL, " \t\n"); + count = str_int(token, STR_INT32, &errptr); + if(errptr) { + pmsg_error("count %s: %s\n", token, errptr); + return -1; + } + if(count < 1) { + LineError(NULL, str_ccprintf("invalid count %d given", count), lineno); + return -1; + } + + name = strtok(NULL, " \t\n"); + if(type != 'P' && type != 'M') { + pmsg_error("invalid tag type %c (must be L, P or M)\n", type); + return -1; + } + + add_symbol(address, type, subtype, count, name, NULL); + return 0; +} + +// Allocate, copy, append a suffix (H, L, 0...8 or nothing), make upper case and return +static char *regname(const char *pre, const char *reg, int suf) { + char *ret = + suf <= -1? str_sprintf("%s%s", pre, reg): + suf == 'h' || suf == 'l'? str_sprintf("%s%s%c", pre, reg, suf): + str_sprintf("%s%s%d", pre, reg, suf); + + for(char *s = ret; *s; s++) + *s = *s == '.'? '_': isascii(*s & 0xff)? toupper(*s & 0xff): *s; + + return ret; +} + +// Initialise cx->dis_symbols from part register file +static void init_regfile(const AVRPART *p) { + int nr = 0, offset = 0; + const Register_file *rf = avr_locate_register_file(p, &nr); + + if(rf) { + AVRMEM *mem = avr_locate_io(p); + if(mem) + offset = mem->offset; + const char *mpre = offset? "MEM_": ""; + const char *ipre = offset? "IO_": ""; + for(int i = 0; i< nr; i++) { + int addr = offset + rf[i].addr; + int sub = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; + int count = rf[i].size > 2? rf[i].size: 1; + add_symbol(addr, 'M', sub, count, regname(mpre, rf[i].reg, -1), NULL); + + if(rf[i].addr < 0x40) { + if(rf[i].size == 1) + add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, -1), NULL); + else if(rf[i].size == 2) { + add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, 'l'), NULL); + add_symbol(rf[i].addr+1, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, 'h'), NULL); + } else if(rf[i].size > 2) { + for(int k = 0; k < rf[i].size; k++) + add_symbol(rf[i].addr+k, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, k), NULL); + } + } + } + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); + } +} + +int disasm_init_tagfile(const AVRPART *p, const char *fname) { + FILE *inf = fopen(fname, "r"); + int lineno = 1; + const char *errstr; + + if(!inf) { + pmsg_ext_error("cannot open tagfile %s: %s\n", fname, strerror(errno)); + return -1; + } + + zap_symbols(); + init_regfile(p); + + for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) + if(Tagfile_Readline(buffer, lineno++) < 0) + goto error; + + if(errstr) { + pmsg_error("read error in tag file %s: %s\n", fname, errstr); + goto error; + } + + fclose(inf); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); + return 0; + +error: + fclose(inf); + return -1; +} + +static char *Tagfile_GetLabel(int index) { + return cx->dis_symbols[index].name; +} + +static char *Tagfile_GetLabelComment(int index) { + return cx->dis_symbols[index].comment; +} + +static const char *resolve_mem_address(int address) { + for(int i = 0; i < cx->dis_symbolN; i++) { + if(cx->dis_symbols[i].type != 'M') + continue; + if(cx->dis_symbols[i].address > address) + break; + + int start = cx->dis_symbols[i].address; + int size = cx->dis_symbols[i].subtype == TYPE_WORD? 2: 1; + int end = cx->dis_symbols[i].address + cx->dis_symbols[i].count * size - 1; + + if(address >= start && address <= end) { + if(cx->dis_symbols[i].count == 1) { // Single variable + if(size == 1) + return str_ccprintf("%s", cx->dis_symbols[i].name); + return str_ccprintf("_%s8(%s)", address == start? "lo": "hi", cx->dis_symbols[i].name); + } + // Array + if(size == 1) + return str_ccprintf("%s[%d]", cx->dis_symbols[i].name, address - start); + return str_ccprintf("_%s8(%s[%d])", (address - start)%2? "hi": "lo", + cx->dis_symbols[i].name, (address - start)/2); + } + } + + return NULL; +} + +static int process_byte(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { + term_out(".byte 0x%02x\n", Bitstream[Position] & 0xff); + return 1; +} + +static int process_word(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { + term_out(".word 0x%02x%02x\n", Bitstream[Position + 1] & 0xff, Bitstream[Position] & 0xff); + return 2; +} + +static int process_string(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { + int i; + unsigned char c; + unsigned int InString = 0; + + term_out("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); + i = 0; + while((c = Bitstream[Position + i])) { + if((c >= 32) && (c <= 127)) { + if(!InString) + term_out(".ascii \""); + term_out("%c", c); + InString = 1; + } else { + if(InString) + term_out("\"\n"); + term_out(".byte 0x%02x\n", c); + InString = 0; + } + i++; + } + if(InString) + term_out("\\0\"\n"); + else + term_out(".byte 0x00\n"); + + term_out("\n"); + return i + 1; +} + +static void Sanitize_String(char *String) { + size_t i; + size_t l = strlen(String); + + for(i = 0; i < l; i++) { + if(!(((String[i] >= 'a') && (String[i] <= 'z')) || + (((String[i] >= 'A') && (String[i] <= 'Z'))) || (((String[i] >= '0') && (String[i] <= '9'))))) { + String[i] = '_'; + } + } +} // Wrap around flash -int disasm_wrap(int addr) { +static int disasm_wrap(int addr) { if(cx->dis_flashsz2) addr &= cx->dis_flashsz2-1; return addr; } +static int process_data(const char *Bitstream, int Position, int offset) { + int BytesAdvanced; + int (*ProcessingFunction)(const char *, int, int, int, const char *) = NULL; + char Buffer[32]; + + int index = find_symbol('P', disasm_wrap(Position + offset)); + if(index < 0) + return 0; + + switch(cx->dis_symbols[index].subtype) { + case TYPE_BYTE: + ProcessingFunction = process_byte; + break; + case TYPE_WORD: + ProcessingFunction = process_word; + break; + case TYPE_ASTRING: + ProcessingFunction = process_string; + break; + case TYPE_STRING: + ProcessingFunction = process_string; + break; + } + + term_out("; Inline PGM data: %d ", cx->dis_symbols[index].count); + switch(cx->dis_symbols[index].subtype) { + case TYPE_BYTE: + term_out("byte"); + break; + case TYPE_WORD: + term_out("word"); + break; + case TYPE_ASTRING: + term_out("autoaligned string"); + break; + case TYPE_STRING: + term_out("string"); + break; + } + if(cx->dis_symbols[index].count != 1) + term_out("s"); + term_out(" starting at 0x%0*x", cx->dis_addrwidth, disasm_wrap(Position + offset)); + + if(cx->dis_symbols[index].name) + term_out(" (%s)", cx->dis_symbols[index].name); + term_out("\n"); + + if((cx->dis_symbols[index].subtype == TYPE_ASTRING) || (cx->dis_symbols[index].subtype == TYPE_STRING)) { + if(cx->dis_symbols[index].name != NULL) { + snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_symbols[index].name); + Sanitize_String(Buffer); + } else { + snprintf(Buffer, sizeof(Buffer), "%x", disasm_wrap(Position + offset)); + } + } + + BytesAdvanced = 0; + for(int i = 0; i < cx->dis_symbols[index].count; i++) + BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, offset, i, Buffer); + + if(cx->dis_symbols[index].subtype == TYPE_ASTRING) { + // Autoaligned string + if((BytesAdvanced % 2) != 0) { + // Not yet aligned correctly + if(Bitstream[Position + BytesAdvanced] != 0x00) + pmsg_warning("autoalignment expected zero but got 0x%02x padding; ignored\n", + Bitstream[Position + BytesAdvanced] & 0xff); + term_out(".byte 0x%02x ; String Autoalignment\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); + BytesAdvanced++; + } + } + + term_out("\n"); + return BytesAdvanced; +} + +static const char *resolve_io_register(int Number) { + for(int i = 0; i < cx->dis_symbolN; i++) { + if(cx->dis_symbols[i].type != 'I') + continue; + if(cx->dis_symbols[i].address == Number) { + cx->dis_symbols[i].used = 1; + return cx->dis_symbols[i].name; + } + } + + return NULL; +} + +void emit_used_io_registers() { + for(int i = 0; i < cx->dis_symbolN; i++) + if(cx->dis_symbols[i].used) + term_out(".equ %s, 0x%02x\n", cx->dis_symbols[i].name, cx->dis_symbols[i].address); +} + + +void disasm_zap_jumpcalls() { + if(cx->dis_JumpCalls) { + mmt_free(cx->dis_JumpCalls); + cx->dis_JumpCalls = NULL; + } + cx->dis_JumpCallN = 0; +} + +static void register_jumpcall(int From, int To, int mnemo, unsigned char FunctionCall) { + if(cx->dis_opts.process_labels) { + Disasm_JumpCall *jc = cx->dis_JumpCalls; + int N = cx->dis_JumpCallN; + + // Already entered this JC? + for(int i = 0; i < N; i++) + if(jc[i].From == From && jc[N].To == To && jc[N].mnemo == mnemo) + return; + + jc = mmt_realloc(jc, sizeof(Disasm_JumpCall) * (N+1)); + jc[N].From = From; + jc[N].To = To; + jc[N].mnemo = mnemo; + jc[N].LabelNumber = 0; + jc[N].FunctionCall = FunctionCall; + + cx->dis_JumpCalls = jc; + cx->dis_JumpCallN++; + } +} + +static int JC_Comparison(const void *Element1, const void *Element2) { + Disasm_JumpCall *JC1, *JC2; + + JC1 = (Disasm_JumpCall *) Element1; + JC2 = (Disasm_JumpCall *) Element2; + if((JC1->To) > (JC2->To)) + return 1; + else if((JC1->To) == (JC2->To)) + return 0; + return -1; +} + +static void Correct_Label_IsFunct(void) { + int i, j; + int LastIdx = 0; + int LastDest = cx->dis_JumpCalls[0].To; + char CurIsFunct = cx->dis_JumpCalls[0].FunctionCall; + + for(i = 1; i < cx->dis_JumpCallN; i++) { + if(cx->dis_JumpCalls[i].To != LastDest) { + for(j = LastIdx; j < i; j++) + cx->dis_JumpCalls[j].FunctionCall = CurIsFunct; + LastIdx = i; + LastDest = cx->dis_JumpCalls[i].To; + CurIsFunct = 0; + } + CurIsFunct = CurIsFunct || cx->dis_JumpCalls[i].FunctionCall; + } + for(j = LastIdx; j < cx->dis_JumpCallN; j++) + cx->dis_JumpCalls[j].FunctionCall = CurIsFunct; +} + +static void enumerate_labels(void) { + int i; + int CurrentLabelNumber = 0; + int CurrentFunctionNumber = 0; + int Destination; + + if(cx->dis_JumpCallN < 2) + return; + + qsort(cx->dis_JumpCalls, cx->dis_JumpCallN, sizeof(Disasm_JumpCall), JC_Comparison); + Correct_Label_IsFunct(); + + Destination = cx->dis_JumpCalls[0].To; + if(cx->dis_JumpCalls[0].FunctionCall) + CurrentFunctionNumber++; + else + CurrentLabelNumber++; + for(i = 0; i < cx->dis_JumpCallN; i++) { + if(Destination != cx->dis_JumpCalls[i].To) { + if(cx->dis_JumpCalls[i].FunctionCall) + CurrentFunctionNumber++; + else + CurrentLabelNumber++; + Destination = cx->dis_JumpCalls[i].To; + } + if(cx->dis_JumpCalls[i].FunctionCall) + cx->dis_JumpCalls[i].LabelNumber = CurrentFunctionNumber; + else + cx->dis_JumpCalls[i].LabelNumber = CurrentLabelNumber; + } +} + +static const char *get_label_name(int destination, char **comment) { + int index = find_symbol('L', destination); + if(index >= 0) { + if(comment) + *comment = Tagfile_GetLabelComment(index); + return str_ccprintf("%s", Tagfile_GetLabel(index)); + } + + for(int i = 0; i < cx->dis_JumpCallN; i++) + if(cx->dis_JumpCalls[i].To == destination) + return str_ccprintf("%s%d", cx->dis_JumpCalls[i].FunctionCall? "Function": "Label", cx->dis_JumpCalls[i].LabelNumber); + + return "unknown"; +} + +// Show all references which refer to "Position" as destination +static void print_jumpcalls(int Position) { + int i; + int Match = 0; + + for(i = 0; i < cx->dis_JumpCallN; i++) { + if((cx->dis_JumpCalls[i].To) == Position) { + if(Match == 0) { + term_out("\n"); + Match = 1; + } + term_out("; Referenced from 0x%0*x by %s\n", cx->dis_addrwidth, + cx->dis_JumpCalls[i].From, avr_opcodes[cx->dis_JumpCalls[i].mnemo].opcode); + } + } + if(Match == 1) { + char *LabelComment = NULL; + const char *LabelName = get_label_name(Position, &LabelComment); + if(LabelComment == NULL) { + term_out("%s:\n", LabelName); + } else { + term_out("%-23s ; %s\n", str_ccprintf("%s:", LabelName), LabelComment); + } + } +} + typedef struct { char code[256], comment[256]; } Disasm_line; @@ -66,7 +613,7 @@ typedef struct { #define Nb (bits['b']) #define Nq (bits['q']) -char *add_comment(Disasm_line *line, const char *comment) { +static char *add_comment(Disasm_line *line, const char *comment) { int len = strlen(line->comment), rem = 256-len-1; char *p = line->comment + len; @@ -78,7 +625,6 @@ char *add_comment(Disasm_line *line, const char *comment) { return p + strlen(p); } - static const char *regstyle(int n, int regword) { if(regword && !cx->dis_opts.avrgcc_style) return str_ccprintf("%d:%d", n+1, n); @@ -96,7 +642,7 @@ static unsigned bitcount(unsigned n) { return ret; } -void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm_line *line, int pass) { +static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm_line *line, int pass) { memset(line, 0, sizeof*line); if(mnemo < 0) { add_comment(line, "Invalid opcode"); @@ -210,7 +756,7 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm offset = (int8_t) (Rk<<1); // Sign-extend and multiply by 2 target = disasm_wrap(addr + offset + 2); if(pass == 1) - Register_JumpCall(addr, target, mnemo, 0); + register_jumpcall(addr, target, mnemo, 0); is_jumpcall = 1; is_relative = 1; break; // rjmp/rcall @@ -218,12 +764,12 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm offset = (int16_t) (Rk<<4) >> 3; // Sign extend and multiply by 2 target = disasm_wrap(addr + offset + 2); if(pass == 1) - Register_JumpCall(addr, target, mnemo, is_function); + register_jumpcall(addr, target, mnemo, is_function); is_jumpcall = 1; is_relative = 1; break; case 16: // lds/sts - kmemaddr = Tagfile_Resolve_Mem_Address(Rk); + kmemaddr = resolve_mem_address(Rk); break; case 22: if(cx->dis_flashsz && 2*Rk > cx->dis_flashsz) @@ -231,7 +777,7 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm str_ccprintf("Warning: destination outside flash [0, 0x%0*x]", awd, cx->dis_flashsz-1)); target = 2*Rk; // disasm_wrap(2*Rk); if(pass == 1) - Register_JumpCall(addr, target, mnemo, is_function); + register_jumpcall(addr, target, mnemo, is_function); is_jumpcall = 1; break; } @@ -245,7 +791,7 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm *c++ = *o, *c = 0; break; case 'A': - if((regname = Resolve_IO_Register(RA))) + if((regname = resolve_io_register(RA))) snprintf(c, 256-strlen(c), "%s", regname); else snprintf(c, 256-strlen(c), "0x%02x", RA); @@ -253,13 +799,13 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm break; case 'a': snprintf(c, 255 - (c-line->code), "0x%02x", Ra); - if((memaddr = Tagfile_Resolve_Mem_Address(Ra))) + if((memaddr = resolve_mem_address(Ra))) add_comment(line, str_ccprintf("%s", memaddr)); break; case 'k': if(is_jumpcall) { - if(cx->dis_opts.Process_Labels) { - snprintf(c, 255 - (c-line->code), "%s", Get_Label_Name(target, NULL)); + if(cx->dis_opts.process_labels) { + snprintf(c, 255 - (c-line->code), "%s", get_label_name(target, NULL)); add_comment(line, str_ccprintf("0x%0*x", awd, target)); } else { if(is_relative) { @@ -308,7 +854,7 @@ void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm /* * Disassemble buflen bytes at buf which corresponds to address addr * - * Before the location buf there are leadin bytes available (0 - 2) + * Before(!) the location buf there are leadin bytes available (0 - 2) * After the location buf+readlen there are leadout bytes available (0 -4) */ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { @@ -321,7 +867,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { if(cx->dis_symbols[i].type == 'I') cx->dis_symbols[i].used = 0; - if(cx->dis_opts.Process_Labels || cx->dis_opts.avrgcc_style) { + if(cx->dis_opts.process_labels || cx->dis_opts.avrgcc_style) { // Preprocess to gather jump labels or to gain knowledge about registers which are being used while(pos < buflen) { opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; @@ -329,16 +875,16 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line, 1); pos += mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords; } - Enumerate_Labels(); + enumerate_labels(); pos = 0; } if(cx->dis_opts.avrgcc_style) - Emit_Used_IO_Registers(); + emit_used_io_registers(); while(pos < buflen) { // Check if this is actually code or maybe only data from tagfile - int added = Tagfile_Process_Data(buf, pos, addr); + int added = process_data(buf, pos, addr); if(added) { pos += added; continue; @@ -350,21 +896,21 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line, 2); - if(cx->dis_opts.Process_Labels) - Print_JumpCalls(disasm_wrap(pos + addr)); + if(cx->dis_opts.process_labels) + print_jumpcalls(disasm_wrap(pos + addr)); - if(cx->dis_opts.Show_Addresses) + if(cx->dis_opts.show_addresses) term_out("%*x: ", awd, disasm_wrap(pos + addr)); - if(cx->dis_opts.Show_Cycles) + if(cx->dis_opts.show_cycles) term_out("[%-3s] ", mnemo < 0? "---": avr_opcodes[mnemo].clock[cx->dis_cycle_index]); - if(cx->dis_opts.Show_Opcodes) { + if(cx->dis_opts.show_opcodes) { for(int i = 0; i < 5; i++) term_out(i < oplen? "%02x ": " ", buf[pos + i] & 0xff); term_out(" "); } - if(!*line.comment || !cx->dis_opts.Show_Comments) + if(!*line.comment || !cx->dis_opts.show_comments) term_out("%s\n", line.code); else term_out("%-23s ; %s\n", line.code, line.comment); @@ -408,6 +954,6 @@ int disasm_init(const AVRPART *p) { cx->dis_cycle_index = avr_get_cycle_index(p); - disasm_init_regfile(p); + init_regfile(p); return 0; } diff --git a/src/disasm_jumpcall.c b/src/disasm_jumpcall.c deleted file mode 100644 index ce093236..00000000 --- a/src/disasm_jumpcall.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * AVRDUDE - A Downloader/Uploader for AVR device programmers - * - * This file was ported from - * avrdisas - A disassembler for AVR microcontroller units - * Copyright (C) 2007 Johannes Bauer - * - * Copyright (C) 2024 port by Stefan Rueger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* $Id$ */ - - -#include -#include -#include - -#include "avrdude.h" -#include "libavrdude.h" -#include "disasm_private.h" - - -void disasm_zap_JumpCalls() { - if(cx->dis_JumpCalls) { - mmt_free(cx->dis_JumpCalls); - cx->dis_JumpCalls = NULL; - } - cx->dis_JumpCallN = 0; -} - -void Register_JumpCall(int From, int To, int mnemo, unsigned char FunctionCall) { - if(cx->dis_opts.Process_Labels) { - Disasm_JumpCall *jc = cx->dis_JumpCalls; - int N = cx->dis_JumpCallN; - - // Already entered this JC? - for(int i = 0; i < N; i++) - if(jc[i].From == From && jc[N].To == To && jc[N].mnemo == mnemo) - return; - - jc = mmt_realloc(jc, sizeof(Disasm_JumpCall) * (N+1)); - jc[N].From = From; - jc[N].To = To; - jc[N].mnemo = mnemo; - jc[N].LabelNumber = 0; - jc[N].FunctionCall = FunctionCall; - - cx->dis_JumpCalls = jc; - cx->dis_JumpCallN++; - } -} - -static int JC_Comparison(const void *Element1, const void *Element2) { - Disasm_JumpCall *JC1, *JC2; - - JC1 = (Disasm_JumpCall *) Element1; - JC2 = (Disasm_JumpCall *) Element2; - if((JC1->To) > (JC2->To)) - return 1; - else if((JC1->To) == (JC2->To)) - return 0; - return -1; -} - -static void Correct_Label_IsFunct(void) { - int i, j; - int LastIdx = 0; - int LastDest = cx->dis_JumpCalls[0].To; - char CurIsFunct = cx->dis_JumpCalls[0].FunctionCall; - - for(i = 1; i < cx->dis_JumpCallN; i++) { - if(cx->dis_JumpCalls[i].To != LastDest) { - for(j = LastIdx; j < i; j++) - cx->dis_JumpCalls[j].FunctionCall = CurIsFunct; - LastIdx = i; - LastDest = cx->dis_JumpCalls[i].To; - CurIsFunct = 0; - } - CurIsFunct = CurIsFunct || cx->dis_JumpCalls[i].FunctionCall; - } - for(j = LastIdx; j < cx->dis_JumpCallN; j++) - cx->dis_JumpCalls[j].FunctionCall = CurIsFunct; -} - -void Enumerate_Labels(void) { - int i; - int CurrentLabelNumber = 0; - int CurrentFunctionNumber = 0; - int Destination; - - if(cx->dis_JumpCallN < 2) - return; - - qsort(cx->dis_JumpCalls, cx->dis_JumpCallN, sizeof(Disasm_JumpCall), JC_Comparison); - Correct_Label_IsFunct(); - - Destination = cx->dis_JumpCalls[0].To; - if(cx->dis_JumpCalls[0].FunctionCall) - CurrentFunctionNumber++; - else - CurrentLabelNumber++; - for(i = 0; i < cx->dis_JumpCallN; i++) { - if(Destination != cx->dis_JumpCalls[i].To) { - if(cx->dis_JumpCalls[i].FunctionCall) - CurrentFunctionNumber++; - else - CurrentLabelNumber++; - Destination = cx->dis_JumpCalls[i].To; - } - if(cx->dis_JumpCalls[i].FunctionCall) - cx->dis_JumpCalls[i].LabelNumber = CurrentFunctionNumber; - else - cx->dis_JumpCalls[i].LabelNumber = CurrentLabelNumber; - } -} - -const char *Get_Label_Name(int destination, char **comment) { - int index = disasm_find_symbol('L', destination); - if(index >= 0) { - if(comment) - *comment = Tagfile_GetLabelComment(index); - return str_ccprintf("%s", Tagfile_GetLabel(index)); - } - - for(int i = 0; i < cx->dis_JumpCallN; i++) - if(cx->dis_JumpCalls[i].To == destination) - return str_ccprintf("%s%d", cx->dis_JumpCalls[i].FunctionCall? "Function": "Label", cx->dis_JumpCalls[i].LabelNumber); - - return "unknown"; -} - -// Show all references which refer to "Position" as destination -void Print_JumpCalls(int Position) { - int i; - int Match = 0; - - for(i = 0; i < cx->dis_JumpCallN; i++) { - if((cx->dis_JumpCalls[i].To) == Position) { - if(Match == 0) { - term_out("\n"); - Match = 1; - } - term_out("; Referenced from 0x%0*x by %s\n", cx->dis_addrwidth, - cx->dis_JumpCalls[i].From, avr_opcodes[cx->dis_JumpCalls[i].mnemo].opcode); - } - } - if(Match == 1) { - char *LabelComment = NULL; - const char *LabelName = Get_Label_Name(Position, &LabelComment); - if(LabelComment == NULL) { - term_out("%s:\n", LabelName); - } else { - term_out("%-23s ; %s\n", str_ccprintf("%s:", LabelName), LabelComment); - } - } -} diff --git a/src/disasm_private.h b/src/disasm_private.h deleted file mode 100644 index 9ce78dba..00000000 --- a/src/disasm_private.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * AVRDUDE - A Downloader/Uploader for AVR device programmers - * - * This file was ported from - * avrdisas - A disassembler for AVR microcontroller units - * Copyright (C) 2007 Johannes Bauer - * - * Copyright (C) 2024 port by Stefan Rueger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* $Id$ */ - -#ifndef disasm_private_h -#define disasm_private_h - -#define TYPE_BYTE 1 -#define TYPE_WORD 2 -#define TYPE_ASTRING 3 -#define TYPE_STRING 4 - -void disasm_init_regfile(const AVRPART *p); -int disasm_wrap(int addr); -int disasm_find_symbol(int type, int address); -char *Tagfile_GetLabel(int index); -char *Tagfile_GetLabelComment(int index); -int Tagfile_FindPGMAddress(int address); -const char *Tagfile_Resolve_Mem_Address(int address); -int Tagfile_Process_Data(const char *Bitstream, int Position, int offset); -const char *Resolve_IO_Register(int Number); -void Emit_Used_IO_Registers(); - -void Register_JumpCall(int From, int To, int mnemo, unsigned char FunctionCall); -void Enumerate_Labels(); -const char *Get_Label_Name(int Destination, char **LabelComment); -void Print_JumpCalls(int Position); - -#endif diff --git a/src/disasm_tagfile.c b/src/disasm_tagfile.c deleted file mode 100644 index 24a5b981..00000000 --- a/src/disasm_tagfile.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * AVRDUDE - A Downloader/Uploader for AVR device programmers - * - * This file was ported from - * avrdisas - A disassembler for AVR microcontroller units - * Copyright (C) 2007 Johannes Bauer - * - * Copyright (C) 2024 port by Stefan Rueger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* $Id$ */ - - -#include -#include -#include -#include -#include - -#include "avrdude.h" -#include "libavrdude.h" -#include "disasm_private.h" - -static void zap_symbols() { - if(cx->dis_symbols) { - for(int i = 0; i < cx->dis_symbolN; i++) { - mmt_free(cx->dis_symbols[i].comment); - mmt_free(cx->dis_symbols[i].name); - } - mmt_free(cx->dis_symbols); - cx->dis_symbols = NULL; - } - cx->dis_symbolN = 0; -} - -static int symbol_sort(const void *v1, const void *v2) { - const Disasm_symbol *p1 = v1, *p2 = v2; - int diff; - - if((diff = p1->type - p2->type)) - return diff; - return p1->address - p2->address; -} - -int disasm_find_symbol(int type, int address) { - Disasm_symbol key, *found; - - key.type = type; - key.address = address; - found = bsearch(&key, cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); - - return found? found - cx->dis_symbols: -1; -} - -static void add_symbol(int address, int type, int subtype, int count, const char *name, const char *comment) { - int N = cx->dis_symbolN++; - - cx->dis_symbols = (Disasm_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Disasm_symbol) * (N+1)); - cx->dis_symbols[N].address = address; - cx->dis_symbols[N].type = type; - cx->dis_symbols[N].subtype = subtype; - cx->dis_symbols[N].count = count; - cx->dis_symbols[N].used = 0; - cx->dis_symbols[N].name = name? mmt_strdup(name): NULL; - cx->dis_symbols[N].comment = comment? mmt_strdup(comment): NULL; -} - -static int LineError(const char *token, const char *message, int lineno) { - if((token == NULL) || (strlen(token) == 0)) { - pmsg_error("%s in tagfile, line %d\n", message, lineno); - return 1; - } - return 0; -} - -static int Tagfile_Readline(char *line, int lineno) { - char *token, type, subtype, *name; - int address, count; - const char *errptr; - - if(line[0] == '#' || strlen(line) <= 1) - return 0; - - token = strtok(line, " \t\n"); - if(LineError(token, "nonempty line", lineno)) - return -1; - address = str_int(token, STR_INT32, &errptr); - if(errptr) { - pmsg_error("address %s: %s\n", token, errptr); - return -1; - } - - token = strtok(NULL, " \t\n"); - if(LineError(token, "no second argument", lineno)) - return -1; - if(strlen(token) != 1) { - LineError(NULL, "second argument should be a type (L, P or M)", lineno); - return -1; - } - type = token[0]; - - token = strtok(NULL, " \t\n"); - if(LineError(token, "no third argument", lineno)) - return -1; - - if(type == 'L') { - name = token; // Name, comment is optional - add_symbol(address, 'L', 0, 0, name, strtok(NULL, "\t\n")); - return 0; - } - - if(LineError(token, "no fourth argument", lineno)) - return -1; - if(strlen(token) != 1) { - LineError(NULL, "fourth argument should be a subtype (B, W, A or S)", lineno); - return -1; - } - subtype = token[0]; - - // Either B(yte), W(ord), A(utoterminated string) or S(tring) - switch(subtype) { - case 'B': - subtype = TYPE_BYTE; - break; - case 'W': - subtype = TYPE_WORD; - break; - case 'A': - subtype = TYPE_ASTRING; - break; - case 'S': - subtype = TYPE_STRING; - break; - default: - LineError(NULL, "invalid subtype (expected one of B, W, A or S)", lineno); - return -1; - } - - if((type == 'M') && ((subtype != TYPE_BYTE) && (subtype != TYPE_WORD))) { - LineError(NULL, "memory labels can only be of type B or W", lineno); - return -1; - } - - token = strtok(NULL, " \t\n"); - count = str_int(token, STR_INT32, &errptr); - if(errptr) { - pmsg_error("count %s: %s\n", token, errptr); - return -1; - } - if(count < 1) { - LineError(NULL, str_ccprintf("invalid count %d given", count), lineno); - return -1; - } - - name = strtok(NULL, " \t\n"); - if(type != 'P' && type != 'M') { - pmsg_error("invalid tag type %c (must be L, P or M)\n", type); - return -1; - } - - add_symbol(address, type, subtype, count, name, NULL); - return 0; -} - - -int disasm_init_tagfile(const AVRPART *p, const char *fname) { - FILE *inf = fopen(fname, "r"); - int lineno = 1; - const char *errstr; - - if(!inf) { - pmsg_ext_error("cannot open tagfile %s: %s\n", fname, strerror(errno)); - return -1; - } - - zap_symbols(); - disasm_init_regfile(p); - - for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) - if(Tagfile_Readline(buffer, lineno++) < 0) - goto error; - - if(errstr) { - pmsg_error("read error in tag file %s: %s\n", fname, errstr); - goto error; - } - - fclose(inf); - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); - return 0; - -error: - fclose(inf); - return -1; -} - -char *Tagfile_GetLabel(int index) { - return cx->dis_symbols[index].name; -} - -char *Tagfile_GetLabelComment(int index) { - return cx->dis_symbols[index].comment; -} - -const char *Tagfile_Resolve_Mem_Address(int address) { - for(int i = 0; i < cx->dis_symbolN; i++) { - if(cx->dis_symbols[i].type != 'M') - continue; - if(cx->dis_symbols[i].address > address) - break; - - int start = cx->dis_symbols[i].address; - int size = cx->dis_symbols[i].subtype == TYPE_WORD? 2: 1; - int end = cx->dis_symbols[i].address + cx->dis_symbols[i].count * size - 1; - - if(address >= start && address <= end) { - if(cx->dis_symbols[i].count == 1) { // Single variable - if(size == 1) - return str_ccprintf("%s", cx->dis_symbols[i].name); - return str_ccprintf("_%s8(%s)", address == start? "lo": "hi", cx->dis_symbols[i].name); - } - // Array - if(size == 1) - return str_ccprintf("%s[%d]", cx->dis_symbols[i].name, address - start); - return str_ccprintf("_%s8(%s[%d])", (address - start)%2? "hi": "lo", - cx->dis_symbols[i].name, (address - start)/2); - } - } - - return NULL; -} - -static int Tagfile_Process_Byte(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { - term_out(".byte 0x%02x\n", Bitstream[Position] & 0xff); - return 1; -} - -static int Tagfile_Process_Word(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { - term_out(".word 0x%02x%02x\n", Bitstream[Position + 1] & 0xff, Bitstream[Position] & 0xff); - return 2; -} - -static int Tagfile_Process_String(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { - int i; - unsigned char c; - unsigned int InString = 0; - - term_out("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); - i = 0; - while((c = Bitstream[Position + i])) { - if((c >= 32) && (c <= 127)) { - if(!InString) - term_out(".ascii \""); - term_out("%c", c); - InString = 1; - } else { - if(InString) - term_out("\"\n"); - term_out(".byte 0x%02x\n", c); - InString = 0; - } - i++; - } - if(InString) - term_out("\\0\"\n"); - else - term_out(".byte 0x00\n"); - - term_out("\n"); - return i + 1; -} - -static void Sanitize_String(char *String) { - size_t i; - size_t l = strlen(String); - - for(i = 0; i < l; i++) { - if(!(((String[i] >= 'a') && (String[i] <= 'z')) || - (((String[i] >= 'A') && (String[i] <= 'Z'))) || (((String[i] >= '0') && (String[i] <= '9'))))) { - String[i] = '_'; - } - } -} - -int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) { - int BytesAdvanced; - int (*ProcessingFunction)(const char *, int, int, int, const char *) = NULL; - char Buffer[32]; - - int index = disasm_find_symbol('P', disasm_wrap(Position + offset)); - if(index < 0) - return 0; - - switch(cx->dis_symbols[index].subtype) { - case TYPE_BYTE: - ProcessingFunction = Tagfile_Process_Byte; - break; - case TYPE_WORD: - ProcessingFunction = Tagfile_Process_Word; - break; - case TYPE_ASTRING: - ProcessingFunction = Tagfile_Process_String; - break; - case TYPE_STRING: - ProcessingFunction = Tagfile_Process_String; - break; - } - - term_out("; Inline PGM data: %d ", cx->dis_symbols[index].count); - switch(cx->dis_symbols[index].subtype) { - case TYPE_BYTE: - term_out("byte"); - break; - case TYPE_WORD: - term_out("word"); - break; - case TYPE_ASTRING: - term_out("autoaligned string"); - break; - case TYPE_STRING: - term_out("string"); - break; - } - if(cx->dis_symbols[index].count != 1) - term_out("s"); - term_out(" starting at 0x%0*x", cx->dis_addrwidth, disasm_wrap(Position + offset)); - - if(cx->dis_symbols[index].name) - term_out(" (%s)", cx->dis_symbols[index].name); - term_out("\n"); - - if((cx->dis_symbols[index].subtype == TYPE_ASTRING) || (cx->dis_symbols[index].subtype == TYPE_STRING)) { - if(cx->dis_symbols[index].name != NULL) { - snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_symbols[index].name); - Sanitize_String(Buffer); - } else { - snprintf(Buffer, sizeof(Buffer), "%x", disasm_wrap(Position + offset)); - } - } - - BytesAdvanced = 0; - for(int i = 0; i < cx->dis_symbols[index].count; i++) - BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, offset, i, Buffer); - - if(cx->dis_symbols[index].subtype == TYPE_ASTRING) { - // Autoaligned string - if((BytesAdvanced % 2) != 0) { - // Not yet aligned correctly - if(Bitstream[Position + BytesAdvanced] != 0x00) - pmsg_warning("autoalignment expected zero but got 0x%02x padding; ignored\n", - Bitstream[Position + BytesAdvanced] & 0xff); - term_out(".byte 0x%02x ; String Autoalignment\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); - BytesAdvanced++; - } - } - - term_out("\n"); - return BytesAdvanced; -} - - -// Allocate, copy, append a suffix (H, L, 0...8 or nothing), make upper case and return -static char *regname(const char *pre, const char *reg, int suf) { - char *ret = - suf <= -1? str_sprintf("%s%s", pre, reg): - suf == 'h' || suf == 'l'? str_sprintf("%s%s%c", pre, reg, suf): - str_sprintf("%s%s%d", pre, reg, suf); - - for(char *s = ret; *s; s++) - *s = *s == '.'? '_': isascii(*s & 0xff)? toupper(*s & 0xff): *s; - - return ret; -} - -// Initialise cx->dis_symbols from part register file -void disasm_init_regfile(const AVRPART *p) { - int nr = 0, offset = 0; - const Register_file *rf = avr_locate_register_file(p, &nr); - - if(rf) { - AVRMEM *mem = avr_locate_io(p); - if(mem) - offset = mem->offset; - const char *mpre = offset? "MEM_": ""; - const char *ipre = offset? "IO_": ""; - for(int i = 0; i< nr; i++) { - int addr = offset + rf[i].addr; - int sub = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; - int count = rf[i].size > 2? rf[i].size: 1; - add_symbol(addr, 'M', sub, count, regname(mpre, rf[i].reg, -1), NULL); - - if(rf[i].addr < 0x40) { - if(rf[i].size == 1) - add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, -1), NULL); - else if(rf[i].size == 2) { - add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, 'l'), NULL); - add_symbol(rf[i].addr+1, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, 'h'), NULL); - } else if(rf[i].size > 2) { - for(int k = 0; k < rf[i].size; k++) - add_symbol(rf[i].addr+k, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, k), NULL); - } - } - } - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); - } -} - -const char *Resolve_IO_Register(int Number) { - for(int i = 0; i < cx->dis_symbolN; i++) { - if(cx->dis_symbols[i].type != 'I') - continue; - if(cx->dis_symbols[i].address == Number) { - cx->dis_symbols[i].used = 1; - return cx->dis_symbols[i].name; - } - } - - return NULL; -} - -void Emit_Used_IO_Registers() { - for(int i = 0; i < cx->dis_symbolN; i++) - if(cx->dis_symbols[i].used) - term_out(".equ %s, 0x%02x\n", cx->dis_symbols[i].name, cx->dis_symbols[i].address); -} diff --git a/src/libavrdude.h b/src/libavrdude.h index fc0d5a84..2c1f66a0 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1455,14 +1455,14 @@ typedef enum { } AVR_cycle_index; typedef struct { - int Show_Addresses; - int Show_Opcodes; - int Show_Comments; - int Show_Cycles; + int show_addresses; + int show_opcodes; + int show_comments; + int show_cycles; int avrgcc_style; - int Process_Labels; + int process_labels; int avrlevel; - char *Tagfile; + char *tagfile; } Disasm_options; typedef struct { @@ -1473,12 +1473,6 @@ typedef struct { int FunctionCall; } Disasm_JumpCall; -typedef struct { - int address; - char *name; - unsigned char used; -} Disasm_IO_Register; - typedef struct { char *name, *comment; int address; @@ -1732,10 +1726,10 @@ AVR_opcode opcode_mnemo(int op, int avrlevel); int avr_get_archlevel(const AVRPART *p); AVR_cycle_index avr_get_cycle_index(const AVRPART *p); +int disasm(const char *buf, int len, int addr, int leadin, int leadout); int disasm_init(const AVRPART *p); int disasm_init_tagfile(const AVRPART *p, const char *file); -int disasm(const char *buf, int len, int addr, int leadin, int leadout); -void disasm_zap_JumpCalls(); +void disasm_zap_jumpcalls(); #ifdef __cplusplus } diff --git a/src/term.c b/src/term.c index e51efad6..401787a1 100644 --- a/src/term.c +++ b/src/term.c @@ -214,12 +214,12 @@ static int hexdump_buf(const FILE *f, const AVRMEM *m, int startaddr, const unsi static int disasm_ison(char c) { switch(c) { - case 'a': return cx->dis_opts.Show_Addresses; - case 'o': return cx->dis_opts.Show_Opcodes; - case 'c': return cx->dis_opts.Show_Comments; - case 'q': return cx->dis_opts.Show_Cycles; + case 'a': return cx->dis_opts.show_addresses; + case 'o': return cx->dis_opts.show_opcodes; + case 'c': return cx->dis_opts.show_comments; + case 'q': return cx->dis_opts.show_cycles; case 's': return cx->dis_opts.avrgcc_style; - case 'l': return cx->dis_opts.Process_Labels; + case 'l': return cx->dis_opts.process_labels; case 'd': return cx->dis_opts.avrlevel == (PART_ALL | OP_AVR_ILL); } return 0; @@ -472,13 +472,13 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c int help = 0, invalid = 0, itemac = 1, chr; if(!cx->dis_initopts) { - cx->dis_opts.Show_Addresses = 1; - cx->dis_opts.Show_Opcodes = 1; - cx->dis_opts.Show_Comments = 1; - cx->dis_opts.Show_Cycles = 0; + cx->dis_opts.show_addresses = 1; + cx->dis_opts.show_opcodes = 1; + cx->dis_opts.show_comments = 1; + cx->dis_opts.show_cycles = 0; cx->dis_opts.avrgcc_style = 1; - cx->dis_opts.Process_Labels = 1; - cx->dis_opts.Tagfile = NULL; + cx->dis_opts.process_labels = 1; + cx->dis_opts.tagfile = NULL; cx->dis_opts.avrlevel = avr_get_archlevel(p); disasm_init(p); cx->dis_initopts++; @@ -496,25 +496,25 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c help++; break; case 'a': case 'A': - cx->dis_opts.Show_Addresses = islower(chr); + cx->dis_opts.show_addresses = islower(chr); break; case 'o': case 'O': - cx->dis_opts.Show_Opcodes = islower(chr); + cx->dis_opts.show_opcodes = islower(chr); break; case 'c': case 'C': - cx->dis_opts.Show_Comments = islower(chr); + cx->dis_opts.show_comments = islower(chr); break; case 'q': case 'Q': - cx->dis_opts.Show_Cycles = islower(chr); + cx->dis_opts.show_cycles = islower(chr); break; case 's': case 'S': cx->dis_opts.avrgcc_style = islower(chr); break; case 'l': case 'L': - cx->dis_opts.Process_Labels = islower(chr); + cx->dis_opts.process_labels = islower(chr); break; case 'z': - disasm_zap_JumpCalls(); + disasm_zap_jumpcalls(); break; case 'd': cx->dis_opts.avrlevel = PART_ALL | OP_AVR_ILL; @@ -525,8 +525,8 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c case 't': if(*++q == '=') q++; - mmt_free(cx->dis_opts.Tagfile); - cx->dis_opts.Tagfile = mmt_strdup(q); + mmt_free(cx->dis_opts.tagfile); + cx->dis_opts.tagfile = mmt_strdup(q); q = "x"; break; default: @@ -545,8 +545,8 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c return -1; } - if(cx->dis_opts.Tagfile) - if(disasm_init_tagfile(p, cx->dis_opts.Tagfile) < 0) + if(cx->dis_opts.tagfile) + if(disasm_init_tagfile(p, cx->dis_opts.tagfile) < 0) return -1; buf = readbuf(pgm, p, argc, argv, NULL, &addr, &len, &leadin, &leadout); From 92a6e71ae407208eee6379870030ad2bd0664e3d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 21:28:27 +0100 Subject: [PATCH 346/422] Adjust address when disassembling flash sub-memories, eg, boot --- src/avr.c | 16 ++++++++++++++++ src/libavrdude.h | 1 + src/term.c | 6 ++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/avr.c b/src/avr.c index fe48def3..6fb3629d 100644 --- a/src/avr.c +++ b/src/avr.c @@ -197,6 +197,22 @@ int avr_sigrow_offset(const AVRPART *p, const AVRMEM *mem, int addr) { return offset; } +// If mem is a sub-memory of flash return its offset within flash, 0 otherwise +int avr_flash_offset(const AVRPART *p, const AVRMEM *mem, int addr) { + int offset = 0; + + if(mem_is_in_flash(mem)) { + AVRMEM *m = avr_locate_flash(p); + if(m) { + int off = mem->offset - m->offset; + if(off >= 0 && off + addr < m->size) + offset = off; + } + } + + return offset; +} + int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char * value) { diff --git a/src/libavrdude.h b/src/libavrdude.h index 2c1f66a0..8ed8b370 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1104,6 +1104,7 @@ int avr_tpi_poll_nvmbsy(const PROGRAMMER *pgm); int avr_tpi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p); int avr_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p, unsigned char guard_time); int avr_sigrow_offset(const AVRPART *p, const AVRMEM *mem, int addr); +int avr_flash_offset(const AVRPART *p, const AVRMEM *mem, int addr); int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char * value); diff --git a/src/term.c b/src/term.c index 401787a1..5074411b 100644 --- a/src/term.c +++ b/src/term.c @@ -387,7 +387,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, int toread = cx->term_rmem[i].len; int whence = cx->term_rmem[i].addr; - int before = 0, after = 0; + int before = 0, after = 0, flash_offset = 0; if(is_disasm) { // Read a few bytes before/after & don't wrap round if(whence >= 2) before = 2, whence -= 2, toread += 2; @@ -427,10 +427,12 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, after -= i-end; else if(i > end) // Reduce length after += i-end; + // Disassembly of XMEGA's boot/apptable memory needs to know absolute addr in flash + flash_offset = avr_flash_offset(p, mem, whence + before); } if(memp) *memp = mem; - if(baddr) *baddr = whence + before; + if(baddr) *baddr = whence + before + flash_offset; if(blen) *blen = toread - before - after; if(prequel) *prequel = before; if(sequel) *sequel = after; From cdcb8fa8a28a643e9582734ffd01010e1dd8837c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 22:05:41 +0100 Subject: [PATCH 347/422] Provide disasm -f to show affected flags in SREG --- src/disasm.c | 12 ++++++++---- src/libavrdude.h | 1 + src/term.c | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 4c6c4dac..78080c8c 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -900,12 +900,16 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { print_jumpcalls(disasm_wrap(pos + addr)); if(cx->dis_opts.show_addresses) - term_out("%*x: ", awd, disasm_wrap(pos + addr)); - if(cx->dis_opts.show_cycles) - term_out("[%-3s] ", mnemo < 0? "---": avr_opcodes[mnemo].clock[cx->dis_cycle_index]); + term_out("%*x: ", awd, disasm_wrap(pos + addr)); + if(cx->dis_opts.show_cycles || cx->dis_opts.show_flags) { + if(cx->dis_opts.show_flags) + term_out("%s ", mnemo < 0? "--------": avr_opcodes[mnemo].flags); + if(cx->dis_opts.show_cycles) + term_out("%3s ", mnemo < 0? "---": avr_opcodes[mnemo].clock[cx->dis_cycle_index]); + } if(cx->dis_opts.show_opcodes) { - for(int i = 0; i < 5; i++) + for(int i = 0; i < 4; i++) term_out(i < oplen? "%02x ": " ", buf[pos + i] & 0xff); term_out(" "); } diff --git a/src/libavrdude.h b/src/libavrdude.h index 8ed8b370..7f6f68e5 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1459,6 +1459,7 @@ typedef struct { int show_addresses; int show_opcodes; int show_comments; + int show_flags; int show_cycles; int avrgcc_style; int process_labels; diff --git a/src/term.c b/src/term.c index 5074411b..f5cf6ee5 100644 --- a/src/term.c +++ b/src/term.c @@ -217,6 +217,7 @@ static int disasm_ison(char c) { case 'a': return cx->dis_opts.show_addresses; case 'o': return cx->dis_opts.show_opcodes; case 'c': return cx->dis_opts.show_comments; + case 'f': return cx->dis_opts.show_flags; case 'q': return cx->dis_opts.show_cycles; case 's': return cx->dis_opts.avrgcc_style; case 'l': return cx->dis_opts.process_labels; @@ -262,6 +263,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, {{'a', 'A'}, {"show addresses", "don't show addresses"}}, {{'o', 'O'}, {"show opcode bytes", "don't show opcode bytes"}}, {{'c', 'C'}, {"show comments", "don't show comments"}}, + {{'f', 'F'}, {"show affected flags in SREG", "don't show SREG flags"}}, {{'q', 'Q'}, {"show cycles", "don't show cycles"}}, {{'s', 'S'}, {"use avr-gcc code style", "use AVR instruction set style"}}, {{'l', 'L'}, {"preprocess jump/call labels", "don't preprocess labels"}}, @@ -477,6 +479,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.show_addresses = 1; cx->dis_opts.show_opcodes = 1; cx->dis_opts.show_comments = 1; + cx->dis_opts.show_flags = 0; cx->dis_opts.show_cycles = 0; cx->dis_opts.avrgcc_style = 1; cx->dis_opts.process_labels = 1; @@ -506,6 +509,9 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c case 'c': case 'C': cx->dis_opts.show_comments = islower(chr); break; + case 'f': case 'F': + cx->dis_opts.show_flags = islower(chr); + break; case 'q': case 'Q': cx->dis_opts.show_cycles = islower(chr); break; From dadd9c52cd7b053b4cced786542614d108831c4f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 22:21:01 +0100 Subject: [PATCH 348/422] Auto-adjust cycles for parts with 3-byte PC --- src/avr_opcodes.c | 16 ++++++++-------- src/disasm.c | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index bc55e758..eaeac956 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -193,22 +193,22 @@ const AVR_opcode_data avr_opcodes[164] = { {"3", "3", "3", "n/a"}, ""}, {OP_ID(rcall), 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, "rcall", "k", "Relative Call Subroutine", "PC <-- PC + k + 1", "--------", - {"3/4", "2/3", "2/3", "3"}, ""}, + {"3+", "2+", "2+", "3"}, ""}, {OP_ID(icall), 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPI, "icall", "", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", - {"3/4", "2/3", "2/3", "3"}, ""}, + {"3+", "2+", "2+", "3"}, ""}, {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, "eicall", "", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, ""}, {OP_ID(call), 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "--------", - {"4/5", "3/4", "3/4", "n/a"}, ""}, + {"4+", "3+", "3+", "n/a"}, ""}, {OP_ID(ret), 0xffff, 0x9508, 1, OP_AVR1, "1001 0101 0000 1000", OTY_JMPX, "ret", "", "Subroutine Return", "PC <-- STACK", "--------", - {"4/5", "4/5", "4/5", "6"}, ""}, + {"4+", "4+", "4+", "6"}, ""}, {OP_ID(reti), 0xffff, 0x9518, 1, OP_AVR1, "1001 0101 0001 1000", OTY_JMPX, "reti", "", "Interrupt Return", "PC <-- STACK", "I-------", - {"4/5", "4/5", "4/5", "6"}, ""}, + {"4+", "4+", "4+", "6"}, ""}, {OP_ID(cpse), 0xfc00, 0x1000, 1, OP_AVR1, "0001 00rd dddd rrrr", OTY_SKPI|OTY_RALL, "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, @@ -551,16 +551,16 @@ const AVR_opcode_data avr_opcodes[164] = { {"1", "1", "1", "1"}, ""}, {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPI, "u/icall", "", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", - {"3/4", "2/3", "2/3", "3"}, "xxx != 000"}, + {"3+", "2+", "2+", "3"}, "xxx != 000"}, {OP_ID(u_eicall), 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, "u/eicall", "", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, "xxx != 000"}, {OP_ID(u_ret), 0xff9f, 0x9508, 1, OP_AVR_ILL, "1001 0101 0xx0 1000", OTY_JMPX, "u/ret", "", "alt Subroutine Return", "PC <-- STACK", "--------", - {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, + {"4+", "4+", "4+", "6"}, "xx != 00"}, {OP_ID(u_reti), 0xff9f, 0x9518, 1, OP_AVR_ILL, "1001 0101 0xx1 1000", OTY_JMPX, "u/reti", "", "alt Interrupt Return", "PC <-- STACK", "I-------", - {"4/5", "4/5", "4/5", "6"}, "xx != 00"}, + {"4+", "4+", "4+", "6"}, "xx != 00"}, {OP_ID(u_nop_8), 0xffff, 0x95b8, 1, OP_AVR_ILL, "1001 0101 1011 1000", OTY_MCUI, "u/nop", "", "alt No Operation", "-", "--------", {"1", "1", "1", "1"}, ""}, diff --git a/src/disasm.c b/src/disasm.c index 78080c8c..e29357e4 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -851,6 +851,21 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, *c = 0; } + +// Increase cycle number by 1 if it's a 3 byte PC +static const char *cycles(int mnemo) { + if(mnemo < 0) + return "---"; + + const char *ret = avr_opcodes[mnemo].clock[cx->dis_cycle_index]; + + // A plus sign after the cycle number means add one for 3-byte PC + if(*ret && ret[1] == '+') + return str_ccprintf("%c", cx->dis_flashsz > 128*1024? *ret+1: *ret); + + return ret; +} + /* * Disassemble buflen bytes at buf which corresponds to address addr * @@ -905,7 +920,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { if(cx->dis_opts.show_flags) term_out("%s ", mnemo < 0? "--------": avr_opcodes[mnemo].flags); if(cx->dis_opts.show_cycles) - term_out("%3s ", mnemo < 0? "---": avr_opcodes[mnemo].clock[cx->dis_cycle_index]); + term_out("%3s ", cycles(mnemo)); } if(cx->dis_opts.show_opcodes) { From 0c3044217be810cd36df7dbf28c3693650e9f10e Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 23:31:39 +0100 Subject: [PATCH 349/422] Provide disasm -n to show full opcode name in comment --- src/avr_opcodes.c | 328 +++++++++++++++++++++++----------------------- src/disasm.c | 4 +- src/libavrdude.h | 3 +- src/term.c | 34 +++-- 4 files changed, 189 insertions(+), 180 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index eaeac956..0bfc9d7d 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -82,438 +82,438 @@ const AVR_opcode_data avr_opcodes[164] = { // Arithmetic and Logic Instructions {OP_ID(lsl), 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "lsl", "Rd", "Logical Shift Left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "--H-VNZC", + "lsl", "Rd", "logical shift left", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- 0", "--H-VNZC", {"1", "1", "1", "1"}, "alias for add Rd, Rd"}, {OP_ID(add), 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11rd dddd rrrr", OTY_ALBI|OTY_RALL, - "add", "Rd, Rr", "Add without Carry", "Rd <-- Rd + Rr", "--HSVNZC", + "add", "Rd, Rr", "add without carry", "Rd <-- Rd + Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(rol), 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "rol", "Rd", "Rotate Left Through Carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "--H-VNZC", + "rol", "Rd", "rotate left through carry", "C <-- Rd(7) <-- Rd(6) ... Rd(1) <-- Rd(0) <-- C", "--H-VNZC", {"1", "1", "1", "1"}, "alias for adc Rd, Rd"}, {OP_ID(adc), 0xfc00, 0x1c00, 1, OP_AVR1, "0001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, - "adc", "Rd, Rr", "Add with Carry", "Rd <-- Rd + Rr + C", "--HSVNZC", + "adc", "Rd, Rr", "add with carry", "Rd <-- Rd + Rr + C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(ror), 0xfe0f, 0x9407, 1, OP_AVR1, "1001 010d dddd 0111", OTY_ALBI|OTY_RALL, - "ror", "Rd", "Rotate Right Through Carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", + "ror", "Rd", "rotate right through carry", "C --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(asr), 0xfe0f, 0x9405, 1, OP_AVR1, "1001 010d dddd 0101", OTY_ALBI|OTY_RALL, - "asr", "Rd", "Arithmetic Shift Right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", + "asr", "Rd", "arithmetic shift right", "Rd(7) --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(adiw), 0xff00, 0x9600, 1, OP_AVR2nRC, "1001 0110 KKdd KKKK", OTY_ALBI|OTY_RW24, - "adiw", "Rd, K", "Add Immediate to Word", "Rd+1:Rd <-- Rd+1:Rd + K", "---SVNZC", + "adiw", "Rd, K", "add immediate to word", "Rd+1:Rd <-- Rd+1:Rd + K", "---SVNZC", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, {OP_ID(sub), 0xfc00, 0x1800, 1, OP_AVR1, "0001 10rd dddd rrrr", OTY_ALBI|OTY_RALL, - "sub", "Rd, Rr", "Subtract without Carry", "Rd <-- Rd - Rr", "--HSVNZC", + "sub", "Rd, Rr", "subtract without carry", "Rd <-- Rd - Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(subi), 0xf000, 0x5000, 1, OP_AVR1, "0101 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "subi", "Rd, K", "Subtract Immediate", "Rd <-- Rd - K", "--HSVNZC", + "subi", "Rd, K", "subtract immediate", "Rd <-- Rd - K", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, {OP_ID(sbc), 0xfc00, 0x0800, 1, OP_AVR1, "0000 10rd dddd rrrr", OTY_ALBI|OTY_RALL, - "sbc", "Rd, Rr", "Subtract with Carry", "Rd <-- Rd - Rr - C", "--HSVNZC", + "sbc", "Rd, Rr", "subtract with carry", "Rd <-- Rd - Rr - C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(sbci), 0xf000, 0x4000, 1, OP_AVR1, "0100 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "sbci", "Rd, K", "Subtract Immediate with Carry", "Rd <-- Rd - K - C", "--HSVNZC", + "sbci", "Rd, K", "subtract immediate with carry", "Rd <-- Rd - K - C", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, {OP_ID(sbiw), 0xff00, 0x9700, 1, OP_AVR2nRC, "1001 0111 KKdd KKKK", OTY_ALBI|OTY_RW24, - "sbiw", "Rd, K", "Subtract Immediate from Word", "Rd+1:Rd <-- Rd+1:Rd - K", "---SVNZC", + "sbiw", "Rd, K", "subtract immediate from word", "Rd+1:Rd <-- Rd+1:Rd - K", "---SVNZC", {"2", "2", "2", "n/a"}, "d in {24, 26, 28, 30}"}, {OP_ID(tst), 0xfc00, 0x2000, 1, OP_AVR1, "0010 00r= rrrr ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "tst", "Rr", "Test for Zero or Minus", "Rr <-- Rr & Rr", "---SVNZ-", + "tst", "Rr", "test for zero or minus", "Rr <-- Rr & Rr", "---SVNZ-", {"1", "1", "1", "1"}, "alias for and Rd, Rd"}, {OP_ID(and), 0xfc00, 0x2000, 1, OP_AVR1, "0010 00rd dddd rrrr", OTY_ALBI|OTY_RALL, - "and", "Rd, Rr", "Logical And", "Rd <-- Rd & Rr", "---SVNZ-", + "and", "Rd, Rr", "logical and", "Rd <-- Rd & Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OP_ID(andi), 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "andi", "Rd, K", "Logical And with Immediate", "Rd <-- Rd & K", "---SVNZ-", + "andi", "Rd, K", "logical and with immediate", "Rd <-- Rd & K", "---SVNZ-", {"1", "1", "1", "1"}, "d = 16..31"}, {OP_ID(cbr), 0xf000, 0x7000, 1, OP_AVR1, "0111 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, - "cbr", "Rd, K", "Clear Bit(s) in Register", "Rd <-- Rd & (0xff - K)", "---SVNZ-", + "cbr", "Rd, K", "clear bit(s) in register", "Rd <-- Rd & (0xff - K)", "---SVNZ-", {"1", "1", "1", "1"}, "alias for andi Rd, (0xff - K); d = 16..31"}, {OP_ID(or), 0xfc00, 0x2800, 1, OP_AVR1, "0010 10rd dddd rrrr", OTY_ALBI|OTY_RALL, - "or", "Rd, Rr", "Logical Or", "Rd <-- Rd | Rr", "---SVNZ-", + "or", "Rd, Rr", "logical or", "Rd <-- Rd | Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OP_ID(ori), 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "ori", "Rd, K", "Logical Or with Immediate", "Rd <-- Rd | K", "---SVNZ-", + "ori", "Rd, K", "logical or with immediate", "Rd <-- Rd | K", "---SVNZ-", {"1", "1", "1", "1"}, "d = 16..31"}, {OP_ID(sbr), 0xf000, 0x6000, 1, OP_AVR1, "0110 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP|OTY_ALIAS, - "sbr", "Rd, K", "Set Bit(s) in Register", "Rd <-- Rd or K", "---SVNZ-", + "sbr", "Rd, K", "set bit(s) in register", "Rd <-- Rd | K", "---SVNZ-", {"1", "1", "1", "1"}, "alias for ori Rd, K; d = 16..31"}, {OP_ID(clr), 0xfc00, 0x2400, 1, OP_AVR1, "0010 01d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, - "clr", "Rd", "Clear Register", "Rd <-- Rd ^ Rd", "---SVNZ-", + "clr", "Rd", "clear register", "Rd <-- Rd ^ Rd", "---SVNZ-", {"1", "1", "1", "1"}, "alias for eor Rd, Rd"}, {OP_ID(eor), 0xfc00, 0x2400, 1, OP_AVR1, "0010 01rd dddd rrrr", OTY_ALBI|OTY_RALL, - "eor", "Rd, Rr", "Exclusive or", "Rd <-- Rd ^ Rr", "---SVNZ-", + "eor", "Rd, Rr", "exclusive or", "Rd <-- Rd ^ Rr", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OP_ID(com), 0xfe0f, 0x9400, 1, OP_AVR1, "1001 010d dddd 0000", OTY_ALBI|OTY_RALL, - "com", "Rd", "One's Complement", "Rd <-- 0xff - Rd", "---SVNZC", + "com", "Rd", "one's complement", "Rd <-- 0xff - Rd", "---SVNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(neg), 0xfe0f, 0x9401, 1, OP_AVR1, "1001 010d dddd 0001", OTY_ALBI|OTY_RALL, - "neg", "Rd", "Two's Complement", "Rd <-- 0x00 - Rd", "--HSVNZC", + "neg", "Rd", "two's complement", "Rd <-- 0x00 - Rd", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(inc), 0xfe0f, 0x9403, 1, OP_AVR1, "1001 010d dddd 0011", OTY_ALBI|OTY_RALL, - "inc", "Rd", "Increment", "Rd <-- Rd + 1", "---SVNZ-", + "inc", "Rd", "increment", "Rd <-- Rd + 1", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OP_ID(dec), 0xfe0f, 0x940a, 1, OP_AVR1, "1001 010d dddd 1010", OTY_ALBI|OTY_RALL, - "dec", "Rd", "Decrement", "Rd <-- Rd - 1", "---SVNZ-", + "dec", "Rd", "decrement", "Rd <-- Rd - 1", "---SVNZ-", {"1", "1", "1", "1"}, ""}, {OP_ID(mul), 0xfc00, 0x9c00, 1, OP_AVR4, "1001 11rd dddd rrrr", OTY_ALBI|OTY_RALL, - "mul", "Rd, Rr", "Multiply Unsigned", "R1:R0 <-- Rd x Rr (UU)", "------ZC", + "mul", "Rd, Rr", "multiply unsigned", "R1:R0 <-- Rd x Rr (UU)", "------ZC", {"2", "2", "2", "n/a"}, ""}, {OP_ID(muls), 0xff00, 0x0200, 1, OP_AVR4, "0000 0010 dddd rrrr", OTY_ALBI|OTY_RUPP, - "muls", "Rd, Rr", "Multiply Signed", "R1:R0 <-- Rd x Rr (SS)", "------ZC", + "muls", "Rd, Rr", "multiply signed", "R1:R0 <-- Rd x Rr (SS)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..31"}, {OP_ID(mulsu), 0xff88, 0x0300, 1, OP_AVR4, "0000 0011 0ddd 0rrr", OTY_ALBI|OTY_RUPP, - "mulsu", "Rd, Rr", "Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr (SU)", "------ZC", + "mulsu", "Rd, Rr", "multiply signed with unsigned", "R1:R0 <-- Rd x Rr (SU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {OP_ID(fmul), 0xff88, 0x0308, 1, OP_AVR4, "0000 0011 0ddd 1rrr", OTY_ALBI|OTY_RUPP, - "fmul", "Rd, Rr", "Fractional Multiply Unsigned", "R1:R0 <-- Rd x Rr<<1 (UU)", "------ZC", + "fmul", "Rd, Rr", "fractional multiply unsigned", "R1:R0 <-- Rd x Rr << 1 (UU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {OP_ID(fmuls), 0xff88, 0x0380, 1, OP_AVR4, "0000 0011 1ddd 0rrr", OTY_ALBI|OTY_RUPP, - "fmuls", "Rd, Rr", "Fractional Multiply Signed", "R1:R0 <-- Rd x Rr<<1 (SS)", "------ZC", + "fmuls", "Rd, Rr", "fractional multiply signed", "R1:R0 <-- Rd x Rr << 1 (SS)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {OP_ID(fmulsu), 0xff88, 0x0388, 1, OP_AVR4, "0000 0011 1ddd 1rrr", OTY_ALBI|OTY_RUPP, - "fmulsu", "Rd, Rr", "Fractional Multiply Signed with Unsigned", "R1:R0 <-- Rd x Rr<<1 (SU)", "------ZC", + "fmulsu", "Rd, Rr", "fractional multiply signed with unsigned", "R1:R0 <-- Rd x Rr << 1 (SU)", "------ZC", {"2", "2", "2", "n/a"}, "d, r = 16..23"}, {OP_ID(des), 0xff0f, 0x940b, 1, OP_AVR_XM, "1001 0100 KKKK 1011", OTY_ALBI, - "des", "K", "Data Encryption", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "--------", + "des", "K", "data encryption round", "if (H = 0) then R15:R0 <-- Encrypt(R15:R0, K) if (H = 1) then R15:R0 <-- Decrypt(R15:R0, K)", "--------", {"n/a", "1/2", "n/a", "n/a"}, ""}, // Branch Instructions (and compare) {OP_ID(rjmp), 0xf000, 0xc000, 1, OP_AVR1, "1100 kkkk kkkk kkkk", OTY_RJMI, - "rjmp", "k", "Relative Jump", "PC <-- PC + k + 1", "--------", + "rjmp", "k", "relative jump", "PC <-- PC + k + 1", "--------", {"2", "2", "2", "2"}, ""}, {OP_ID(ijmp), 0xffff, 0x9409, 1, OP_AVR2, "1001 0100 0000 1001", OTY_JMPI, - "ijmp", "", "Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", + "ijmp", "", "indirect jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, ""}, {OP_ID(eijmp), 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, - "eijmp", "", "Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", + "eijmp", "", "extended indirect jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, ""}, {OP_ID(jmp), 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, - "jmp", "k", "Jump", "PC <-- k", "--------", + "jmp", "k", "jump", "PC <-- k", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(rcall), 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, - "rcall", "k", "Relative Call Subroutine", "PC <-- PC + k + 1", "--------", + "rcall", "k", "relative call subroutine", "PC <-- PC + k + 1", "--------", {"3+", "2+", "2+", "3"}, ""}, {OP_ID(icall), 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPI, - "icall", "", "Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", + "icall", "", "indirect call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3+", "2+", "2+", "3"}, ""}, {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, - "eicall", "", "Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", + "eicall", "", "extended indirect call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, ""}, {OP_ID(call), 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, - "call", "k", "call Subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "--------", + "call", "k", "call subroutine", "PC <-- k, STACK <-- PC, SP <-- SP - 2", "--------", {"4+", "3+", "3+", "n/a"}, ""}, {OP_ID(ret), 0xffff, 0x9508, 1, OP_AVR1, "1001 0101 0000 1000", OTY_JMPX, - "ret", "", "Subroutine Return", "PC <-- STACK", "--------", + "ret", "", "subroutine return", "SP <-- SP + 2, PC <-- STACK", "--------", {"4+", "4+", "4+", "6"}, ""}, {OP_ID(reti), 0xffff, 0x9518, 1, OP_AVR1, "1001 0101 0001 1000", OTY_JMPX, - "reti", "", "Interrupt Return", "PC <-- STACK", "I-------", + "reti", "", "interrupt return", "SP <-- SP + 2, PC <-- STACK", "I-------", {"4+", "4+", "4+", "6"}, ""}, {OP_ID(cpse), 0xfc00, 0x1000, 1, OP_AVR1, "0001 00rd dddd rrrr", OTY_SKPI|OTY_RALL, - "cpse", "Rd, Rr", "Compare, Skip if Equal", "if(Rd=Rr) PC <-- PC + 2/3", "--------", + "cpse", "Rd, Rr", "compare and skip if equal", "if(Rd=Rr) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, {OP_ID(cp), 0xfc00, 0x1400, 1, OP_AVR1, "0001 01rd dddd rrrr", OTY_ALBI|OTY_RALL, - "cp", "Rd, Rr", "Compare", "Rd - Rr", "--HSVNZC", + "cp", "Rd, Rr", "compare", "Rd - Rr", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(cpc), 0xfc00, 0x0400, 1, OP_AVR1, "0000 01rd dddd rrrr", OTY_ALBI|OTY_RALL, - "cpc", "Rd, Rr", "Compare with Carry", "Rd - Rr - C", "--HSVNZC", + "cpc", "Rd, Rr", "compare with carry", "Rd - Rr - C", "--HSVNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(cpi), 0xf000, 0x3000, 1, OP_AVR1, "0011 KKKK dddd KKKK", OTY_ALBI|OTY_RUPP, - "cpi", "Rd, K", "Compare with Immediate", "Rd - K", "--HSVNZC", + "cpi", "Rd, K", "compare with immediate", "Rd - K", "--HSVNZC", {"1", "1", "1", "1"}, "d = 16..31"}, {OP_ID(sbrc), 0xfe08, 0xfc00, 1, OP_AVR1, "1111 110r rrrr 0bbb", OTY_SKPI|OTY_RALL, - "sbrc", "Rr, b", "Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "--------", + "sbrc", "Rr, b", "skip if bit in register cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, {OP_ID(sbrs), 0xfe08, 0xfe00, 1, OP_AVR1, "1111 111r rrrr 0bbb", OTY_SKPI|OTY_RALL, - "sbrs", "Rr, b", "Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", + "sbrs", "Rr, b", "skip if bit in register set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, {OP_ID(sbic), 0xff00, 0x9900, 1, OP_AVR1, "1001 1001 AAAA Abbb", OTY_SKPX, - "sbic", "A, b", "Skip if Bit in I/O Register Cleared", "if(I/O(A,b)=0) PC <-- PC + 2/3", "--------", + "sbic", "A, b", "skip if bit in I/O register cleared", "if(I/O(A,b)=0) PC <-- PC + 2/3", "--------", {"1-3", "2-4", "1-3", "1/2"}, ""}, {OP_ID(sbis), 0xff00, 0x9b00, 1, OP_AVR1, "1001 1011 AAAA Abbb", OTY_SKPX, - "sbis", "A, b", "Skip if Bit in I/O Register Set", "If(I/O(A,b)=1) PC <-- PC + 2/3", "--------", + "sbis", "A, b", "skip if bit in I/O register set", "If(I/O(A,b)=1) PC <-- PC + 2/3", "--------", {"1-3", "2-4", "1-3", "1/2"}, ""}, {OP_ID(brcs), 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI, - "brcs", "k", "Branch if Carry Set", "if(C=1) then PC <-- PC + k + 1", "--------", + "brcs", "k", "branch if carry set", "if(C=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, {OP_ID(brlo), 0xfc07, 0xf000, 1, OP_AVR1, "1111 00kk kkkk k000", OTY_BRAI|OTY_ALIAS, - "brlo", "k", "Branch if Lower", "if(C=1) then PC <-- PC + k + 1", "--------", + "brlo", "k", "branch if lower", "if(C=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 0, k (C Carry)"}, {OP_ID(breq), 0xfc07, 0xf001, 1, OP_AVR1, "1111 00kk kkkk k001", OTY_BRAI, - "breq", "k", "Branch if Equal", "if(Z=1) then PC <-- PC + k + 1", "--------", + "breq", "k", "branch if equal", "if(Z=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 1, k (Z Zero)"}, {OP_ID(brmi), 0xfc07, 0xf002, 1, OP_AVR1, "1111 00kk kkkk k010", OTY_BRAI, - "brmi", "k", "Branch if Minus", "if(N=1) then PC <-- PC + k + 1", "--------", + "brmi", "k", "branch if minus", "if(N=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 2, k (N Negative)"}, {OP_ID(brvs), 0xfc07, 0xf003, 1, OP_AVR1, "1111 00kk kkkk k011", OTY_BRAI, - "brvs", "k", "Branch if Overflow Flag is Set", "if(V=1) then PC <-- PC + k + 1", "--------", + "brvs", "k", "branch if overflow flag is set", "if(V=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 3, k (V Overflow in two's complement)"}, {OP_ID(brlt), 0xfc07, 0xf004, 1, OP_AVR1, "1111 00kk kkkk k100", OTY_BRAI, - "brlt", "k", "Branch if Less Than, Signed", "if(N^V=1) then PC <-- PC + k + 1", "--------", + "brlt", "k", "branch if less than (signed)", "if(N^V=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 4, k (S Sign)"}, {OP_ID(brhs), 0xfc07, 0xf005, 1, OP_AVR1, "1111 00kk kkkk k101", OTY_BRAI, - "brhs", "k", "Branch if Half Carry Flag Set", "if(H=1) then PC <-- PC + k + 1", "--------", + "brhs", "k", "branch if half-carry flag set", "if(H=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 5, k (H Half carry)"}, {OP_ID(brts), 0xfc07, 0xf006, 1, OP_AVR1, "1111 00kk kkkk k110", OTY_BRAI, - "brts", "k", "Branch if T Flag Set", "if(T=1) then PC <-- PC + k + 1", "--------", + "brts", "k", "branch if T flag set", "if(T=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 6, k (T Transfer bit)"}, {OP_ID(brie), 0xfc07, 0xf007, 1, OP_AVR1, "1111 00kk kkkk k111", OTY_BRAI, - "brie", "k", "Branch if Interrupt Enabled", "if(I=1) then PC <-- PC + k + 1", "--------", + "brie", "k", "branch if interrupt enabled", "if(I=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbs 7, k (I Interrupt enable)"}, {OP_ID(brbs), 0xfc00, 0xf000, 1, OP_AVR1, "1111 00kk kkkk ksss", OTY_BRAI, - "brbs", "s, k", "Branch if Status Flag Set", "if(SREG(s)=1) then PC <-- PC + k + 1", "--------", + "brbs", "s, k", "branch if status flag set", "if(SREG(s)=1) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, ""}, {OP_ID(brcc), 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI, - "brcc", "k", "Branch if Carry Cleared", "if(C=0) then PC <-- PC + k + 1", "--------", + "brcc", "k", "branch if carry cleared", "if(C=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, {OP_ID(brsh), 0xfc07, 0xf400, 1, OP_AVR1, "1111 01kk kkkk k000", OTY_BRAI|OTY_ALIAS, - "brsh", "k", "Branch if Same or Higher", "if(C=0) then PC <-- PC + k + 1", "--------", + "brsh", "k", "branch if same or higher", "if(C=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 0, k (C Carry)"}, {OP_ID(brne), 0xfc07, 0xf401, 1, OP_AVR1, "1111 01kk kkkk k001", OTY_BRAI, - "brne", "k", "Branch if Not Equal", "if(Z=0) then PC <-- PC + k + 1", "--------", + "brne", "k", "branch if not equal", "if(Z=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 1, k (Z Zero)"}, {OP_ID(brpl), 0xfc07, 0xf402, 1, OP_AVR1, "1111 01kk kkkk k010", OTY_BRAI, - "brpl", "k", "Branch if Plus", "if(N=0) then PC <-- PC + k + 1", "--------", + "brpl", "k", "branch if plus", "if(N=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 2, k (N Negative)"}, {OP_ID(brvc), 0xfc07, 0xf403, 1, OP_AVR1, "1111 01kk kkkk k011", OTY_BRAI, - "brvc", "k", "Branch if Overflow Flag is Cleared", "if(V=0) then PC <-- PC + k + 1", "--------", + "brvc", "k", "branch if overflow flag is cleared", "if(V=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 3, k (V Overflow in two's complement)"}, {OP_ID(brge), 0xfc07, 0xf404, 1, OP_AVR1, "1111 01kk kkkk k100", OTY_BRAI, - "brge", "k", "Branch if Greater or Equal, Signed", "if(N^V=0) then PC <-- PC + k + 1", "--------", + "brge", "k", "branch if greater or equal (signed)", "if(N^V=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 4, k (S Sign)"}, {OP_ID(brhc), 0xfc07, 0xf405, 1, OP_AVR1, "1111 01kk kkkk k101", OTY_BRAI, - "brhc", "k", "Branch if Half Carry Flag Cleared", "if(H=0) then PC <-- PC + k + 1", "--------", + "brhc", "k", "branch if half-carry flag cleared", "if(H=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 5, k (H Half carry)"}, {OP_ID(brtc), 0xfc07, 0xf406, 1, OP_AVR1, "1111 01kk kkkk k110", OTY_BRAI, - "brtc", "k", "Branch if T Flag Cleared", "if(T=0) then PC <-- PC + k + 1", "--------", + "brtc", "k", "branch if T flag cleared", "if(T=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 6, k (T Transfer bit)"}, {OP_ID(brid), 0xfc07, 0xf407, 1, OP_AVR1, "1111 01kk kkkk k111", OTY_BRAI, - "brid", "k", "Branch if Interrupt Disabled", "if(I=0) then PC <-- PC + k + 1", "--------", + "brid", "k", "branch if interrupt disabled", "if(I=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, "alias for brbc 7, k (I Interrupt enable)"}, {OP_ID(brbc), 0xfc00, 0xf400, 1, OP_AVR1, "1111 01kk kkkk ksss", OTY_BRAI, - "brbc", "s, k", "Branch if Status Flag Cleared", "if(SREG(s)=0) then PC <-- PC + k + 1", "--------", + "brbc", "s, k", "branch if status flag cleared", "if(SREG(s)=0) then PC <-- PC + k + 1", "--------", {"1/2", "1/2", "1/2", "1/2"}, ""}, // Data Transfer Instructions {OP_ID(mov), 0xfc00, 0x2c00, 1, OP_AVR1, "0010 11rd dddd rrrr", OTY_XFRI|OTY_RALL, - "mov", "Rd, Rr", "Copy Register", "Rd <-- Rr", "--------", + "mov", "Rd, Rr", "copy register", "Rd <-- Rr", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(movw), 0xff00, 0x0100, 1, OP_AVR25, "0000 0001 dddd rrrr", OTY_XFRI|OTY_REVN, - "movw", "Rd, Rr", "Copy Register Pair", "Rd+1:Rd <-- Rr+1:Rr", "--------", + "movw", "Rd, Rr", "copy register pair", "Rd+1:Rd <-- Rr+1:Rr", "--------", {"1", "1", "1", "n/a"}, "d, r in {0, 2, ..., 30}"}, {OP_ID(ser), 0xff0f, 0xef0f, 1, OP_AVR1, "1110 1111 dddd 1111", OTY_ALBI|OTY_RUPP, - "ser", "Rd", "Set Register", "Rd <-- 0xff", "--------", + "ser", "Rd", "set register", "Rd <-- 0xff", "--------", {"1", "1", "1", "1"}, "alias for ldi Rd, 0xff; d = 16..31"}, {OP_ID(ldi), 0xf000, 0xe000, 1, OP_AVR1, "1110 KKKK dddd KKKK", OTY_XFRI|OTY_RUPP, - "ldi", "Rd, K", "Load Immediate", "Rd <-- K", "--------", + "ldi", "Rd, K", "load immediate", "Rd <-- K", "--------", {"1", "1", "1", "1"}, "d = 16..31"}, {OP_ID(lds), 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, - "lds", "Rd, k", "Load Direct from data space", "Rd <-- (k)", "--------", + "lds", "Rd, k", "load direct from data space", "Rd <-- (k)", "--------", {"2", "3", "3", "2"}, ""}, {OP_ID(ld_1), 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, - "ld", "Rd, X", "Load Indirect", "Rd <-- (X)", "--------", + "ld", "Rd, X", "load indirect", "Rd <-- (X)", "--------", {"2", "2", "2", "1/2"}, ""}, {OP_ID(ld_2), 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL|OTY_XWRN, - "ld", "Rd, X+", "Load Indirect and Post-Increment", "Rd <-- (X), X <-- X + 1", "--------", + "ld", "Rd, X+", "load indirect and post-increment", "Rd <-- (X), X <-- X + 1", "--------", {"2", "2", "2", "2/3"}, ""}, {OP_ID(ld_3), 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL|OTY_XWRN, - "ld", "Rd, -X", "Load Indirect and Pre-Decrement", "X <-- X - 1, Rd <-- (X)", "--------", + "ld", "Rd, -X", "load indirect and pre-decrement", "X <-- X - 1, Rd <-- (X)", "--------", {"2", "3", "2", "2/3"}, ""}, {OP_ID(ld_4), 0xfe0f, 0x8008, 1, OP_AVR2, "1000 000d dddd 1000", OTY_XFRX|OTY_RALL, - "ld", "Rd, Y", "Load Indirect", "Rd <-- (Y) <-- (Y)", "--------", + "ld", "Rd, Y", "load indirect", "Rd <-- (Y) <-- (Y)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Y+0"}, {OP_ID(ld_5), 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL|OTY_YWRN, - "ld", "Rd, Y+", "Load Indirect and Post-Increment", "Rd <-- (Y), Y <-- Y + 1", "--------", + "ld", "Rd, Y+", "load indirect and post-increment", "Rd <-- (Y), Y <-- Y + 1", "--------", {"2", "2", "2", "2/3"}, ""}, {OP_ID(ld_6), 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL|OTY_YWRN, - "ld", "Rd, -Y", "Load Indirect and Pre-Decrement", "Y <-- Y - 1 Rd <-- (Y)", "--------", + "ld", "Rd, -Y", "load indirect and pre-decrement", "Y <-- Y - 1 Rd <-- (Y)", "--------", {"2", "3", "2", "2/3"}, ""}, {OP_ID(ldd_1), 0xd208, 0x8008, 1, OP_AVR2nRC, "10q0 qq0d dddd 1qqq", OTY_XFRX|OTY_RALL, - "ldd", "Rd, Y+q", "Load Indirect with Displacement", "Rd <-- (Y+q)", "--------", + "ldd", "Rd, Y+q", "load indirect with displacement", "Rd <-- (Y+q)", "--------", {"2", "3", "2", "n/a"}, ""}, {OP_ID(ld_7), 0xfe0f, 0x8000, 1, OP_AVR1, "1000 000d dddd 0000", OTY_XFRX|OTY_RALL, - "ld", "Rd, Z", "Load Indirect", "Rd <-- (Z)", "--------", + "ld", "Rd, Z", "load indirect", "Rd <-- (Z)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Z+0"}, {OP_ID(ld_8), 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL|OTY_ZWRN, - "ld", "Rd, Z+", "Load Indirect and Post-Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", + "ld", "Rd, Z+", "load indirect and post-increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"2", "2", "2", "2/3"}, ""}, {OP_ID(ld_9), 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL|OTY_ZWRN, - "ld", "Rd, -Z", "Load Indirect and Pre-Decrement", "Z <-- Z - 1, Rd <-- (Z)", "--------", + "ld", "Rd, -Z", "load indirect and pre-decrement", "Z <-- Z - 1, Rd <-- (Z)", "--------", {"2", "3", "2", "2/3"}, ""}, {OP_ID(ldd_2), 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, - "ldd", "Rd, Z+q", "Load Indirect with Displacement", "Rd <-- (Z+q)", "--------", + "ldd", "Rd, Z+q", "load indirect with displacement", "Rd <-- (Z+q)", "--------", {"2", "3", "2", "n/a"}, ""}, {OP_ID(sts), 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, - "sts", "k, Rr", "Store Direct to Data Space", "(k) <-- Rr", "--------", + "sts", "k, Rr", "store direct to data space", "(k) <-- Rr", "--------", {"2", "2", "2", "1"}, ""}, {OP_ID(st_1), 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, - "st", "X, Rr", "Store Indirect", "(X) <-- Rr", "--------", + "st", "X, Rr", "store indirect", "(X) <-- Rr", "--------", {"2", "1", "1", "1"}, ""}, {OP_ID(st_2), 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL|OTY_XWRN, - "st", "X+, Rr", "Store Indirect and Post-Increment", "(X) <-- Rr, X <-- X + 1", "--------", + "st", "X+, Rr", "store indirect and post-increment", "(X) <-- Rr, X <-- X + 1", "--------", {"2", "1", "1", "1"}, ""}, {OP_ID(st_3), 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL|OTY_XWRN, - "st", "-X, Rr", "Store Indirect and Pre-Decrement", "X <-- X - 1, (X) <-- Rr", "--------", + "st", "-X, Rr", "store indirect and pre-decrement", "X <-- X - 1, (X) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OP_ID(st_4), 0xfe0f, 0x8208, 1, OP_AVR2, "1000 001r rrrr 1000", OTY_XFRX|OTY_RALL, - "st", "Y, Rr", "Store Indirect", "(Y) <-- Rr", "--------", + "st", "Y, Rr", "store indirect", "(Y) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Y+0, Rr"}, {OP_ID(st_5), 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL|OTY_YWRN, - "st", "Y+, Rr", "Store Indirect and Post-Increment", "(Y) <-- Rr, Y <-- Y + 1", "--------", + "st", "Y+, Rr", "store indirect and post-increment", "(Y) <-- Rr, Y <-- Y + 1", "--------", {"2", "1", "1", "1"}, ""}, {OP_ID(st_6), 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL|OTY_YWRN, - "st", "-Y, Rr", "Store Indirect and Pre-Decrement", "Y <-- Y - 1, (Y) <-- Rr", "--------", + "st", "-Y, Rr", "store indirect and pre-decrement", "Y <-- Y - 1, (Y) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OP_ID(std_1), 0xd208, 0x8208, 1, OP_AVR2nRC, "10q0 qq1r rrrr 1qqq", OTY_XFRX|OTY_RALL, - "std", "Y+q, Rr", "Store Indirect with Displacement", "(Y+q) <-- Rr", "--------", + "std", "Y+q, Rr", "store indirect with displacement", "(Y+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, {OP_ID(st_7), 0xfe0f, 0x8200, 1, OP_AVR1, "1000 001r rrrr 0000", OTY_XFRX|OTY_RALL, - "st", "Z, Rr", "Store Indirect", "(Z) <-- Rr", "--------", + "st", "Z, Rr", "store indirect", "(Z) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Z+0, Rr"}, {OP_ID(st_8), 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL|OTY_ZWRN, - "st", "Z+, Rr", "Store Indirect and Post-Increment", "(Z) <-- Rr, Z <-- Z + 1", "--------", + "st", "Z+, Rr", "store indirect and post-increment", "(Z) <-- Rr, Z <-- Z + 1", "--------", {"2", "1", "1", "1"}, ""}, {OP_ID(st_9), 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL|OTY_ZWRN, - "st", "-Z, Rr", "Store Indirect and Pre-Decrement", "Z <-- Z - 1, (Z) <-- Rr", "--------", + "st", "-Z, Rr", "store indirect and pre-decrement", "Z <-- Z - 1, (Z) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, {OP_ID(std_2), 0xd208, 0x8200, 1, OP_AVR2nRC, "10q0 qq1r rrrr 0qqq", OTY_XFRX|OTY_RALL, - "std", "Z+q, Rr", "Store Indirect with Displacement", "(Z+q) <-- Rr", "--------", + "std", "Z+q, Rr", "store indirect with displacement", "(Z+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, {OP_ID(lpm_1), 0xffff, 0x95c8, 1, OP_AVR1nRC, "1001 0101 1100 1000", OTY_XFRX, - "lpm", "", "Load Program Memory", "R0 <-- (Z)", "--------", + "lpm", "", "load program memory", "R0 <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(lpm_2), 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, - "lpm", "Rd, Z", "Load Program Memory", "Rd <-- (Z)", "--------", + "lpm", "Rd, Z", "load program memory", "Rd <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(lpm_3), 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL|OTY_ZWRN, - "lpm", "Rd, Z+", "Load Program Memory and Post- Increment", "Rd <-- (Z), Z <-- Z + 1", "--------", + "lpm", "Rd, Z+", "load program memory and post-increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(elpm_1), 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, - "elpm", "", "Extended Load Program Memory", "R0 <-- (RAMPZ:Z)", "--------", + "elpm", "", "extended load program memory", "R0 <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(elpm_2), 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, - "elpm", "Rd, Z", "Extended Load Program Memory", "Rd <-- (RAMPZ:Z)", "--------", + "elpm", "Rd, Z", "extended load program memory", "Rd <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(elpm_3), 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL|OTY_ZWRN, - "elpm", "Rd, Z+", "Extended Load Program Memory and Post-Increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "--------", + "elpm", "Rd, Z+", "extended load program memory and post-increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(spm), 0xffff, 0x95e8, 1, OP_AVR25, "1001 0101 1110 1000", OTY_XFRX, - "spm", "", "Store Program Memory", "(RAMPZ:Z) <-- R1:R0", "--------", + "spm", "", "store program memory", "(RAMPZ:Z) <-- R1:R0", "--------", {"-", "-", "-", "-"}, ""}, {OP_ID(spm_zz), 0xffff, 0x95f8, 1, OP_AVR_XTM, "1001 0101 1111 1000", OTY_XFRX, - "spm", "Z+", "Store Program Memory and Post-Increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z + 2", "--------", + "spm", "Z+", "store program memory and post-increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z + 2", "--------", {"n/a", "-", "-", "n/a"}, ""}, {OP_ID(in), 0xf800, 0xb000, 1, OP_AVR1, "1011 0AAd dddd AAAA", OTY_XFRX|OTY_RALL, - "in", "Rd, A", "In from I/O Location", "Rd <-- I/O(A)", "--------", + "in", "Rd, A", "in from I/O location", "Rd <-- I/O(A)", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(out), 0xf800, 0xb800, 1, OP_AVR1, "1011 1AAr rrrr AAAA", OTY_XFRX|OTY_RALL, - "out", "A, Rr", "Out to I/O Location", "I/O(A) <-- Rr", "--------", + "out", "A, Rr", "out to I/O location", "I/O(A) <-- Rr", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(push), 0xfe0f, 0x920f, 1, OP_AVR2, "1001 001r rrrr 1111", OTY_XFRX|OTY_RALL, - "push", "Rr", "Push Register on Stack", "STACK <-- Rr", "--------", + "push", "Rr", "push register on stack", "STACK <-- Rr, SP <-- SP - 2", "--------", {"2", "1", "1", "1"}, ""}, {OP_ID(pop), 0xfe0f, 0x900f, 1, OP_AVR2, "1001 000d dddd 1111", OTY_XFRX|OTY_RALL, - "pop", "Rd", "Pop Register from Stack", "Rd <-- STACK", "--------", + "pop", "Rd", "pop register from stack", "SP <-- SP + 2, Rd <-- STACK", "--------", {"2", "2", "2", "3"}, ""}, {OP_ID(xch), 0xfe0f, 0x9204, 1, OP_AVR_XM, "1001 001d dddd 0100", OTY_XFRX|OTY_RALL, - "xch", "Z, Rd", "Exchange", "(Z) <-- Rd, Rd <-- (Z)", "--------", + "xch", "Z, Rd", "exchange", "(Z) <-- Rd, Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, {OP_ID(las), 0xfe0f, 0x9205, 1, OP_AVR_XM, "1001 001d dddd 0101", OTY_ALBX|OTY_RALL, - "las", "Z, Rd", "Load and Set", "(Z) <-- Rd | (Z), Rd <-- (Z)", "--------", + "las", "Z, Rd", "load and set", "(Z) <-- Rd | (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, {OP_ID(lac), 0xfe0f, 0x9206, 1, OP_AVR_XM, "1001 001d dddd 0110", OTY_ALBX|OTY_RALL, - "lac", "Z, Rd", "Load and Clear", "(Z) <-- (0xff - Rd) & (Z), Rd <-- (Z)", "--------", + "lac", "Z, Rd", "load and clear", "(Z) <-- (0xff - Rd) & (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, {OP_ID(lat), 0xfe0f, 0x9207, 1, OP_AVR_XM, "1001 001d dddd 0111", OTY_ALBX|OTY_RALL, - "lat", "Z, Rd", "Load and Toggle", "(Z) <-- Rd ^ (Z), Rd <-- (Z)", "--------", + "lat", "Z, Rd", "load and toggle", "(Z) <-- Rd ^ (Z), Rd <-- (Z)", "--------", {"n/a", "1", "n/a", "n/a"}, ""}, // Bit and Bit-test Instructions {OP_ID(lsr), 0xfe0f, 0x9406, 1, OP_AVR1, "1001 010d dddd 0110", OTY_ALBI|OTY_RALL, - "lsr", "Rd", "Logical Shift Right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", + "lsr", "Rd", "logical shift right", "0 --> Rd(7) --> Rd(6) ... Rd(1) --> Rd(0) --> C", "----VNZC", {"1", "1", "1", "1"}, ""}, {OP_ID(swap), 0xfe0f, 0x9402, 1, OP_AVR1, "1001 010d dddd 0010", OTY_ALBI|OTY_RALL, - "swap", "Rd", "Swap Nibbles", "Rd(3..0) <--> Rd(7..4)", "--------", + "swap", "Rd", "swap nibbles", "Rd(3..0) <--> Rd(7..4)", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(sbi), 0xff00, 0x9a00, 1, OP_AVR1, "1001 1010 AAAA Abbb", OTY_ALBX, - "sbi", "A, b", "Set Bit in I/O Register", "I/O(A,b) <-- 1", "--------", + "sbi", "A, b", "set bit in I/O register", "I/O(A,b) <-- 1", "--------", {"2", "1", "1", "1"}, ""}, {OP_ID(cbi), 0xff00, 0x9800, 1, OP_AVR1, "1001 1000 AAAA Abbb", OTY_ALBX, - "cbi", "A, b", "Clear Bit in I/O Register", "I/O(A,b) <-- 0", "--------", + "cbi", "A, b", "clear bit in I/O register", "I/O(A,b) <-- 0", "--------", {"2", "1", "1", "1"}, ""}, {OP_ID(bst), 0xfe08, 0xfa00, 1, OP_AVR1, "1111 101r rrrr 0bbb", OTY_ALBI|OTY_RALL, - "bst", "Rr, b", "Bit Store from Register to T", "T <-- Rr(b)", "-T------", + "bst", "Rr, b", "bit store from register to T", "T <-- Rr(b)", "-T------", {"1", "1", "1", "1"}, ""}, {OP_ID(bld), 0xfe08, 0xf800, 1, OP_AVR1, "1111 100d dddd 0bbb", OTY_ALBI|OTY_RALL, - "bld", "Rd, b", "Bit load from T to Register", "Rd(b) <-- T", "--------", + "bld", "Rd, b", "bit load from T to register", "Rd(b) <-- T", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(sec), 0xffff, 0x9408, 1, OP_AVR1, "1001 0100 0000 1000", OTY_ALBI, - "sec", "", "Set Carry", "C <-- 1", "-------C", + "sec", "", "set carry", "C <-- 1", "-------C", {"1", "1", "1", "1"}, "alias for bset 0"}, {OP_ID(clc), 0xffff, 0x9488, 1, OP_AVR1, "1001 0100 1000 1000", OTY_ALBI, - "clc", "", "Clear Carry", "C <-- 0", "-------C", + "clc", "", "clear carry", "C <-- 0", "-------C", {"1", "1", "1", "1"}, "alias for bclr 0"}, {OP_ID(sen), 0xffff, 0x9428, 1, OP_AVR1, "1001 0100 0010 1000", OTY_ALBI, - "sen", "", "Set Negative Flag", "N <-- 1", "-----N--", + "sen", "", "set negative flag", "N <-- 1", "-----N--", {"1", "1", "1", "1"}, "alias for bset 2"}, {OP_ID(cln), 0xffff, 0x94a8, 1, OP_AVR1, "1001 0100 1010 1000", OTY_ALBI, - "cln", "", "Clear Negative Flag", "N <-- 0", "-----N--", + "cln", "", "clear negative flag", "N <-- 0", "-----N--", {"1", "1", "1", "1"}, "alias for bclr 2"}, {OP_ID(sez), 0xffff, 0x9418, 1, OP_AVR1, "1001 0100 0001 1000", OTY_ALBI, - "sez", "", "Set Zero Flag", "Z <-- 1", "------Z-", + "sez", "", "set zero flag", "Z <-- 1", "------Z-", {"1", "1", "1", "1"}, "alias for bset 1"}, {OP_ID(clz), 0xffff, 0x9498, 1, OP_AVR1, "1001 0100 1001 1000", OTY_ALBI, - "clz", "", "Clear Zero Flag", "Z <-- 0", "------Z-", + "clz", "", "clear zero flag", "Z <-- 0", "------Z-", {"1", "1", "1", "1"}, "alias for bclr 1"}, {OP_ID(sei), 0xffff, 0x9478, 1, OP_AVR1, "1001 0100 0111 1000", OTY_ALBX, - "sei", "", "Global Interrupt Enable", "I <-- 1", "I-------", + "sei", "", "global interrupt enable", "I <-- 1", "I-------", {"1", "1", "1", "1"}, "alias for bset 7"}, {OP_ID(cli), 0xffff, 0x94f8, 1, OP_AVR1, "1001 0100 1111 1000", OTY_ALBI, - "cli", "", "Global Interrupt Disable", "I <-- 0", "I-------", + "cli", "", "global interrupt disable", "I <-- 0", "I-------", {"1", "1", "1", "1"}, "alias for bclr 7"}, {OP_ID(ses), 0xffff, 0x9448, 1, OP_AVR1, "1001 0100 0100 1000", OTY_ALBI, - "ses", "", "Set Signed Test Flag", "S <-- 1", "---S----", + "ses", "", "set signed test flag", "S <-- 1", "---S----", {"1", "1", "1", "1"}, "alias for bset 4"}, {OP_ID(cls), 0xffff, 0x94c8, 1, OP_AVR1, "1001 0100 1100 1000", OTY_ALBI, - "cls", "", "Clear Signed Test Flag", "S <-- 0", "---S----", + "cls", "", "clear signed test flag", "S <-- 0", "---S----", {"1", "1", "1", "1"}, "alias for bclr 4"}, {OP_ID(sev), 0xffff, 0x9438, 1, OP_AVR1, "1001 0100 0011 1000", OTY_ALBI, - "sev", "", "Set Two's Complement Overflow", "V <-- 1", "----V---", + "sev", "", "set two's complement overflow", "V <-- 1", "----V---", {"1", "1", "1", "1"}, "alias for bset 3"}, {OP_ID(clv), 0xffff, 0x94b8, 1, OP_AVR1, "1001 0100 1011 1000", OTY_ALBI, - "clv", "", "Clear Two's Complement Overflow", "V <-- 0", "----V---", + "clv", "", "clear two's complement overflow", "V <-- 0", "----V---", {"1", "1", "1", "1"}, "alias for bclr 3"}, {OP_ID(set), 0xffff, 0x9468, 1, OP_AVR1, "1001 0100 0110 1000", OTY_ALBI, - "set", "", "Set T in SREG", "T <-- 1", "-T------", + "set", "", "set T in sreg", "T <-- 1", "-T------", {"1", "1", "1", "1"}, "alias for bset 6"}, {OP_ID(clt), 0xffff, 0x94e8, 1, OP_AVR1, "1001 0100 1110 1000", OTY_ALBI, - "clt", "", "Clear T in SREG", "T <-- 0", "-T------", + "clt", "", "clear T in sreg", "T <-- 0", "-T------", {"1", "1", "1", "1"}, "alias for bclr 6"}, {OP_ID(seh), 0xffff, 0x9458, 1, OP_AVR1, "1001 0100 0101 1000", OTY_ALBI, - "seh", "", "Set Half Carry Flag in SREG", "H <-- 1", "--H-----", + "seh", "", "set half-carry flag in sreg", "H <-- 1", "--H-----", {"1", "1", "1", "1"}, "alias for bset 5"}, {OP_ID(clh), 0xffff, 0x94d8, 1, OP_AVR1, "1001 0100 1101 1000", OTY_ALBI, - "clh", "", "Clear Half Carry Flag in SREG", "H <-- 0", "--H-----", + "clh", "", "clear half-carry flag in sreg", "H <-- 0", "--H-----", {"1", "1", "1", "1"}, "alias for bclr 5"}, {OP_ID(bset), 0xff8f, 0x9408, 1, OP_AVR1, "1001 0100 0sss 1000", OTY_ALBX, - "bset", "s", "Flag Set", "SREG(s) <-- 1", "SREG-bit", + "bset", "s", "flag set", "SREG(s) <-- 1", "SREG-bit", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, {OP_ID(bclr), 0xff8f, 0x9488, 1, OP_AVR1, "1001 0100 1sss 1000", OTY_ALBI, - "bclr", "s", "Flag Clear", "SREG(s) <-- 0", "SREG-bit", + "bclr", "s", "flag clear", "SREG(s) <-- 0", "SREG-bit", {"1", "1", "1", "1"}, "s = 0-7 = C,Z,N,V,S,H,T,I"}, // MCU Control Instructions {OP_ID(break), 0xffff, 0x9598, 1, OP_AVR1, "1001 0101 1001 1000", OTY_MCUX, - "break", "", "Break", "(cf documentation)", "--------", + "break", "", "break", "on-chip debug system breakpoint", "--------", {"-", "-", "-", "-"}, "not available on all parts"}, {OP_ID(nop), 0xffff, 0x0000, 1, OP_AVR1, "0000 0000 0000 0000", OTY_MCUI, - "nop", "", "No Operation", "-", "--------", + "nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(sleep), 0xffff, 0x9588, 1, OP_AVR1, "1001 0101 1000 1000", OTY_MCUX, - "sleep", "", "Sleep", "(cf documentation)", "--------", + "sleep", "", "sleep", "sleep mode defined by the MCU control register", "--------", {"-", "-", "-", "-"}, ""}, {OP_ID(wdr), 0xffff, 0x95a8, 1, OP_AVR1, "1001 0101 1010 1000", OTY_MCUI, - "wdr", "", "Watchdog Reset", "(cf documentation)", "--------", + "wdr", "", "watchdog reset", "reset the watchdog timer", "--------", {"1", "1", "1", "1"}, ""}, /* @@ -521,72 +521,72 @@ const AVR_opcode_data avr_opcodes[164] = { * regular ldd Rd, Y+q; ldd Rd, Z+q; std Y+q, Rr; std Z+q, Rr opcodes */ {OP_ID(lds_rc), 0xf800, 0xa000, 1, OP_AVR_RC, "1010 0aaa dddd aaaa", OTY_XFRX|OTY_RUPP, - "lds", "Rd, a", "Load Direct from data space", "Rd <-- (a)", "--------", + "lds", "Rd, a", "load direct from data space", "Rd <-- (a)", "--------", {"n/a", "n/a", "n/a", "2"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, {OP_ID(sts_rc), 0xf800, 0xa800, 1, OP_AVR_RC, "1010 1aaa rrrr aaaa", OTY_XFRX|OTY_RUPP, - "sts", "a, Rr", "Store Direct to Data Space", "(a) <-- Rr", "--------", + "sts", "a, Rr", "store direct to data space", "(a) <-- Rr", "--------", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, // Unallocated codes: they are said(!) to do the following {OP_ID(u_nop_1), 0xff00, 0x0000, 1, OP_AVR_ILL, "0000 0000 xxxx xxxx", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, {OP_ID(u_nop_2), 0xfe0f, 0x9003, 1, OP_AVR_ILL, "1001 000x xxxx 0011", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_3), 0xfe0f, 0x9008, 1, OP_AVR_ILL, "1001 000x xxxx 1000", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_4), 0xfe0f, 0x900b, 1, OP_AVR_ILL, "1001 000x xxxx 1011", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_5), 0xfe0f, 0x9203, 1, OP_AVR_ILL, "1001 001x xxxx 0011", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_6), 0xfe0f, 0x9208, 1, OP_AVR_ILL, "1001 001x xxxx 1000", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_7), 0xfe0f, 0x920b, 1, OP_AVR_ILL, "1001 001x xxxx 1011", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPI, - "u/icall", "", "alt Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", + "u/icall", "", "indirect call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3+", "2+", "2+", "3"}, "xxx != 000"}, {OP_ID(u_eicall), 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, - "u/eicall", "", "alt Extended Indirect Call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", + "u/eicall", "", "extended indirect call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, "xxx != 000"}, {OP_ID(u_ret), 0xff9f, 0x9508, 1, OP_AVR_ILL, "1001 0101 0xx0 1000", OTY_JMPX, - "u/ret", "", "alt Subroutine Return", "PC <-- STACK", "--------", + "u/ret", "", "subroutine return", "SP --> SP + 2, PC <-- STACK", "--------", {"4+", "4+", "4+", "6"}, "xx != 00"}, {OP_ID(u_reti), 0xff9f, 0x9518, 1, OP_AVR_ILL, "1001 0101 0xx1 1000", OTY_JMPX, - "u/reti", "", "alt Interrupt Return", "PC <-- STACK", "I-------", + "u/reti", "", "interrupt return", "SP -> SP + 2, PC <-- STACK", "I-------", {"4+", "4+", "4+", "6"}, "xx != 00"}, {OP_ID(u_nop_8), 0xffff, 0x95b8, 1, OP_AVR_ILL, "1001 0101 1011 1000", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_9), 0xfe0f, 0x9404, 1, OP_AVR_ILL, "1001 010x xxxx 0100", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_nop_a), 0xff0f, 0x950b, 1, OP_AVR_ILL, "1001 0101 xxxx 1011", OTY_MCUI, - "u/nop", "", "alt No Operation", "-", "--------", + "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_ijmp), 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI, - "u/ijmp", "", "alt Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", + "u/ijmp", "", "indirect jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, "xxx != 000"}, {OP_ID(u_eijmp), 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPI, - "u/eijmp", "", "alt Extended Indirect Jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", + "u/eijmp", "", "extended indirect jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, "xxx != 000"}, {OP_ID(u_bld), 0xfe08, 0xf808, 1, OP_AVR_ILL, "1111 100d dddd 1bbb", OTY_ALBI|OTY_RALL, - "u/bld", "Rd, b", "alt Bit load from T to Register", "Rd(b) <-- T", "--------", + "u/bld", "Rd, b", "bit load from T to register", "Rd(b) <-- T", "--------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_bst), 0xfe08, 0xfa08, 1, OP_AVR_ILL, "1111 101r rrrr 1bbb", OTY_ALBI|OTY_RALL, - "u/bst", "Rr, b", "alt Bit Store from Register to T", "T <-- Rr(b)", "-T------", + "u/bst", "Rr, b", "bit store from register to T", "T <-- Rr(b)", "-T------", {"1", "1", "1", "1"}, ""}, {OP_ID(u_sbrc), 0xfe08, 0xfc08, 1, OP_AVR_ILL, "1111 110r rrrr 1bbb", OTY_SKPI|OTY_RALL, - "u/sbrc", "Rr, b", "alt Skip if Bit in Register Cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "--------", + "u/sbrc", "Rr, b", "skip if bit in register cleared", "if(Rr(b)=0) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, {OP_ID(u_sbrs), 0xfe08, 0xfe08, 1, OP_AVR_ILL, "1111 111r rrrr 1bbb", OTY_SKPI|OTY_RALL, - "u/sbrs", "Rr, b", "alt Skip if Bit in Register Set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", + "u/sbrs", "Rr, b", "skip if bit in register set", "if(Rr(b)=1) PC <-- PC + 2/3", "--------", {"1-3", "1-3", "1-3", "1/2"}, ""}, }; diff --git a/src/disasm.c b/src/disasm.c index e29357e4..0e7ff593 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -846,6 +846,8 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, } c += strlen(c); } + if(cx->dis_opts.show_name) + add_comment(line, avr_opcodes[mnemo].description); // Trim trailing spaces while(--c >= line->code && *c == ' ') *c = 0; @@ -932,7 +934,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { if(!*line.comment || !cx->dis_opts.show_comments) term_out("%s\n", line.code); else - term_out("%-23s ; %s\n", line.code, line.comment); + term_out("%-30s ; %s\n", line.code, line.comment); if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) term_out("\n"); diff --git a/src/libavrdude.h b/src/libavrdude.h index 7f6f68e5..a9093db1 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1461,6 +1461,7 @@ typedef struct { int show_comments; int show_flags; int show_cycles; + int show_name; int avrgcc_style; int process_labels; int avrlevel; @@ -1611,7 +1612,7 @@ typedef struct { const char *opcode, // "add" *operands, // "Rd, Rr" - *description, // "Add without Carry" + *description, // "add without carry" *operation, // "Rd <-- Rd + Rr" *flags, // "--HSVNZC" *clock[OP_AVR_cycle_N], // Timings for AVRe, AVRxm, AVRxt and AVRrc diff --git a/src/term.c b/src/term.c index f5cf6ee5..cf86ac1d 100644 --- a/src/term.c +++ b/src/term.c @@ -214,13 +214,14 @@ static int hexdump_buf(const FILE *f, const AVRMEM *m, int startaddr, const unsi static int disasm_ison(char c) { switch(c) { - case 'a': return cx->dis_opts.show_addresses; - case 'o': return cx->dis_opts.show_opcodes; - case 'c': return cx->dis_opts.show_comments; - case 'f': return cx->dis_opts.show_flags; - case 'q': return cx->dis_opts.show_cycles; - case 's': return cx->dis_opts.avrgcc_style; - case 'l': return cx->dis_opts.process_labels; + case 'a': return !!cx->dis_opts.show_addresses; + case 'o': return !!cx->dis_opts.show_opcodes; + case 'c': return !!cx->dis_opts.show_comments; + case 'f': return !!cx->dis_opts.show_flags; + case 'q': return !!cx->dis_opts.show_cycles; + case 'n': return !!cx->dis_opts.show_name; + case 's': return !!cx->dis_opts.avrgcc_style; + case 'l': return !!cx->dis_opts.process_labels; case 'd': return cx->dis_opts.avrlevel == (PART_ALL | OP_AVR_ILL); } return 0; @@ -265,6 +266,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, {{'c', 'C'}, {"show comments", "don't show comments"}}, {{'f', 'F'}, {"show affected flags in SREG", "don't show SREG flags"}}, {{'q', 'Q'}, {"show cycles", "don't show cycles"}}, + {{'n', 'N'}, {"put opcode full name into comment", "don't show full name"}}, {{'s', 'S'}, {"use avr-gcc code style", "use AVR instruction set style"}}, {{'l', 'L'}, {"preprocess jump/call labels", "don't preprocess labels"}}, {{'d', 'D'}, {"decode all opcodes", "decode only opcodes for the part"}}, @@ -481,6 +483,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.show_comments = 1; cx->dis_opts.show_flags = 0; cx->dis_opts.show_cycles = 0; + cx->dis_opts.show_name = 0; cx->dis_opts.avrgcc_style = 1; cx->dis_opts.process_labels = 1; cx->dis_opts.tagfile = NULL; @@ -501,25 +504,28 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c help++; break; case 'a': case 'A': - cx->dis_opts.show_addresses = islower(chr); + cx->dis_opts.show_addresses = !!islower(chr); break; case 'o': case 'O': - cx->dis_opts.show_opcodes = islower(chr); + cx->dis_opts.show_opcodes = !!islower(chr); break; case 'c': case 'C': - cx->dis_opts.show_comments = islower(chr); + cx->dis_opts.show_comments = !!islower(chr); break; case 'f': case 'F': - cx->dis_opts.show_flags = islower(chr); + cx->dis_opts.show_flags = !!islower(chr); break; case 'q': case 'Q': - cx->dis_opts.show_cycles = islower(chr); + cx->dis_opts.show_cycles = !!islower(chr); + break; + case 'n': case 'N': + cx->dis_opts.show_name = !!islower(chr); break; case 's': case 'S': - cx->dis_opts.avrgcc_style = islower(chr); + cx->dis_opts.avrgcc_style = !!islower(chr); break; case 'l': case 'L': - cx->dis_opts.process_labels = islower(chr); + cx->dis_opts.process_labels = !!islower(chr); break; case 'z': disasm_zap_jumpcalls(); From 4526d330ea30c01eae3f529bbf2ac8155b3e55c5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Jul 2024 23:39:33 +0100 Subject: [PATCH 350/422] Provide disasm -e to show technical explanation in comment --- src/disasm.c | 4 +++- src/libavrdude.h | 1 + src/term.c | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/disasm.c b/src/disasm.c index 0e7ff593..acb82118 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -848,6 +848,8 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, } if(cx->dis_opts.show_name) add_comment(line, avr_opcodes[mnemo].description); + if(cx->dis_opts.show_explanation) + add_comment(line, avr_opcodes[mnemo].operation); // Trim trailing spaces while(--c >= line->code && *c == ' ') *c = 0; @@ -934,7 +936,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { if(!*line.comment || !cx->dis_opts.show_comments) term_out("%s\n", line.code); else - term_out("%-30s ; %s\n", line.code, line.comment); + term_out("%-27s ; %s\n", line.code, line.comment); if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) term_out("\n"); diff --git a/src/libavrdude.h b/src/libavrdude.h index a9093db1..aaef45de 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1462,6 +1462,7 @@ typedef struct { int show_flags; int show_cycles; int show_name; + int show_explanation; int avrgcc_style; int process_labels; int avrlevel; diff --git a/src/term.c b/src/term.c index cf86ac1d..1ad98a28 100644 --- a/src/term.c +++ b/src/term.c @@ -220,6 +220,7 @@ static int disasm_ison(char c) { case 'f': return !!cx->dis_opts.show_flags; case 'q': return !!cx->dis_opts.show_cycles; case 'n': return !!cx->dis_opts.show_name; + case 'e': return !!cx->dis_opts.show_explanation; case 's': return !!cx->dis_opts.avrgcc_style; case 'l': return !!cx->dis_opts.process_labels; case 'd': return cx->dis_opts.avrlevel == (PART_ALL | OP_AVR_ILL); @@ -267,6 +268,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, {{'f', 'F'}, {"show affected flags in SREG", "don't show SREG flags"}}, {{'q', 'Q'}, {"show cycles", "don't show cycles"}}, {{'n', 'N'}, {"put opcode full name into comment", "don't show full name"}}, + {{'e', 'E'}, {"put explanation into comment", "don't show explanation"}}, {{'s', 'S'}, {"use avr-gcc code style", "use AVR instruction set style"}}, {{'l', 'L'}, {"preprocess jump/call labels", "don't preprocess labels"}}, {{'d', 'D'}, {"decode all opcodes", "decode only opcodes for the part"}}, @@ -484,6 +486,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c cx->dis_opts.show_flags = 0; cx->dis_opts.show_cycles = 0; cx->dis_opts.show_name = 0; + cx->dis_opts.show_explanation = 0; cx->dis_opts.avrgcc_style = 1; cx->dis_opts.process_labels = 1; cx->dis_opts.tagfile = NULL; @@ -521,6 +524,9 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c case 'n': case 'N': cx->dis_opts.show_name = !!islower(chr); break; + case 'e': case 'E': + cx->dis_opts.show_explanation = !!islower(chr); + break; case 's': case 'S': cx->dis_opts.avrgcc_style = !!islower(chr); break; From 7162711ebc62f9661cf0906a91f740023595f191 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 23 Jul 2024 16:01:28 +0100 Subject: [PATCH 351/422] Refine opcode_mnemo() to consider reduced-core parts --- src/avr_opcodes.c | 20 +++++++- src/disasm.c | 28 ++++------ src/libavrdude.h | 12 ++--- src/term.c | 128 ++++++++++++++++++++++++---------------------- src/urclock.c | 14 +---- 5 files changed, 105 insertions(+), 97 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 0bfc9d7d..49df7a30 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -615,12 +615,30 @@ int opcode_match(int op, AVR_opcode mnemo) { return 0; } +// Returns bitmask of first character chr in bits +static int bitmask_first_chr(const char *bits, int chr) { + int ret = 0x8000; + for(const char *c = bits; *c && *c != chr && ret; c++) + if(*c != ' ') + ret >>= 1; + return ret; +} + // Return first match of opcode that is compatible with avrlevel or OPCODE_NONE AVR_opcode opcode_mnemo(int op, int avrlevel) { for(AVR_opcode i = 0; i < OPCODE_N; i++) if(avr_opcodes[i].avrlevel & avrlevel) - if(opcode_match(op, i)) + if(opcode_match(op, i)) { + if(avrlevel == PART_AVR_RC && (avr_opcodes[i].type & OTY_REG_MASK) == OTY_RALL) { + // Reduced-core ATtiny does not have registers r0, ..., r15 + int bmask; // Assert highest bit in 5-bit r/d is set + if((bmask = bitmask_first_chr(avr_opcodes[i].bits, 'r')) && !(op & bmask)) + return OPCODE_NONE; + if((bmask = bitmask_first_chr(avr_opcodes[i].bits, 'd')) && !(op & bmask)) + return OPCODE_NONE; + } return i; + } return OPCODE_NONE; } diff --git a/src/disasm.c b/src/disasm.c index acb82118..7ce0c4f1 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -21,9 +21,9 @@ /* * The disassembly code originates from the avrdisas disassembler written in - * 2007 by Johannes Bauer. The current code has been ported by Stefan Rueger to - * - Enable disassembly of small memory chunks in AVRDUDE's terminal - * - Drive disassembly from the avr_opcode[] table + * 2007 by Johannes Bauer. The code here has been rewritten by Stefan Rueger + * - To Enable disassembly of small memory chunks in AVRDUDE's terminal + * - To drive disassembly from the avr_opcodes[] table alone */ #include @@ -873,41 +873,37 @@ static const char *cycles(int mnemo) { /* * Disassemble buflen bytes at buf which corresponds to address addr * - * Before(!) the location buf there are leadin bytes available (0 - 2) - * After the location buf+readlen there are leadout bytes available (0 -4) + * - Caller is responsible that buflen does not split an opcode + * - Before(!) the location buf there are leadin bytes available (0-2) + * - After the location buf+readlen there are leadout bytes available (0-4) */ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { int pos, opcode, mnemo, oplen; Disasm_line line; int awd = cx->dis_addrwidth; - pos = 0; + // Clear marker that symbol has been used for(int i = 0; i < cx->dis_symbolN; i++) if(cx->dis_symbols[i].type == 'I') cx->dis_symbols[i].used = 0; if(cx->dis_opts.process_labels || cx->dis_opts.avrgcc_style) { // Preprocess to gather jump labels or to gain knowledge about registers which are being used - while(pos < buflen) { + for(pos = 0; pos < buflen; pos += mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords) { opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; - mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); + mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); // Can be -1 here disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line, 1); - pos += mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords; } enumerate_labels(); - pos = 0; } if(cx->dis_opts.avrgcc_style) emit_used_io_registers(); - while(pos < buflen) { + for(pos = 0; pos < buflen; pos += oplen) { // Check if this is actually code or maybe only data from tagfile - int added = process_data(buf, pos, addr); - if(added) { - pos += added; + if((oplen = process_data(buf, pos, addr))) continue; - } opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); @@ -939,8 +935,6 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { term_out("%-27s ; %s\n", line.code, line.comment); if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) term_out("\n"); - - pos += oplen; } return 0; diff --git a/src/libavrdude.h b/src/libavrdude.h index aaef45de..c6189fa0 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1589,11 +1589,11 @@ typedef enum { #define OTY_XFRX 0x28 // Data transfer (between external I/O or memory and regs) #define OTY_JMPI 0x30 // Jump to potentially anywhere in flash (jmp, ijmp, eijmp) #define OTY_JMPX 0x38 // Jump to potentially anywhere in flash (calls and ret/i) -#define OTY_RJMI 0x40 // Relative jump rjmp, range [-4094, 4096] bytes -#define OTY_RJMX 0x48 // Relative call rcall, range [-4094, 4096] bytes -#define OTY_BRAI 0x50 // Conditional branch, range [-126, 128] bytes -#define OTY_SKPI 0x60 // Conditional skip, range [0, 4] bytes (cpse, sbrc, sbrs) -#define OTY_SKPX 0x68 // Conditional skip, range [0, 4] bytes (sbic, sbis) +#define OTY_RJMI 0x40 // Relative jump rjmp, range [.-4096, .+4094] bytes +#define OTY_RJMX 0x48 // Relative call rcall, range [.-4096, .+4094] bytes +#define OTY_BRAI 0x50 // Conditional branch, range [.-128, .+126] bytes +#define OTY_SKPI 0x60 // Conditional skip, range [.+0, .+4] (cpse, sbrc, sbrs) +#define OTY_SKPX 0x68 // Conditional skip, range [.+0, .+4] (sbic, sbis) #define OTY_ALIAS 0x100 // Opcode is a strict alias for another one, eg, sbr == ori #define OTY_CONSTRAINT 0x200 // Opcode has constraints: Rr == Rd (tst, clr, lsl, rol) @@ -1826,7 +1826,7 @@ typedef struct { // Static variable from fileio.c int reccount; - // Static variables from disasm*.c + // Static variables from disasm.c int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth, dis_cycle_index; Disasm_options dis_opts; int dis_JumpCallN, dis_symbolN; diff --git a/src/term.c b/src/term.c index 1ad98a28..6411a966 100644 --- a/src/term.c +++ b/src/term.c @@ -233,31 +233,37 @@ static int disasm_ison(char c) { * * Return a buffer with three sections * - up to two lead-in bytes (*prequel) - * - blen bytes (buf + *prequel corresponds to address *baddr) + * - *blen bytes (buf + *prequel corresponds to address *baddr) * - up to 7 lead-out bytes (*sequel) * * Also tell the caller which memory (*memp) was read from. * - * dump/read needs *memp, *baddr and *blen (*prequel and *sequel are 0) + * dump/read needs *memp, *baddr and *blen (*prequel and *sequel are set to 0) * disasm needs *baddr, *blen, *prequel and *sequel */ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[], const AVRMEM **memp, int *baddr, int *blen, int *prequel, int *sequel) { - int i = cx->term_mi; - const char *cmd = tolower(**argv) == 'r'? "read": str_casestarts(*argv, "di")? "disasm []": "dump"; - int is_disasm = cmd[1] == 'i'; - int default_read_size = is_disasm? 32: 256; + const int Nmems = sizeof cx->term_rmem/sizeof*cx->term_rmem; + int mi = cx->term_mi; + if(mi < 0 || mi >= Nmems) + mi = 0; + + const char *cmd = tolower(**argv) == 'r'? "read": str_casestarts(*argv, "di")? "disasm": "dump"; + int is_disasm = cmd[1] == 'i'; + int default_len = is_disasm? 32: 256; + + if((argc < 2 && cx->term_rmem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { + const char *hcmd = is_disasm? "disasm []": cmd; - if ((argc < 2 && cx->term_rmem[0].mem == NULL) || argc > 4 || (argc > 1 && str_eq(argv[1], "-?"))) { msg_error( "Syntax: %s # Entire region\n" " %s # Start at \n" " %s # Continue with memory where left off\n" " %s # Continue with most recently shown \n" "Function: %s\n", - cmd, cmd, cmd, cmd, + hcmd, hcmd, hcmd, hcmd, is_disasm? "disassemble memory section": "display memory section as hex dump" ); if(is_disasm) { @@ -290,44 +296,46 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, "the interval at that many bytes below the memory size.\n" "\n" "The latter two versions of the command page through the memory with a page\n" - "size of the last used effective length (%d bytes default)\n", default_read_size + "size of the last used effective length (%d bytes default)\n", default_len ); return NULL; } - const char *memstr; - if(argc > 1) - memstr = argv[1]; - else - memstr = cx->term_rmem[i].mem->desc; - const AVRMEM *mem = avr_locate_mem(p, memstr); + const char *memstr = + argc > 1? argv[1]: + cx->term_rmem[mi].mem? cx->term_rmem[mi].mem->desc: NULL; + + const AVRMEM *mem = memstr && *memstr? avr_locate_mem(p, memstr): NULL; if (mem == NULL) { - pmsg_error("(%s) memory %s not defined for part %s\n", cmd, memstr, p->desc); + pmsg_error("(%s) memory %s not defined for part %s\n", cmd, memstr? memstr: "???", p->desc); return NULL; } int maxsize = mem->size; - if(maxsize <= 0) { // Sanity check + if(maxsize <= 0) { // Sanity check pmsg_error("(%s) cannot read memory %s of size %d\n", cmd, mem->desc, maxsize); return NULL; } // Iterate through the cx->term_rmem structs to find relevant address and length info - for(i = 0; i < 32; i++) { - if(cx->term_rmem[i].mem == NULL) - cx->term_rmem[i].mem = mem; - if(cx->term_rmem[i].mem == mem) { - if(cx->term_rmem[i].len == 0) - cx->term_rmem[i].len = maxsize > default_read_size? default_read_size: maxsize; + for(mi = 0; mi < Nmems; mi++) { + if(cx->term_rmem[mi].mem == NULL) + cx->term_rmem[mi].mem = mem; + if(cx->term_rmem[mi].mem == mem) { + if(cx->term_rmem[mi].len <= 0) + cx->term_rmem[mi].len = maxsize > default_len? default_len: maxsize; + else if(cx->term_rmem[mi].len > maxsize) + cx->term_rmem[mi].len = maxsize; + if(cx->term_rmem[mi].addr < 0 || cx->term_rmem[mi].addr >= maxsize) + cx->term_rmem[mi].addr = 0; break; } } - - if(i >= 32) { // Catch highly unlikely case + if(mi >= Nmems) { pmsg_error("(%s) cx->term_rmem[] under-dimensioned; increase and recompile\n", cmd); return NULL;; } - cx->term_mi = i; + cx->term_mi = mi; // Get start address if present const char *errptr; @@ -343,20 +351,20 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, addr = maxsize + addr; if (addr < 0 || addr >= maxsize) { - int digits = mem->size > 0x10000? 5: 4; + int digits = maxsize > 0x10000? 5: 4; pmsg_error("(%s) %s address %s is out of range [-0x%0*x, 0x%0*x]\n", cmd, mem->desc, argv[2], digits, maxsize, digits, maxsize-1); return NULL; } - cx->term_rmem[i].addr = addr; + cx->term_rmem[mi].addr = addr; } // Get number of bytes to read if present if (argc >= 3) { if(str_eq(argv[argc - 1], "...")) { if (argc == 3) - cx->term_rmem[i].addr = 0; - cx->term_rmem[i].len = maxsize - cx->term_rmem[i].addr; + cx->term_rmem[mi].addr = 0; + cx->term_rmem[mi].len = maxsize - cx->term_rmem[mi].addr; } else if (argc == 4) { int len = str_int(argv[3], STR_INT32, &errptr); if(errptr) { @@ -364,9 +372,9 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, return NULL; } - // Turn negative len value (number of bytes from top of memory) into an actual length + // Turn negative len (ends at number of bytes from top of memory) into an actual length if (len < 0) - len = maxsize + len + 1 - cx->term_rmem[i].addr; + len = maxsize + len + 1 - cx->term_rmem[mi].addr; if (len == 0) goto nocontent; @@ -375,24 +383,24 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, pmsg_error("(%s) invalid effective length %d\n", cmd, len); return NULL; } - cx->term_rmem[i].len = len; + cx->term_rmem[mi].len = len; } } // Wrap around if the memory address is greater than the maximum size - if(cx->term_rmem[i].addr >= maxsize) - cx->term_rmem[i].addr = 0; // Wrap around + if(cx->term_rmem[mi].addr >= maxsize) + cx->term_rmem[mi].addr = 0; // Trim len if nessary to prevent reading from the same memory address twice - if (cx->term_rmem[i].len > maxsize) - cx->term_rmem[i].len = maxsize; + if (cx->term_rmem[mi].len > maxsize) + cx->term_rmem[mi].len = maxsize; - uint8_t *buf = mmt_malloc(cx->term_rmem[i].len + 16); // Add safety margin + uint8_t *buf = mmt_malloc(cx->term_rmem[mi].len + 16); // Add margin for disasm if(argc < 4 && verbose) - term_out(">>> %s %s 0x%x 0x%x\n", cmd, cx->term_rmem[i].mem->desc, - cx->term_rmem[i].addr, cx->term_rmem[i].len); + term_out(">>> %s %s 0x%x 0x%x\n", cmd, cx->term_rmem[mi].mem->desc, + cx->term_rmem[mi].addr, cx->term_rmem[mi].len); - int toread = cx->term_rmem[i].len; - int whence = cx->term_rmem[i].addr; + int toread = cx->term_rmem[mi].len; + int whence = cx->term_rmem[mi].addr; int before = 0, after = 0, flash_offset = 0; if(is_disasm) { // Read a few bytes before/after & don't wrap round if(whence >= 2) @@ -402,20 +410,18 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, int gap = maxsize - whence - toread; after = gap >= 7? 7: gap < 0? 0: gap; toread += after; - if(toread-before < 2) + if(toread-before < 2) // Cannot disassemble just one byte goto nocontent; } report_progress(0, 1, "Reading"); - for (int j = 0; j < toread; j++) { - int addr = (whence + j) % mem->size; - int rc = pgm->read_byte_cached(pgm, p, cx->term_rmem[i].mem, addr, &buf[j]); + for(int j = 0; j < toread; j++) { + int addr = (whence + j) % maxsize; + int rc = pgm->read_byte_cached(pgm, p, mem, addr, &buf[j]); if (rc != 0) { report_progress(1, -1, NULL); pmsg_error("(%s) error reading %s address 0x%05lx of part %s\n", cmd, mem->desc, (long) whence + j, p->desc); - if (rc == -1) - imsg_error("%*sread operation not supported on memory %s\n", 7, "", mem->desc); mmt_free(buf); return NULL; } @@ -424,15 +430,15 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, report_progress(1, 1, NULL); if(is_disasm) { // Adjust length so buffer does not split opcodes - int i = before, end = toread-after, wend = after? end: end-1; - while(i < wend) - i += is_opcode32(buf[i] | buf[i+1]<<8)? 4: 2; - if(i < end) // Odd length: shorten by one byte - after += end-i; - else if(i > end && after >= i-end) // Increase length to accommodate last 32-bit opcode - after -= i-end; - else if(i > end) // Reduce length - after += i-end; + int j = before, end = toread-after, wend = after? end: end-1; + while(j < wend) + j += is_opcode32(buf[j] | buf[j+1]<<8)? 4: 2; + if(j < end) // Odd length: shorten by one byte + after += end-j; + else if(j > end && after >= j-end) // Increase length to accommodate last 32-bit opcode + after -= j-end; + else if(j > end) // Reduce length + after += j-end; // Disassembly of XMEGA's boot/apptable memory needs to know absolute addr in flash flash_offset = avr_flash_offset(p, mem, whence + before); } @@ -444,7 +450,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, if(sequel) *sequel = after; // Memorise where to start next time - cx->term_rmem[i].addr = (whence + toread - after) % maxsize; + cx->term_rmem[mi].addr = (whence + toread - after) % maxsize; return buf; @@ -562,7 +568,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c if(help || invalid) { const char *help[] = { "disasm", "-?", NULL, }; readbuf(pgm, p, 2, help, NULL, NULL, NULL, NULL, NULL); - return -1; + return invalid? -1: 0; } if(cx->dis_opts.tagfile) @@ -574,7 +580,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c if(!buf) return -1; - if(len > 0) + if(len > 1) disasm((char *) buf+leadin, len, addr, leadin, leadout); lterm_out(""); mmt_free(buf); @@ -2944,7 +2950,7 @@ int terminal_mode(const PROGRAMMER *pgm, const AVRPART *p) { static int cmd_include(const PROGRAMMER *pgm, const AVRPART *p, int argc, const char *argv[]) { - int help = 0, invalid = 0, echo = 0, itemac=1; + int help = 0, invalid = 0, echo = 0, itemac = 1; for(int ai = 0; --argc > 0; ) { // Simple option parsing const char *q; diff --git a/src/urclock.c b/src/urclock.c index 3c6bd7ea..cc27079c 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -349,7 +349,7 @@ static int nmeta(int mcode, int flashsize) { #define ret_opcode 0x9508 -// Is the opcode an rjmp, ie, a relative jump [-4094, 4096] bytes from opcode address? +// Is the opcode an rjmp, ie, a relative jump [.-4096, .+4094] static int isRjmp(uint16_t opcode) { return (opcode & 0xf000) == 0xc000; } @@ -416,16 +416,6 @@ static int addr_jmp(uint32_t jmp) { } -// Is the instruction word the lower 16 bit part of a 32-bit instruction? -static int isop32(uint16_t opcode) { - return - (opcode & 0xfe0f) == 0x9200 || // sts - (opcode & 0xfe0f) == 0x9000 || // lds - (opcode & 0xfe0e) == 0x940c || // jmp - (opcode & 0xfe0e) == 0x940e; // call -} - - // Is the instruction word the lower 16 bit part of a jmp instruction? static int isJmp(uint16_t opcode) { return (opcode & 0xfe0e) == 0x940c; @@ -1483,7 +1473,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { } else if(isJmp(opcode) && toend > 6) { // 4 top bytes are data + 2 the jmp addr op16 = opcode; wasjmp = 1; // Look at destination address in next loop iteration - } else if(isop32(opcode)) { // Skip next opcode, too + } else if(is_opcode32(opcode)) { // Skip next opcode, too wasop32 = 1; } } From a14b13e2bd8e5778ba67b54dee73f8c270ab133f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 23 Jul 2024 23:59:05 +0100 Subject: [PATCH 352/422] Consider UTF-8 characters when escaping strings --- src/avrdude.conf.in | 2 +- src/config.c | 99 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 96 insertions(+), 5 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 51974300..6c5dbf81 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -467,7 +467,7 @@ allow_subshells = no; # support for the STK500 programmer which was the dominant serial port # programmer at that time. The parallel port was attractive because the # STK500 was fairly expensive at the time and people could build a -# parallel port programmer for very little cost in parts if they didn’t +# parallel port programmer for very little cost in parts if they didn't # already have them on-hand." # # Here a 2003 webpage about the bsd programmer: diff --git a/src/config.c b/src/config.c index 1f25c1ac..954483e9 100644 --- a/src/config.c +++ b/src/config.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "avrdude.h" #include "libavrdude.h" @@ -297,7 +298,6 @@ void free_tokens(int n, ...) } - TOKEN *new_number(const char *text) { const char *errstr; TOKEN *tkn = new_token(TKN_NUMBER); @@ -774,12 +774,94 @@ char *cfg_unescape(char *d, const char *s) { return (char *) cfg_unescapeu((unsigned char *) d, (const unsigned char *) s); } +// Returns the number of characters that a unicode character would need (0-6) +static int utf8width(wint_t wc) { + if(!(wc & ~0x7fu)) + return 1; + if(!(wc & ~0x7ffu)) + return 2; + if(!(wc & ~0xffffu)) + return 3; + if(!(wc & ~0x1fffffu)) + return 4; + if(!(wc & ~0x3ffffffu)) + return 5; + if(!(wc & ~0x7fffffffu)) + return 6; + return 0; +} + + +// Given the first byte c of a character sequence, how long is the sequence going to be? +static int utf8headlen(int c) { + return (c & 0xe0) == 0xc0? 2: + (c & 0xf0) == 0xe0? 3: + (c & 0xf8) == 0xf0? 4: (c & 0xfc) == 0xf8? 5: (c & 0xfe) == 0xfc? 6: 1 /* not a utf8 header byte */ ; +} + +/* + * Return the next unicode character from a utf-8 string str with at least + * n characters and record the length of the utf-8 string eaten in *lenp + * Returns U+FFFD (illegal char) if parsing does not go well +*/ + +static wint_t nextutf8char(const char *str, int n, int *lenp) { + int j, utf8, len; + wint_t c, wc = 0; + + c = str[0] & 0xff; + if(!(c & 0x80)) { // Simple ASCII - all done + if(lenp) + *lenp = 1; + return c; + } + + utf8 = 0; // Possible UTF-8 character, convert to wint_t + len = utf8headlen((int) c); + if(len > 1 && len <= n) { + switch (len) { + case 2: + wc = c & 0x1f; + break; + case 3: + wc = c & 0xf; + break; + case 4: + wc = c & 0x7; + break; + case 5: + wc = c & 0x3; + break; + case 6: + wc = c & 0x1; + break; + } + for(utf8 = 1, j = 1; j < len; j++) { + if((str[j] & 0xc0) != 0x80) { + utf8 = 0; + break; + } + wc = (wc << 6) + (str[j] & 0x3f); + } + } + if(utf8 && utf8width(wc) != len) // Sequence code was longer than needed be, make invalid + utf8 = 0; + + if(!utf8) + len = 1, wc = 0xFFFD; // Illegal character + + if(lenp) + *lenp = len; + + return wc; +} + // Return an mmt_malloc'd escaped string that looks like a C-style input string incl quotes char *cfg_escape(const char *s) { char buf[50*1024], *d = buf; *d++ = '"'; - for(; *s && d-buf < (long) sizeof buf-7; s++) { + for(; *s && d-buf < (long) sizeof buf - 10; s++) { switch(*s) { case '\n': *d++ = '\\'; *d++ = 'n'; @@ -808,7 +890,17 @@ char *cfg_escape(const char *s) { *d++ = '\\'; *d++ = '\"'; break; default: - if(*s == 0x7f || (unsigned char) *s < 32) { + if(*s & 0x80) { // Check for utf8-sequences + int chrlen; + if(0xFFFD == nextutf8char(s, strlen(s), &chrlen)) { // Invalid UTF-8 + sprintf(d, "\\%03o", *s & 0xff); + d += strlen(d); + } else { // Copy over valid UTF-8 character + memcpy(d, s, chrlen); + d += chrlen; + s += chrlen - 1; + } + } else if(*s == 0x7f || (unsigned char) *s < 32) { sprintf(d, "\\%03o", *s); d += strlen(d); } else @@ -835,7 +927,6 @@ Component *cfg_comp_search(const char *name, int strct) { if(!cx->cfg_init_search++) qsort(avr_comp, sizeof avr_comp/sizeof*avr_comp, sizeof(Component), cmp_comp); - key.name = name; key.strct = strct; return bsearch(&key, avr_comp, sizeof avr_comp/sizeof*avr_comp, sizeof(Component), cmp_comp); From ac0f0af7bb0e2eaa1d706f8e528f1f051dc7ff1d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 24 Jul 2024 18:42:45 +0100 Subject: [PATCH 353/422] Provide disasm -g option that generates avr-gcc source --- src/disasm.c | 631 +++++++++++++++++++++++------------------------ src/libavrdude.h | 18 +- src/term.c | 12 + 3 files changed, 332 insertions(+), 329 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 7ce0c4f1..9718e5a6 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -21,9 +21,10 @@ /* * The disassembly code originates from the avrdisas disassembler written in - * 2007 by Johannes Bauer. The code here has been rewritten by Stefan Rueger - * - To Enable disassembly of small memory chunks in AVRDUDE's terminal - * - To drive disassembly from the avr_opcodes[] table alone + * 2007 by Johannes Bauer. This code has been rewritten by Stefan Rueger to + * - Enable disassembly of small memory chunks in AVRDUDE's terminal + * - Drive disassembly from the avr_opcodes[] table alone + * - Generate a compilable source */ #include @@ -76,9 +77,13 @@ static int find_symbol(int type, int address) { } static void add_symbol(int address, int type, int subtype, int count, const char *name, const char *comment) { - int N = cx->dis_symbolN++; + int N = find_symbol(0, -1); // Do we have a recycled symbol? - cx->dis_symbols = (Disasm_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Disasm_symbol) * (N+1)); + if(N < 0) { // No, increase symbol table + N = cx->dis_symbolN++; + if(N%1024 == 0) + cx->dis_symbols = (Disasm_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Disasm_symbol) * (N+1024)); + } cx->dis_symbols[N].address = address; cx->dis_symbols[N].type = type; cx->dis_symbols[N].subtype = subtype; @@ -88,7 +93,7 @@ static void add_symbol(int address, int type, int subtype, int count, const char cx->dis_symbols[N].comment = comment? mmt_strdup(comment): NULL; } -static int LineError(const char *token, const char *message, int lineno) { +static int line_error(const char *token, const char *message, int lineno) { if((token == NULL) || (strlen(token) == 0)) { pmsg_error("%s in tagfile, line %d\n", message, lineno); return 1; @@ -105,7 +110,7 @@ static int Tagfile_Readline(char *line, int lineno) { return 0; token = strtok(line, " \t\n"); - if(LineError(token, "nonempty line", lineno)) + if(line_error(token, "nonempty line", lineno)) return -1; address = str_int(token, STR_INT32, &errptr); if(errptr) { @@ -114,16 +119,16 @@ static int Tagfile_Readline(char *line, int lineno) { } token = strtok(NULL, " \t\n"); - if(LineError(token, "no second argument", lineno)) + if(line_error(token, "no second argument", lineno)) return -1; if(strlen(token) != 1) { - LineError(NULL, "second argument should be a type (L, P or M)", lineno); + line_error(NULL, "second argument should be a type (L, P or M)", lineno); return -1; } type = token[0]; token = strtok(NULL, " \t\n"); - if(LineError(token, "no third argument", lineno)) + if(line_error(token, "no third argument", lineno)) return -1; if(type == 'L') { @@ -132,10 +137,10 @@ static int Tagfile_Readline(char *line, int lineno) { return 0; } - if(LineError(token, "no fourth argument", lineno)) + if(line_error(token, "no fourth argument", lineno)) return -1; if(strlen(token) != 1) { - LineError(NULL, "fourth argument should be a subtype (B, W, A or S)", lineno); + line_error(NULL, "fourth argument should be a subtype (B, W, A or S)", lineno); return -1; } subtype = token[0]; @@ -155,12 +160,12 @@ static int Tagfile_Readline(char *line, int lineno) { subtype = TYPE_STRING; break; default: - LineError(NULL, "invalid subtype (expected one of B, W, A or S)", lineno); + line_error(NULL, "invalid subtype (expected one of B, W, A or S)", lineno); return -1; } if((type == 'M') && ((subtype != TYPE_BYTE) && (subtype != TYPE_WORD))) { - LineError(NULL, "memory labels can only be of type B or W", lineno); + line_error(NULL, "memory labels can only be of type B or W", lineno); return -1; } @@ -171,7 +176,7 @@ static int Tagfile_Readline(char *line, int lineno) { return -1; } if(count < 1) { - LineError(NULL, str_ccprintf("invalid count %d given", count), lineno); + line_error(NULL, str_ccprintf("invalid count %d given", count), lineno); return -1; } @@ -262,11 +267,11 @@ error: return -1; } -static char *Tagfile_GetLabel(int index) { +static char *get_symbol_name(int index) { return cx->dis_symbols[index].name; } -static char *Tagfile_GetLabelComment(int index) { +static char *get_symbol_comment(int index) { return cx->dis_symbols[index].comment; } @@ -298,56 +303,33 @@ static const char *resolve_mem_address(int address) { return NULL; } -static int process_byte(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { - term_out(".byte 0x%02x\n", Bitstream[Position] & 0xff); - return 1; +// Increase cycle number by 1 if it's a 3 byte PC +static const char *cycles(int mnemo) { + if(mnemo < 0) + return "---"; + + const char *ret = avr_opcodes[mnemo].clock[cx->dis_cycle_index]; + + // A plus sign after the cycle number means add one for 3-byte PC + if(*ret && ret[1] == '+') + return str_ccprintf("%c", cx->dis_flashsz > 128*1024? *ret+1: *ret); + + return ret; } -static int process_word(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { - term_out(".word 0x%02x%02x\n", Bitstream[Position + 1] & 0xff, Bitstream[Position] & 0xff); - return 2; -} - -static int process_string(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) { - int i; - unsigned char c; - unsigned int InString = 0; - - term_out("String_0x%s_%d: ; Address 0x%x (%d)\n", Label, ArgumentNo, Position, Position); - i = 0; - while((c = Bitstream[Position + i])) { - if((c >= 32) && (c <= 127)) { - if(!InString) - term_out(".ascii \""); - term_out("%c", c); - InString = 1; - } else { - if(InString) - term_out("\"\n"); - term_out(".byte 0x%02x\n", c); - InString = 0; - } - i++; +static const char *get_label_name(int destination, char **comment) { + int index = find_symbol('L', destination); + if(index >= 0) { + if(comment) + *comment = get_symbol_comment(index); + return str_ccprintf("%s", get_symbol_name(index)); } - if(InString) - term_out("\\0\"\n"); - else - term_out(".byte 0x00\n"); - term_out("\n"); - return i + 1; -} + for(int i = 0; i < cx->dis_jumpcallN; i++) + if(cx->dis_jumpcalls[i].to == destination) + return str_ccprintf("%s%d", cx->dis_jumpcalls[i].is_func? "subroutine": "label", cx->dis_jumpcalls[i].labelno); -static void Sanitize_String(char *String) { - size_t i; - size_t l = strlen(String); - - for(i = 0; i < l; i++) { - if(!(((String[i] >= 'a') && (String[i] <= 'z')) || - (((String[i] >= 'A') && (String[i] <= 'Z'))) || (((String[i] >= '0') && (String[i] <= '9'))))) { - String[i] = '_'; - } - } + return "unknown"; } // Wrap around flash @@ -358,80 +340,167 @@ static int disasm_wrap(int addr) { return addr; } -static int process_data(const char *Bitstream, int Position, int offset) { - int BytesAdvanced; - int (*ProcessingFunction)(const char *, int, int, int, const char *) = NULL; - char Buffer[32]; +#define disasm_out(...) do { \ + if(cx->dis_pass != 2) \ + break; \ + if(cx->dis_para && cx->dis_written) \ + term_out("\n"); \ + cx->dis_para = 0, cx->dis_written = 1; \ + term_out(__VA_ARGS__); \ +} while(0) - int index = find_symbol('P', disasm_wrap(Position + offset)); - if(index < 0) - return 0; +#define LINE_N 256 +typedef struct { + char label[LINE_N], code[LINE_N], comment[LINE_N]; +} Disasm_line; - switch(cx->dis_symbols[index].subtype) { - case TYPE_BYTE: - ProcessingFunction = process_byte; - break; - case TYPE_WORD: - ProcessingFunction = process_word; - break; - case TYPE_ASTRING: - ProcessingFunction = process_string; - break; - case TYPE_STRING: - ProcessingFunction = process_string; - break; + +// Column where opcode starts +static int codecol() { + int ret = 0; + if(cx->dis_opts.show_addresses) + ret += 3 + cx->dis_addrwidth; + if(cx->dis_opts.show_flags) + ret += 9; + if(cx->dis_opts.show_cycles) + ret += 4; + if(cx->dis_opts.show_opcodes) + ret += 12; + + return ret? ret+1: 2; +} + +// Unified printing of a line +static void lineout(const char *code, const char *comment, + int mnemo, int oplen, const char *buf, int pos, int addr, int labellable) { + + int here = disasm_wrap(pos + addr), codewidth = 27; + + if(cx->dis_opts.process_labels && labellable) { + int match = 0; + + for(int i = 0; i < cx->dis_jumpcallN; i++) { + if((cx->dis_jumpcalls[i].to) == here) { + if(!match++) + cx->dis_para = 1; + disasm_out("; Referenced from L%0*x by %s\n", cx->dis_addrwidth, + cx->dis_jumpcalls[i].from, avr_opcodes[cx->dis_jumpcalls[i].mnemo].opcode); + } + } + + if(match) { + char *comment = NULL; + const char *name = get_label_name(here, &comment); + if(comment == NULL) + disasm_out("%s:\n", name); + else + disasm_out("%-*s ; %s\n", codecol() + codewidth, str_ccprintf("%s:", name), comment); + } + if(cx->dis_pass == 1) // Mark this position as one that can be label destination + add_symbol(here, 'l', 0, 0, NULL, NULL); } - term_out("; Inline PGM data: %d ", cx->dis_symbols[index].count); - switch(cx->dis_symbols[index].subtype) { - case TYPE_BYTE: - term_out("byte"); - break; - case TYPE_WORD: - term_out("word"); - break; - case TYPE_ASTRING: - term_out("autoaligned string"); - break; - case TYPE_STRING: - term_out("string"); - break; + if(cx->dis_opts.show_addresses) + disasm_out("L%0*x: ", cx->dis_addrwidth, here); + if(cx->dis_opts.show_flags) + disasm_out("%s ", mnemo < 0? "--------": avr_opcodes[mnemo].flags); + if(cx->dis_opts.show_cycles) + disasm_out("%3s ", cycles(mnemo)); + if(cx->dis_opts.show_opcodes) + for(int i = 0; i < 4; i++) + disasm_out(i < oplen? "%02x ": " ", buf[pos + i] & 0xff); + disasm_out(codecol() > 2? " ": " "); + if(!comment || !*comment || !cx->dis_opts.show_comments) + disasm_out("%s\n", code); + else + disasm_out("%-*s ; %s\n", codewidth, code, comment); + if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_reti || mnemo == OPCODE_u_reti) + cx->dis_para = 1; +} + +// Process 1, 2 or 4 byte number +static int process_num(const char *buf, int buflen, int nbytes, int pos, int offset) { + if(buflen - pos < nbytes) + nbytes = buflen - pos; + while(nbytes & (nbytes-1)) // Round down to next power of 2 + nbytes &= nbytes-1; + + const char *str = + nbytes == 1? str_ccprintf(".byte 0x%02x", buf[pos] & 0xff): + nbytes == 2? str_ccprintf(".word 0x%02x%02x", buf[pos+1] & 0xff, buf[pos] & 0xff): + nbytes == 4? str_ccprintf(".long 0x%02x%02x%02x%02x", buf[pos+3] & 0xff, buf[pos+2] & 0xff, + buf[pos+1] & 0xff, buf[pos] & 0xff): "nbytes?"; + + lineout(str, NULL, -1, 1, buf, pos, offset, 0); + return nbytes; +} + +// Output quoted string +static int process_string(const char *buf, int buflen, int pos, int offset) { + char *code, *out; + int i = pos; + while(i < buflen && buf[i]) + i++; + + if(i == buflen) { // Ran out of buffer: string not terminated + char *str = mmt_malloc(i-pos + 1); + memcpy(str, buf+pos, i-pos); + str[i-pos] = 0; + out = cfg_escape(str); + mmt_free(str); + code = str_sprintf(".ascii %s", out); + } else { // Nul terminated string + out = cfg_escape(buf + pos); + code = str_sprintf(".asciz %s", out); + i++; } - if(cx->dis_symbols[index].count != 1) - term_out("s"); - term_out(" starting at 0x%0*x", cx->dis_addrwidth, disasm_wrap(Position + offset)); - if(cx->dis_symbols[index].name) - term_out(" (%s)", cx->dis_symbols[index].name); - term_out("\n"); + lineout(code, NULL, -1, i-pos, buf, pos, offset, 0); + mmt_free(out); + mmt_free(code); - if((cx->dis_symbols[index].subtype == TYPE_ASTRING) || (cx->dis_symbols[index].subtype == TYPE_STRING)) { - if(cx->dis_symbols[index].name != NULL) { - snprintf(Buffer, sizeof(Buffer), "%x_%s", disasm_wrap(Position + offset), cx->dis_symbols[index].name); - Sanitize_String(Buffer); - } else { - snprintf(Buffer, sizeof(Buffer), "%x", disasm_wrap(Position + offset)); + return i-pos; +} + +// Returns number of bytes of PGM data at this position, printing them in pass 2 +static int process_data(const char *buf, int buflen, int pos, int offset) { + int ret = 0, index = find_symbol('P', disasm_wrap(pos + offset)); + if(index < 0) { + // Try to see if there are PGM data at the next (odd) address + if((index = find_symbol('P', disasm_wrap(pos + offset + 1))) < 0) + return 0; + process_num(buf, buflen, 1, pos, offset); + ret = 1; + } + Disasm_symbol *s = cx->dis_symbols + index; + + if(s->name) { + cx->dis_para = 1; + disasm_out("%s:\n", s->name); + } + + for(int i = 0; i < s->count && pos+ret < buflen; i++) { + switch(s->subtype) { + case TYPE_BYTE: + case TYPE_WORD: + ret += process_num(buf, buflen, s->subtype, pos+ret, offset); + break; + case TYPE_ASTRING: + case TYPE_STRING: + ret += process_string(buf, buflen, pos+ret, offset); } } - BytesAdvanced = 0; - for(int i = 0; i < cx->dis_symbols[index].count; i++) - BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, offset, i, Buffer); - - if(cx->dis_symbols[index].subtype == TYPE_ASTRING) { - // Autoaligned string - if((BytesAdvanced % 2) != 0) { - // Not yet aligned correctly - if(Bitstream[Position + BytesAdvanced] != 0x00) - pmsg_warning("autoalignment expected zero but got 0x%02x padding; ignored\n", - Bitstream[Position + BytesAdvanced] & 0xff); - term_out(".byte 0x%02x ; String Autoalignment\n", ((unsigned char *) Bitstream)[Position + BytesAdvanced]); - BytesAdvanced++; + if(s->subtype == TYPE_ASTRING) { // Autoaligned string + if(ret%2) { + if(buf[pos+ret]) + pmsg_warning("autoalignment expects 0x00 padding but got 0x%02x\n", buf[pos+ret] & 0xff); + lineout(str_ccprintf(".byte 0x%02x", buf[pos+ret] & 0xff), + "String autoalignment", -1, 1, buf, pos+ret, offset, 0); + ret++; } } - - term_out("\n"); - return BytesAdvanced; + return ret; } static const char *resolve_io_register(int Number) { @@ -450,149 +519,96 @@ static const char *resolve_io_register(int Number) { void emit_used_io_registers() { for(int i = 0; i < cx->dis_symbolN; i++) if(cx->dis_symbols[i].used) - term_out(".equ %s, 0x%02x\n", cx->dis_symbols[i].name, cx->dis_symbols[i].address); + disasm_out(".equ %s, 0x%02x\n", cx->dis_symbols[i].name, cx->dis_symbols[i].address); } - void disasm_zap_jumpcalls() { - if(cx->dis_JumpCalls) { - mmt_free(cx->dis_JumpCalls); - cx->dis_JumpCalls = NULL; + if(cx->dis_jumpcalls) { + mmt_free(cx->dis_jumpcalls); + cx->dis_jumpcalls = NULL; } - cx->dis_JumpCallN = 0; + cx->dis_jumpcallN = 0; } -static void register_jumpcall(int From, int To, int mnemo, unsigned char FunctionCall) { +static void register_jumpcall(int from, int to, int mnemo, unsigned char is_func) { if(cx->dis_opts.process_labels) { - Disasm_JumpCall *jc = cx->dis_JumpCalls; - int N = cx->dis_JumpCallN; + Disasm_jumpcall *jc = cx->dis_jumpcalls; + int N = cx->dis_jumpcallN; // Already entered this JC? for(int i = 0; i < N; i++) - if(jc[i].From == From && jc[N].To == To && jc[N].mnemo == mnemo) + if(jc[i].from == from && jc[N].to == to && jc[N].mnemo == mnemo) return; - jc = mmt_realloc(jc, sizeof(Disasm_JumpCall) * (N+1)); - jc[N].From = From; - jc[N].To = To; + if(N%1024 == 0) + jc = mmt_realloc(jc, sizeof(Disasm_jumpcall) * (N+1024)); + jc[N].from = from; + jc[N].to = to; jc[N].mnemo = mnemo; - jc[N].LabelNumber = 0; - jc[N].FunctionCall = FunctionCall; + jc[N].labelno = 0; + jc[N].is_func = is_func; - cx->dis_JumpCalls = jc; - cx->dis_JumpCallN++; + cx->dis_jumpcalls = jc; + cx->dis_jumpcallN++; } } static int JC_Comparison(const void *Element1, const void *Element2) { - Disasm_JumpCall *JC1, *JC2; + Disasm_jumpcall *JC1, *JC2; - JC1 = (Disasm_JumpCall *) Element1; - JC2 = (Disasm_JumpCall *) Element2; - if((JC1->To) > (JC2->To)) + JC1 = (Disasm_jumpcall *) Element1; + JC2 = (Disasm_jumpcall *) Element2; + if((JC1->to) > (JC2->to)) return 1; - else if((JC1->To) == (JC2->To)) + else if((JC1->to) == (JC2->to)) return 0; return -1; } -static void Correct_Label_IsFunct(void) { +static void correct_is_funct(void) { int i, j; - int LastIdx = 0; - int LastDest = cx->dis_JumpCalls[0].To; - char CurIsFunct = cx->dis_JumpCalls[0].FunctionCall; + int last_idx = 0; + int last_dest = cx->dis_jumpcalls[0].to; + char cur_is_func = cx->dis_jumpcalls[0].is_func; - for(i = 1; i < cx->dis_JumpCallN; i++) { - if(cx->dis_JumpCalls[i].To != LastDest) { - for(j = LastIdx; j < i; j++) - cx->dis_JumpCalls[j].FunctionCall = CurIsFunct; - LastIdx = i; - LastDest = cx->dis_JumpCalls[i].To; - CurIsFunct = 0; + for(i = 1; i < cx->dis_jumpcallN; i++) { + if(cx->dis_jumpcalls[i].to != last_dest) { + for(j = last_idx; j < i; j++) + cx->dis_jumpcalls[j].is_func = cur_is_func; + last_idx = i; + last_dest = cx->dis_jumpcalls[i].to; + cur_is_func = 0; } - CurIsFunct = CurIsFunct || cx->dis_JumpCalls[i].FunctionCall; + cur_is_func = cur_is_func || cx->dis_jumpcalls[i].is_func; } - for(j = LastIdx; j < cx->dis_JumpCallN; j++) - cx->dis_JumpCalls[j].FunctionCall = CurIsFunct; + for(j = last_idx; j < cx->dis_jumpcallN; j++) + cx->dis_jumpcalls[j].is_func = cur_is_func; } static void enumerate_labels(void) { - int i; - int CurrentLabelNumber = 0; - int CurrentFunctionNumber = 0; - int Destination; + int i, dest, cur_labelno = 0, cur_funcno = 0; - if(cx->dis_JumpCallN < 2) + if(cx->dis_jumpcallN < 2) return; - qsort(cx->dis_JumpCalls, cx->dis_JumpCallN, sizeof(Disasm_JumpCall), JC_Comparison); - Correct_Label_IsFunct(); + qsort(cx->dis_jumpcalls, cx->dis_jumpcallN, sizeof(Disasm_jumpcall), JC_Comparison); + correct_is_funct(); - Destination = cx->dis_JumpCalls[0].To; - if(cx->dis_JumpCalls[0].FunctionCall) - CurrentFunctionNumber++; - else - CurrentLabelNumber++; - for(i = 0; i < cx->dis_JumpCallN; i++) { - if(Destination != cx->dis_JumpCalls[i].To) { - if(cx->dis_JumpCalls[i].FunctionCall) - CurrentFunctionNumber++; + dest = 987654321; + for(i = 0; i < cx->dis_jumpcallN; i++) { + if(find_symbol('l', cx->dis_jumpcalls[i].to) < 0) + continue; + cx->dis_jumpcalls[i].labelno = cx->dis_jumpcalls[i].is_func? cur_funcno: cur_labelno; + if(dest != cx->dis_jumpcalls[i].to) { + if(cx->dis_jumpcalls[i].is_func) + cur_funcno++; else - CurrentLabelNumber++; - Destination = cx->dis_JumpCalls[i].To; - } - if(cx->dis_JumpCalls[i].FunctionCall) - cx->dis_JumpCalls[i].LabelNumber = CurrentFunctionNumber; - else - cx->dis_JumpCalls[i].LabelNumber = CurrentLabelNumber; - } -} - -static const char *get_label_name(int destination, char **comment) { - int index = find_symbol('L', destination); - if(index >= 0) { - if(comment) - *comment = Tagfile_GetLabelComment(index); - return str_ccprintf("%s", Tagfile_GetLabel(index)); - } - - for(int i = 0; i < cx->dis_JumpCallN; i++) - if(cx->dis_JumpCalls[i].To == destination) - return str_ccprintf("%s%d", cx->dis_JumpCalls[i].FunctionCall? "Function": "Label", cx->dis_JumpCalls[i].LabelNumber); - - return "unknown"; -} - -// Show all references which refer to "Position" as destination -static void print_jumpcalls(int Position) { - int i; - int Match = 0; - - for(i = 0; i < cx->dis_JumpCallN; i++) { - if((cx->dis_JumpCalls[i].To) == Position) { - if(Match == 0) { - term_out("\n"); - Match = 1; - } - term_out("; Referenced from 0x%0*x by %s\n", cx->dis_addrwidth, - cx->dis_JumpCalls[i].From, avr_opcodes[cx->dis_JumpCalls[i].mnemo].opcode); - } - } - if(Match == 1) { - char *LabelComment = NULL; - const char *LabelName = get_label_name(Position, &LabelComment); - if(LabelComment == NULL) { - term_out("%s:\n", LabelName); - } else { - term_out("%-23s ; %s\n", str_ccprintf("%s:", LabelName), LabelComment); + cur_labelno++; + dest = cx->dis_jumpcalls[i].to; } } } -typedef struct { - char code[256], comment[256]; -} Disasm_line; - #define Ra (regs['a']) #define Rd (regs['d']) #define Rr (regs['r']) @@ -614,7 +630,7 @@ typedef struct { #define Nq (bits['q']) static char *add_comment(Disasm_line *line, const char *comment) { - int len = strlen(line->comment), rem = 256-len-1; + int len = strlen(line->comment), rem = LINE_N - len - 1; char *p = line->comment + len; if(len && *comment && rem > 2) @@ -642,11 +658,11 @@ static unsigned bitcount(unsigned n) { return ret; } -static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm_line *line, int pass) { +static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm_line *line) { memset(line, 0, sizeof*line); if(mnemo < 0) { add_comment(line, "Invalid opcode"); - snprintf(line->code, 256, ".word 0x%02x%02x", buf[1] & 0xff, buf[0] & 0xff); + snprintf(line->code, LINE_N, ".word 0x%02x%02x", buf[1] & 0xff, buf[0] & 0xff); return; } @@ -726,8 +742,9 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, } int awd = cx->dis_addrwidth, swd = cx->dis_sramwidth; - snprintf(line->code, 256, "%-7s ", oc->opcode); - char *c = line->code + strlen(line->code); + snprintf(line->code, LINE_N, "%-7s ", oc->opcode); + char *lc = line->code + strlen(line->code); +#define add_operand(lc, ...) snprintf((lc), LINE_N - ((lc) - line->code), __VA_ARGS__) // Check for opcodes with undefined results switch(oc->type & OTY_WARN_MASK) { @@ -755,7 +772,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, case 7: // Branches offset = (int8_t) (Rk<<1); // Sign-extend and multiply by 2 target = disasm_wrap(addr + offset + 2); - if(pass == 1) + if(cx->dis_pass == 1) register_jumpcall(addr, target, mnemo, 0); is_jumpcall = 1; is_relative = 1; @@ -763,7 +780,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, case 12: offset = (int16_t) (Rk<<4) >> 3; // Sign extend and multiply by 2 target = disasm_wrap(addr + offset + 2); - if(pass == 1) + if(cx->dis_pass == 1) register_jumpcall(addr, target, mnemo, is_function); is_jumpcall = 1; is_relative = 1; @@ -776,98 +793,85 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, add_comment(line, str_ccprintf("Warning: destination outside flash [0, 0x%0*x]", awd, cx->dis_flashsz-1)); target = 2*Rk; // disasm_wrap(2*Rk); - if(pass == 1) + if(cx->dis_pass == 1) register_jumpcall(addr, target, mnemo, is_function); is_jumpcall = 1; break; } - for(const char *o = oc->operands; *o && c-line->code < 255; o++) { + for(const char *o = oc->operands; *o && lc-line->code < LINE_N - 1; o++) { switch(*o) { case 'R': - *c++ = 'r', *c = 0; + *lc++ = 'r', *lc = 0; break; default: - *c++ = *o, *c = 0; + *lc++ = *o, *lc = 0; break; case 'A': if((regname = resolve_io_register(RA))) - snprintf(c, 256-strlen(c), "%s", regname); + add_operand(lc, "%s", regname); else - snprintf(c, 256-strlen(c), "0x%02x", RA); - c += strlen(c); + add_operand(lc, "0x%02x", RA); + lc += strlen(lc); break; case 'a': - snprintf(c, 255 - (c-line->code), "0x%02x", Ra); + add_operand(lc, "0x%02x", Ra); if((memaddr = resolve_mem_address(Ra))) add_comment(line, str_ccprintf("%s", memaddr)); break; case 'k': if(is_jumpcall) { - if(cx->dis_opts.process_labels) { - snprintf(c, 255 - (c-line->code), "%s", get_label_name(target, NULL)); - add_comment(line, str_ccprintf("0x%0*x", awd, target)); + const char *name = get_label_name(target, NULL); + if(cx->dis_opts.process_labels && find_symbol('l', target) >= 0) { + add_operand(lc, "%s", name); + add_comment(line, str_ccprintf("L%0*x", awd, target)); } else { if(is_relative) { - snprintf(c, 255 - (c-line->code), ".%+d", offset); - add_comment(line, str_ccprintf("0x%0*x", awd, target)); + add_operand(lc, ".%+d", offset); + add_comment(line, str_ccprintf("L%0*x", awd, target)); } else - snprintf(c, 255 - (c-line->code), "0x%0*x", awd, target); + add_operand(lc, "0x%0*x", awd, target); } } else { - snprintf(c, 255 - (c-line->code), "0x%0*x", swd, Rk); + add_operand(lc, "0x%0*x", swd, Rk); if(kmemaddr) add_comment(line, str_ccprintf("%s", kmemaddr)); } break; case 'b': - snprintf(c, 255 - (c-line->code), "%d", Rb); + add_operand(lc, "%d", Rb); add_comment(line, str_ccprintf("bit %d = 0x%02x", Rb, 1 << Rb)); break; case 's': - snprintf(c, 255 - (c-line->code), "%d", Rs); + add_operand(lc, "%d", Rs); break; case 'd': - snprintf(c, 255 - (c-line->code), "%s", regstyle(Rd, regword)); + add_operand(lc, "%s", regstyle(Rd, regword)); break; case 'r': - snprintf(c, 255 - (c-line->code), "%s", regstyle(Rr, regword)); + add_operand(lc, "%s", regstyle(Rr, regword)); break; case 'K': if(NK == 4) - snprintf(c, 255 - (c-line->code), "%d", RK); + add_operand(lc, "%d", RK); else { - snprintf(c, 255 - (c-line->code), "0x%02x", RK); + add_operand(lc, "0x%02x", RK); add_comment(line, str_ccprintf("%d", RK)); } break; - case 'q': snprintf(c, 255 - (c-line->code), "%d", Rq); + case 'q': + add_operand(lc, "%d", Rq); break; } - c += strlen(c); + lc += strlen(lc); } if(cx->dis_opts.show_name) add_comment(line, avr_opcodes[mnemo].description); if(cx->dis_opts.show_explanation) add_comment(line, avr_opcodes[mnemo].operation); // Trim trailing spaces - while(--c >= line->code && *c == ' ') - *c = 0; -} - - -// Increase cycle number by 1 if it's a 3 byte PC -static const char *cycles(int mnemo) { - if(mnemo < 0) - return "---"; - - const char *ret = avr_opcodes[mnemo].clock[cx->dis_cycle_index]; - - // A plus sign after the cycle number means add one for 3-byte PC - if(*ret && ret[1] == '+') - return str_ccprintf("%c", cx->dis_flashsz > 128*1024? *ret+1: *ret); - - return ret; + while(--lc >= line->code && *lc == ' ') + *lc = 0; } /* @@ -880,61 +884,46 @@ static const char *cycles(int mnemo) { int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { int pos, opcode, mnemo, oplen; Disasm_line line; - int awd = cx->dis_addrwidth; - // Clear marker that symbol has been used - for(int i = 0; i < cx->dis_symbolN; i++) + // Clear info that symbol has been used and recycle labellable marker 'l' + int recycled = 0; + for(int i = 0; i < cx->dis_symbolN; i++) { if(cx->dis_symbols[i].type == 'I') cx->dis_symbols[i].used = 0; - - if(cx->dis_opts.process_labels || cx->dis_opts.avrgcc_style) { - // Preprocess to gather jump labels or to gain knowledge about registers which are being used - for(pos = 0; pos < buflen; pos += mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords) { - opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; - mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); // Can be -1 here - disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line, 1); - } - enumerate_labels(); + if(cx->dis_symbols[i].type == 'l') + recycled = 1, cx->dis_symbols[i].type = 0, cx->dis_symbols[i].address = -1; } + if(recycled) + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); - if(cx->dis_opts.avrgcc_style) - emit_used_io_registers(); - - for(pos = 0; pos < buflen; pos += oplen) { - // Check if this is actually code or maybe only data from tagfile - if((oplen = process_data(buf, pos, addr))) - continue; - - opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; - mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); - oplen = mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords; - - disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line, 2); - - if(cx->dis_opts.process_labels) - print_jumpcalls(disasm_wrap(pos + addr)); - - if(cx->dis_opts.show_addresses) - term_out("%*x: ", awd, disasm_wrap(pos + addr)); - if(cx->dis_opts.show_cycles || cx->dis_opts.show_flags) { - if(cx->dis_opts.show_flags) - term_out("%s ", mnemo < 0? "--------": avr_opcodes[mnemo].flags); - if(cx->dis_opts.show_cycles) - term_out("%3s ", cycles(mnemo)); + // Make two passes: the first gathers labels, the second outputs the assembler code + for(cx->dis_pass = 1; cx->dis_pass < 3; cx->dis_pass++) { + if(cx->dis_pass == 2) { + enumerate_labels(); + if(cx->dis_opts.avrgcc_style) + emit_used_io_registers(); + if(cx->dis_opts.show_gcc_source) { + cx->dis_para=1; + disasm_out(".text\nmain:\n"); + } } + for(pos = 0; pos < buflen; pos += oplen) { + // Check if this is actually code or maybe only data from tagfile + if((oplen = process_data(buf, buflen, pos, addr))) + continue; - if(cx->dis_opts.show_opcodes) { - for(int i = 0; i < 4; i++) - term_out(i < oplen? "%02x ": " ", buf[pos + i] & 0xff); - term_out(" "); + if(pos & 1) { // Last of PGM data items left off at odd address + oplen = process_num(buf, buflen, 1, pos, addr); + continue; + } + + opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; + mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); + oplen = mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords; + + disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line); + lineout(line.code, line.comment, mnemo, oplen, buf, pos, addr, 1); } - - if(!*line.comment || !cx->dis_opts.show_comments) - term_out("%s\n", line.code); - else - term_out("%-27s ; %s\n", line.code, line.comment); - if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_ret || mnemo == OPCODE_u_ret) - term_out("\n"); } return 0; diff --git a/src/libavrdude.h b/src/libavrdude.h index c6189fa0..90cafe34 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1456,6 +1456,7 @@ typedef enum { } AVR_cycle_index; typedef struct { + int show_gcc_source; int show_addresses; int show_opcodes; int show_comments; @@ -1470,12 +1471,12 @@ typedef struct { } Disasm_options; typedef struct { - int From; - int To; + int from; + int to; int mnemo; - unsigned int LabelNumber; - int FunctionCall; -} Disasm_JumpCall; + unsigned int labelno; + int is_func; +} Disasm_jumpcall; typedef struct { char *name, *comment; @@ -1827,10 +1828,11 @@ typedef struct { int reccount; // Static variables from disasm.c - int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth, dis_cycle_index; + int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth; + int dis_pass, dis_para, dis_written, dis_cycle_index; Disasm_options dis_opts; - int dis_JumpCallN, dis_symbolN; - Disasm_JumpCall *dis_JumpCalls; + int dis_jumpcallN, dis_symbolN; + Disasm_jumpcall *dis_jumpcalls; Disasm_symbol *dis_symbols; // Static variables from usb_libusb.c diff --git a/src/term.c b/src/term.c index 6411a966..17d43a50 100644 --- a/src/term.c +++ b/src/term.c @@ -214,6 +214,7 @@ static int hexdump_buf(const FILE *f, const AVRMEM *m, int startaddr, const unsi static int disasm_ison(char c) { switch(c) { + case 'g': return !!cx->dis_opts.show_gcc_source; case 'a': return !!cx->dis_opts.show_addresses; case 'o': return !!cx->dis_opts.show_opcodes; case 'c': return !!cx->dis_opts.show_comments; @@ -268,6 +269,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, ); if(is_disasm) { struct { char ochr[2]; const char *info[2]; } opts[] = { + {{'g', 'G'}, {"generate avr-gcc source: sets -sOFQ", "don't create gcc source"}}, {{'a', 'A'}, {"show addresses", "don't show addresses"}}, {{'o', 'O'}, {"show opcode bytes", "don't show opcode bytes"}}, {{'c', 'C'}, {"show comments", "don't show comments"}}, @@ -486,6 +488,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c int help = 0, invalid = 0, itemac = 1, chr; if(!cx->dis_initopts) { + cx->dis_opts.show_gcc_source = 0; cx->dis_opts.show_addresses = 1; cx->dis_opts.show_opcodes = 1; cx->dis_opts.show_comments = 1; @@ -512,6 +515,15 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c case 'h': help++; break; + case 'g': case 'G': + cx->dis_opts.show_gcc_source = !!islower(chr); + if(cx->dis_opts.show_gcc_source) { + cx->dis_opts.show_opcodes = 0; + cx->dis_opts.show_flags = 0; + cx->dis_opts.show_cycles = 0; + cx->dis_opts.avrgcc_style = 1; + } + break; case 'a': case 'A': cx->dis_opts.show_addresses = !!islower(chr); break; From fec6e842df65fa85b8a0b5b2f537d5f82926d814 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 24 Jul 2024 19:54:02 +0100 Subject: [PATCH 354/422] Disassemble a series of 4 or more 0xff as fill block --- src/disasm.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 9718e5a6..b73dad03 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -435,6 +435,11 @@ static int process_num(const char *buf, int buflen, int nbytes, int pos, int off return nbytes; } +static int process_fill0xff(const char *buf, int buflen, int nbytes, int pos, int offset) { + lineout(str_ccprintf(".fill %d, 2, 0xffff", nbytes/2), NULL, -1, 1, buf, pos, offset, 0); + return nbytes/2*2; +} + // Output quoted string static int process_string(const char *buf, int buflen, int pos, int offset) { char *code, *out; @@ -466,9 +471,19 @@ static int process_string(const char *buf, int buflen, int pos, int offset) { static int process_data(const char *buf, int buflen, int pos, int offset) { int ret = 0, index = find_symbol('P', disasm_wrap(pos + offset)); if(index < 0) { - // Try to see if there are PGM data at the next (odd) address - if((index = find_symbol('P', disasm_wrap(pos + offset + 1))) < 0) + if(pos+1 >= buflen) return 0; + + if((index = find_symbol('P', disasm_wrap(pos + offset + 1))) < 0) { // No PGM label, check for fill block + int k = 0; + if((buf[pos] &0xff) == 0xff && (buf[pos+1] & 0xff) == 0xff) + for(k=pos+2; k= 0) + break; + k &= ~1; + return !k || k-pos < 4? 0: process_fill0xff(buf, buflen, k-pos, pos, offset); + } + // Found PGM label at odd address, print byte and continue process_num(buf, buflen, 1, pos, offset); ret = 1; } From 32ca573b7194bbf744e1499b36a063d9238df54d Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 25 Jul 2024 17:40:19 +0100 Subject: [PATCH 355/422] Make list of jumpable addresses a bitfield --- src/disasm.c | 199 ++++++++++++++++++++++------------------------- src/libavrdude.h | 4 +- 2 files changed, 97 insertions(+), 106 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index b73dad03..299f3658 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -77,13 +77,9 @@ static int find_symbol(int type, int address) { } static void add_symbol(int address, int type, int subtype, int count, const char *name, const char *comment) { - int N = find_symbol(0, -1); // Do we have a recycled symbol? - - if(N < 0) { // No, increase symbol table - N = cx->dis_symbolN++; - if(N%1024 == 0) - cx->dis_symbols = (Disasm_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Disasm_symbol) * (N+1024)); - } + int N = cx->dis_symbolN++; + if(N % 1024 == 0) + cx->dis_symbols = (Disasm_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Disasm_symbol) * (N+1024)); cx->dis_symbols[N].address = address; cx->dis_symbols[N].type = type; cx->dis_symbols[N].subtype = subtype; @@ -101,7 +97,7 @@ static int line_error(const char *token, const char *message, int lineno) { return 0; } -static int Tagfile_Readline(char *line, int lineno) { +static int tagfile_readline(char *line, int lineno) { char *token, type, subtype, *name; int address, count; const char *errptr; @@ -250,7 +246,7 @@ int disasm_init_tagfile(const AVRPART *p, const char *fname) { init_regfile(p); for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) - if(Tagfile_Readline(buffer, lineno++) < 0) + if(tagfile_readline(buffer, lineno++) < 0) goto error; if(errstr) { @@ -267,14 +263,6 @@ error: return -1; } -static char *get_symbol_name(int index) { - return cx->dis_symbols[index].name; -} - -static char *get_symbol_comment(int index) { - return cx->dis_symbols[index].comment; -} - static const char *resolve_mem_address(int address) { for(int i = 0; i < cx->dis_symbolN; i++) { if(cx->dis_symbols[i].type != 'M') @@ -321,8 +309,8 @@ static const char *get_label_name(int destination, char **comment) { int index = find_symbol('L', destination); if(index >= 0) { if(comment) - *comment = get_symbol_comment(index); - return str_ccprintf("%s", get_symbol_name(index)); + *comment = cx->dis_symbols[index].comment; + return cx->dis_symbols[index].name; } for(int i = 0; i < cx->dis_jumpcallN; i++) @@ -343,9 +331,9 @@ static int disasm_wrap(int addr) { #define disasm_out(...) do { \ if(cx->dis_pass != 2) \ break; \ - if(cx->dis_para && cx->dis_written) \ + if(cx->dis_para) \ term_out("\n"); \ - cx->dis_para = 0, cx->dis_written = 1; \ + cx->dis_para = 0; \ term_out(__VA_ARGS__); \ } while(0) @@ -354,7 +342,6 @@ typedef struct { char label[LINE_N], code[LINE_N], comment[LINE_N]; } Disasm_line; - // Column where opcode starts static int codecol() { int ret = 0; @@ -370,13 +357,24 @@ static int codecol() { return ret? ret+1: 2; } +static int is_jumpable(int address) { + if(!cx->dis_jumpable || address < cx->dis_start || address > cx->dis_end) + return 0; + + int n = sizeof(int)*8, idx = (address - cx->dis_start)/2; + return cx->dis_jumpable[idx/n] & (1<<(idx%n)); +} + // Unified printing of a line static void lineout(const char *code, const char *comment, - int mnemo, int oplen, const char *buf, int pos, int addr, int labellable) { + int mnemo, int oplen, const char *buf, int pos, int addr, int showlabel) { + + if(cx->dis_pass == 1) + return; int here = disasm_wrap(pos + addr), codewidth = 27; - if(cx->dis_opts.process_labels && labellable) { + if(cx->dis_opts.process_labels && showlabel) { int match = 0; for(int i = 0; i < cx->dis_jumpcallN; i++) { @@ -396,8 +394,6 @@ static void lineout(const char *code, const char *comment, else disasm_out("%-*s ; %s\n", codecol() + codewidth, str_ccprintf("%s:", name), comment); } - if(cx->dis_pass == 1) // Mark this position as one that can be label destination - add_symbol(here, 'l', 0, 0, NULL, NULL); } if(cx->dis_opts.show_addresses) @@ -538,10 +534,8 @@ void emit_used_io_registers() { } void disasm_zap_jumpcalls() { - if(cx->dis_jumpcalls) { - mmt_free(cx->dis_jumpcalls); - cx->dis_jumpcalls = NULL; - } + mmt_free(cx->dis_jumpcalls); + cx->dis_jumpcalls = NULL; cx->dis_jumpcallN = 0; } @@ -555,7 +549,7 @@ static void register_jumpcall(int from, int to, int mnemo, unsigned char is_func if(jc[i].from == from && jc[N].to == to && jc[N].mnemo == mnemo) return; - if(N%1024 == 0) + if(N % 1024 == 0) jc = mmt_realloc(jc, sizeof(Disasm_jumpcall) * (N+1024)); jc[N].from = from; jc[N].to = to; @@ -568,27 +562,14 @@ static void register_jumpcall(int from, int to, int mnemo, unsigned char is_func } } -static int JC_Comparison(const void *Element1, const void *Element2) { - Disasm_jumpcall *JC1, *JC2; - - JC1 = (Disasm_jumpcall *) Element1; - JC2 = (Disasm_jumpcall *) Element2; - if((JC1->to) > (JC2->to)) - return 1; - else if((JC1->to) == (JC2->to)) - return 0; - return -1; -} - static void correct_is_funct(void) { - int i, j; int last_idx = 0; int last_dest = cx->dis_jumpcalls[0].to; - char cur_is_func = cx->dis_jumpcalls[0].is_func; + int cur_is_func = cx->dis_jumpcalls[0].is_func; - for(i = 1; i < cx->dis_jumpcallN; i++) { + for(int i = 1; i < cx->dis_jumpcallN; i++) { if(cx->dis_jumpcalls[i].to != last_dest) { - for(j = last_idx; j < i; j++) + for(int j = last_idx; j < i; j++) cx->dis_jumpcalls[j].is_func = cur_is_func; last_idx = i; last_dest = cx->dis_jumpcalls[i].to; @@ -596,30 +577,31 @@ static void correct_is_funct(void) { } cur_is_func = cur_is_func || cx->dis_jumpcalls[i].is_func; } - for(j = last_idx; j < cx->dis_jumpcallN; j++) + for(int j = last_idx; j < cx->dis_jumpcallN; j++) cx->dis_jumpcalls[j].is_func = cur_is_func; } +static int jumpcall_sort(const void *p1, const void *p2) { + return ((Disasm_jumpcall *) p1)->to - ((Disasm_jumpcall *) p2)->to; +} + static void enumerate_labels(void) { - int i, dest, cur_labelno = 0, cur_funcno = 0; + if(cx->dis_jumpcallN > 1) { + qsort(cx->dis_jumpcalls, cx->dis_jumpcallN, sizeof(Disasm_jumpcall), jumpcall_sort); + correct_is_funct(); - if(cx->dis_jumpcallN < 2) - return; - - qsort(cx->dis_jumpcalls, cx->dis_jumpcallN, sizeof(Disasm_jumpcall), JC_Comparison); - correct_is_funct(); - - dest = 987654321; - for(i = 0; i < cx->dis_jumpcallN; i++) { - if(find_symbol('l', cx->dis_jumpcalls[i].to) < 0) - continue; - cx->dis_jumpcalls[i].labelno = cx->dis_jumpcalls[i].is_func? cur_funcno: cur_labelno; - if(dest != cx->dis_jumpcalls[i].to) { - if(cx->dis_jumpcalls[i].is_func) - cur_funcno++; - else - cur_labelno++; - dest = cx->dis_jumpcalls[i].to; + int dest = 987654321, cur_labelno = 0, cur_funcno = 0; + for(int i = 0; i < cx->dis_jumpcallN; i++) { + if(!is_jumpable(cx->dis_jumpcalls[i].to)) + continue; + cx->dis_jumpcalls[i].labelno = cx->dis_jumpcalls[i].is_func? cur_funcno: cur_labelno; + if(dest != cx->dis_jumpcalls[i].to) { + if(cx->dis_jumpcalls[i].is_func) + cur_funcno++; + else + cur_labelno++; + dest = cx->dis_jumpcalls[i].to; + } } } } @@ -747,6 +729,12 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, break; } + int awd = cx->dis_addrwidth, swd = cx->dis_sramwidth; + + int target = 0, offset = 0, is_jumpcall = 0, is_relative = 0; + int is_function = !!(oc->type & OTY_EXTERNAL); // call/rcall affects stack memory + const char *kmemaddr = NULL, *amemaddr = NULL, *regname = NA? resolve_io_register(RA): NULL; + if(Na) { /* * Address is limited to 0x40...0xbf for the reduced-core (TPI part) @@ -754,33 +742,9 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, * ADDR[7:0] ← (/a[4], a[4], a[6], a[5], a[3], a[2], a[1], a[0]) */ Ra = (Ra & 0xf) | ((Ra >> 1) & 0x30) | ((Ra & 0x10) << 2) | (((Ra & 0x10) ^ 0x10) << 3); + amemaddr = resolve_mem_address(Ra); } - int awd = cx->dis_addrwidth, swd = cx->dis_sramwidth; - snprintf(line->code, LINE_N, "%-7s ", oc->opcode); - char *lc = line->code + strlen(line->code); -#define add_operand(lc, ...) snprintf((lc), LINE_N - ((lc) - line->code), __VA_ARGS__) - - // Check for opcodes with undefined results - switch(oc->type & OTY_WARN_MASK) { - case OTY_XWRN: - if(Rd == 26 || Rd == 27 || Rr == 26 || Rr == 27) - add_comment(line, "Warning: the result of this operation is undefined"); - break; - case OTY_YWRN: - if(Rd == 28 || Rd == 29 || Rr == 28 || Rr == 29) - add_comment(line, "Warning: the result of this operation is undefined"); - break; - case OTY_ZWRN: - if(Rd == 30 || Rd == 31 || Rr == 30 || Rr == 31) - add_comment(line, "Warning: the result of this operation is undefined"); - break; - } - - int target = 0, offset = 0, is_jumpcall = 0, is_relative = 0; - int is_function = !!(oc->type & OTY_EXTERNAL); // call/rcall affects stack memory - const char *kmemaddr = NULL, *memaddr, *regname; - switch(Nk) { case 0: break; @@ -814,6 +778,29 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, break; } + if(cx->dis_pass == 1) + return; + + snprintf(line->code, LINE_N, "%-7s ", oc->opcode); + char *lc = line->code + strlen(line->code); +#define add_operand(lc, ...) snprintf((lc), LINE_N - ((lc) - line->code), __VA_ARGS__) + + // Check for opcodes with undefined results + switch(oc->type & OTY_WARN_MASK) { + case OTY_XWRN: + if(Rd == 26 || Rd == 27 || Rr == 26 || Rr == 27) + add_comment(line, "Warning: the result of this operation is undefined"); + break; + case OTY_YWRN: + if(Rd == 28 || Rd == 29 || Rr == 28 || Rr == 29) + add_comment(line, "Warning: the result of this operation is undefined"); + break; + case OTY_ZWRN: + if(Rd == 30 || Rd == 31 || Rr == 30 || Rr == 31) + add_comment(line, "Warning: the result of this operation is undefined"); + break; + } + for(const char *o = oc->operands; *o && lc-line->code < LINE_N - 1; o++) { switch(*o) { case 'R': @@ -823,7 +810,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, *lc++ = *o, *lc = 0; break; case 'A': - if((regname = resolve_io_register(RA))) + if(regname) add_operand(lc, "%s", regname); else add_operand(lc, "0x%02x", RA); @@ -831,13 +818,13 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, break; case 'a': add_operand(lc, "0x%02x", Ra); - if((memaddr = resolve_mem_address(Ra))) - add_comment(line, str_ccprintf("%s", memaddr)); + if(amemaddr) + add_comment(line, str_ccprintf("%s", amemaddr)); break; case 'k': if(is_jumpcall) { const char *name = get_label_name(target, NULL); - if(cx->dis_opts.process_labels && find_symbol('l', target) >= 0) { + if(cx->dis_opts.process_labels && is_jumpable(target)) { add_operand(lc, "%s", name); add_comment(line, str_ccprintf("L%0*x", awd, target)); } else { @@ -900,20 +887,17 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { int pos, opcode, mnemo, oplen; Disasm_line line; - // Clear info that symbol has been used and recycle labellable marker 'l' - int recycled = 0; - for(int i = 0; i < cx->dis_symbolN; i++) { + for(int i = 0; i < cx->dis_symbolN; i++) // Clear used-state of symbols if(cx->dis_symbols[i].type == 'I') cx->dis_symbols[i].used = 0; - if(cx->dis_symbols[i].type == 'l') - recycled = 1, cx->dis_symbols[i].type = 0, cx->dis_symbols[i].address = -1; - } - if(recycled) - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); + + cx->dis_jumpable = mmt_malloc((buflen+1)/2/8); // Allocate one bit per word address + cx->dis_start = addr, cx->dis_end = addr + buflen - 1; // Make two passes: the first gathers labels, the second outputs the assembler code for(cx->dis_pass = 1; cx->dis_pass < 3; cx->dis_pass++) { if(cx->dis_pass == 2) { + cx->dis_para = 0; enumerate_labels(); if(cx->dis_opts.avrgcc_style) emit_used_io_registers(); @@ -924,8 +908,10 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { } for(pos = 0; pos < buflen; pos += oplen) { // Check if this is actually code or maybe only data from tagfile - if((oplen = process_data(buf, buflen, pos, addr))) + if((oplen = process_data(buf, buflen, pos, addr))) { + cx->dis_para = 1; continue; + } if(pos & 1) { // Last of PGM data items left off at odd address oplen = process_num(buf, buflen, 1, pos, addr); @@ -938,9 +924,14 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line); lineout(line.code, line.comment, mnemo, oplen, buf, pos, addr, 1); + if(cx->dis_pass == 1) { // Mark this position as one that can be a jump/call destination + int n = sizeof(int)*8, idx = pos/2; + cx->dis_jumpable[idx/n] |= (1<<(idx%n)); + } } } + mmt_free(cx->dis_jumpable); cx->dis_jumpable = NULL; return 0; } diff --git a/src/libavrdude.h b/src/libavrdude.h index 90cafe34..68688a44 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1829,9 +1829,9 @@ typedef struct { // Static variables from disasm.c int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth; - int dis_pass, dis_para, dis_written, dis_cycle_index; + int dis_pass, dis_para, dis_cycle_index; Disasm_options dis_opts; - int dis_jumpcallN, dis_symbolN; + int dis_jumpcallN, dis_symbolN, *dis_jumpable, dis_start, dis_end; Disasm_jumpcall *dis_jumpcalls; Disasm_symbol *dis_symbols; From d221e466738521ce26b8e210e088432de4192bbe Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 25 Jul 2024 18:36:54 +0100 Subject: [PATCH 356/422] Shorten I/O Register name --- src/disasm.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 299f3658..2828f0d3 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -199,6 +199,24 @@ static char *regname(const char *pre, const char *reg, int suf) { return ret; } +// Return the basename of a register, ie, the part after the first . (if any) +static const char *regbase(const char *reg) { + const char *ret = strchr(reg, '.'); + return ret? ret+1: reg; +} + +// Return the basename of rf[i].reg if that's unique amongst the nr register entries +static const char *shortrname(const Register_file *rf, int nr, int i) { + const char *f = rf[i].reg, *s = regbase(f); + + if(f != s) + for(int k=0; kdis_symbols from part register file static void init_regfile(const AVRPART *p) { int nr = 0, offset = 0; @@ -215,16 +233,17 @@ static void init_regfile(const AVRPART *p) { int sub = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; int count = rf[i].size > 2? rf[i].size: 1; add_symbol(addr, 'M', sub, count, regname(mpre, rf[i].reg, -1), NULL); + const char *rname = offset? shortrname(rf, nr, i): rf[i].reg; if(rf[i].addr < 0x40) { if(rf[i].size == 1) - add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, -1), NULL); + add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rname, -1), NULL); else if(rf[i].size == 2) { - add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, 'l'), NULL); - add_symbol(rf[i].addr+1, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, 'h'), NULL); + add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rname, 'l'), NULL); + add_symbol(rf[i].addr+1, 'I', TYPE_BYTE, 1, regname(ipre, rname, 'h'), NULL); } else if(rf[i].size > 2) { for(int k = 0; k < rf[i].size; k++) - add_symbol(rf[i].addr+k, 'I', TYPE_BYTE, 1, regname(ipre, rf[i].reg, k), NULL); + add_symbol(rf[i].addr+k, 'I', TYPE_BYTE, 1, regname(ipre, rname, k), NULL); } } } @@ -528,9 +547,19 @@ static const char *resolve_io_register(int Number) { } void emit_used_io_registers() { + int maxlen = 0; + + for(int i = 0; i < cx->dis_symbolN; i++) + if(cx->dis_symbols[i].used) { + int len = strlen(cx->dis_symbols[i].name); + if(len > maxlen) + maxlen = len; + } + for(int i = 0; i < cx->dis_symbolN; i++) if(cx->dis_symbols[i].used) - disasm_out(".equ %s, 0x%02x\n", cx->dis_symbols[i].name, cx->dis_symbols[i].address); + disasm_out(".equ %s,%*s 0x%02x\n", cx->dis_symbols[i].name, + (int) (maxlen-strlen(cx->dis_symbols[i].name)), "", cx->dis_symbols[i].address); } void disasm_zap_jumpcalls() { From 8570dd27fd304f0f2447f93e90a7f5aa05f347d3 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 26 Jul 2024 01:23:55 +0100 Subject: [PATCH 357/422] Use memory labels for lds/sts --- src/disasm.c | 161 +++++++++++++++++++++++------------------------ src/libavrdude.h | 2 +- 2 files changed, 81 insertions(+), 82 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 2828f0d3..35a9ec7e 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -39,10 +39,10 @@ #include "avrdude.h" #include "libavrdude.h" -#define TYPE_BYTE 1 -#define TYPE_WORD 2 -#define TYPE_ASTRING 3 -#define TYPE_STRING 4 +#define TYPE_BYTE 1 // 1 byte +#define TYPE_WORD 2 // 2 bytes +#define TYPE_ASTRING 3 // Autoaligned string +#define TYPE_STRING 4 // String static void zap_symbols() { @@ -60,12 +60,18 @@ static void zap_symbols() { static int symbol_sort(const void *v1, const void *v2) { const Disasm_symbol *p1 = v1, *p2 = v2; int diff; - if((diff = p1->type - p2->type)) return diff; return p1->address - p2->address; } +static int symbol_qsort_stable(const void *v1, const void *v2) { + int diff = symbol_sort(v1, v2); + if(diff) + return diff; + return (char *) v1 - (char *) v2; // Keep original order if same keys (stable sort) +} + static int find_symbol(int type, int address) { Disasm_symbol key, *found; @@ -141,7 +147,6 @@ static int tagfile_readline(char *line, int lineno) { } subtype = token[0]; - // Either B(yte), W(ord), A(utoterminated string) or S(tring) switch(subtype) { case 'B': subtype = TYPE_BYTE; @@ -217,37 +222,32 @@ static const char *shortrname(const Register_file *rf, int nr, int i) { return s; } +static void add_register(int io_off, int addr, const char *name, int suffix) { + add_symbol(io_off+addr, 'M', TYPE_BYTE, 1, regname(io_off? "MEM_": "", name, suffix), NULL); + if(addr < 0x40 && io_off) // Only keep I/O addresses separate if memory addresses have an offset + add_symbol(addr, 'I', TYPE_BYTE, 1, regname(io_off? "IO_": "", name, suffix), NULL); +} + // Initialise cx->dis_symbols from part register file static void init_regfile(const AVRPART *p) { - int nr = 0, offset = 0; + int nr = 0, io_off = cx->dis_io_offset; const Register_file *rf = avr_locate_register_file(p, &nr); if(rf) { - AVRMEM *mem = avr_locate_io(p); - if(mem) - offset = mem->offset; - const char *mpre = offset? "MEM_": ""; - const char *ipre = offset? "IO_": ""; for(int i = 0; i< nr; i++) { - int addr = offset + rf[i].addr; - int sub = rf[i].size == 2? TYPE_WORD: TYPE_BYTE; - int count = rf[i].size > 2? rf[i].size: 1; - add_symbol(addr, 'M', sub, count, regname(mpre, rf[i].reg, -1), NULL); - const char *rname = offset? shortrname(rf, nr, i): rf[i].reg; + const char *rname = io_off? shortrname(rf, nr, i): rf[i].reg; - if(rf[i].addr < 0x40) { - if(rf[i].size == 1) - add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rname, -1), NULL); - else if(rf[i].size == 2) { - add_symbol(rf[i].addr, 'I', TYPE_BYTE, 1, regname(ipre, rname, 'l'), NULL); - add_symbol(rf[i].addr+1, 'I', TYPE_BYTE, 1, regname(ipre, rname, 'h'), NULL); - } else if(rf[i].size > 2) { - for(int k = 0; k < rf[i].size; k++) - add_symbol(rf[i].addr+k, 'I', TYPE_BYTE, 1, regname(ipre, rname, k), NULL); - } + if(rf[i].size == 1) { + add_register(io_off, rf[i].addr, rname, -1); + } else if(rf[i].size == 2) { + add_register(io_off, rf[i].addr, rname, 'l'); + add_register(io_off, rf[i].addr+1, rname, 'h'); + } else if(rf[i].size > 2) { + for(int k = 0; k < rf[i].size; k++) + add_register(io_off, rf[i].addr+k, rname, k); } } - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_qsort_stable); } } @@ -274,7 +274,7 @@ int disasm_init_tagfile(const AVRPART *p, const char *fname) { } fclose(inf); - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_qsort_stable); return 0; error: @@ -282,32 +282,39 @@ error: return -1; } -static const char *resolve_mem_address(int address) { - for(int i = 0; i < cx->dis_symbolN; i++) { - if(cx->dis_symbols[i].type != 'M') - continue; - if(cx->dis_symbols[i].address > address) - break; +// Width of memory a symbol covers (only valid for I/O and memory symbols) +static int symbol_width(Disasm_symbol *s) { + return s->count * (s->subtype == TYPE_WORD? 2: 1); +} - int start = cx->dis_symbols[i].address; - int size = cx->dis_symbols[i].subtype == TYPE_WORD? 2: 1; - int end = cx->dis_symbols[i].address + cx->dis_symbols[i].count * size - 1; +// Returns the first symbol for that address with the smallest width +static Disasm_symbol *symbol_address(int type, int address) { + int k = find_symbol(type, address), m = k; - if(address >= start && address <= end) { - if(cx->dis_symbols[i].count == 1) { // Single variable - if(size == 1) - return str_ccprintf("%s", cx->dis_symbols[i].name); - return str_ccprintf("_%s8(%s)", address == start? "lo": "hi", cx->dis_symbols[i].name); - } - // Array - if(size == 1) - return str_ccprintf("%s[%d]", cx->dis_symbols[i].name, address - start); - return str_ccprintf("_%s8(%s[%d])", (address - start)%2? "hi": "lo", - cx->dis_symbols[i].name, (address - start)/2); - } - } + if(k < 0) + return NULL; - return NULL; + // Determine m as a matching symbol that has smallest width + Disasm_symbol *s = cx->dis_symbols; + int w, width = symbol_width(s+k); + + for(int i = k-1; i >= 0 && symbol_sort(s+i, s+k) == 0; i--) + if((w = symbol_width(s+i)) <= width) // Want first entry of those with same min width + m = i, width = w; + for(int i = k+1; i < cx->dis_symbolN && symbol_sort(s+i, s+k) == 0; i++) + if((w = symbol_width(s+i)) < width) // < is deliberate, see above + m = i, width = w; + + return s+m; +} + +static const char *resolve_address(int type, int address) { + Disasm_symbol *s = symbol_address(type == 'I' && !cx->dis_io_offset? 'M': type, address); + + if(s && s->name) + s->used = 1; + + return s? s->name: NULL; } // Increase cycle number by 1 if it's a 3 byte PC @@ -397,7 +404,7 @@ static void lineout(const char *code, const char *comment, int match = 0; for(int i = 0; i < cx->dis_jumpcallN; i++) { - if((cx->dis_jumpcalls[i].to) == here) { + if(cx->dis_jumpcalls[i].to == here) { if(!match++) cx->dis_para = 1; disasm_out("; Referenced from L%0*x by %s\n", cx->dis_addrwidth, @@ -513,7 +520,7 @@ static int process_data(const char *buf, int buflen, int pos, int offset) { switch(s->subtype) { case TYPE_BYTE: case TYPE_WORD: - ret += process_num(buf, buflen, s->subtype, pos+ret, offset); + ret += process_num(buf, buflen, s->subtype == TYPE_WORD? 2: 1, pos+ret, offset); break; case TYPE_ASTRING: case TYPE_STRING: @@ -533,19 +540,6 @@ static int process_data(const char *buf, int buflen, int pos, int offset) { return ret; } -static const char *resolve_io_register(int Number) { - for(int i = 0; i < cx->dis_symbolN; i++) { - if(cx->dis_symbols[i].type != 'I') - continue; - if(cx->dis_symbols[i].address == Number) { - cx->dis_symbols[i].used = 1; - return cx->dis_symbols[i].name; - } - } - - return NULL; -} - void emit_used_io_registers() { int maxlen = 0; @@ -557,7 +551,7 @@ void emit_used_io_registers() { } for(int i = 0; i < cx->dis_symbolN; i++) - if(cx->dis_symbols[i].used) + if(cx->dis_symbols[i].used && (cx->dis_io_offset || cx->dis_symbols[i].type == 'M')) disasm_out(".equ %s,%*s 0x%02x\n", cx->dis_symbols[i].name, (int) (maxlen-strlen(cx->dis_symbols[i].name)), "", cx->dis_symbols[i].address); } @@ -573,9 +567,9 @@ static void register_jumpcall(int from, int to, int mnemo, unsigned char is_func Disasm_jumpcall *jc = cx->dis_jumpcalls; int N = cx->dis_jumpcallN; - // Already entered this JC? + // Already entered this jumpcall? for(int i = 0; i < N; i++) - if(jc[i].from == from && jc[N].to == to && jc[N].mnemo == mnemo) + if(jc[i].from == from && jc[i].to == to && jc[i].mnemo == mnemo) return; if(N % 1024 == 0) @@ -610,8 +604,12 @@ static void correct_is_funct(void) { cx->dis_jumpcalls[j].is_func = cur_is_func; } -static int jumpcall_sort(const void *p1, const void *p2) { - return ((Disasm_jumpcall *) p1)->to - ((Disasm_jumpcall *) p2)->to; +static int jumpcall_sort(const void *v1, const void *v2) { + const Disasm_jumpcall *p1 = v1, *p2 = v2; + int diff; + if((diff = p1->to - p2->to)) + return diff; + return p1->from - p2->from; } static void enumerate_labels(void) { @@ -762,7 +760,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, int target = 0, offset = 0, is_jumpcall = 0, is_relative = 0; int is_function = !!(oc->type & OTY_EXTERNAL); // call/rcall affects stack memory - const char *kmemaddr = NULL, *amemaddr = NULL, *regname = NA? resolve_io_register(RA): NULL; + const char *kmemaddr = NULL, *amemaddr = NULL, *regname = NA? resolve_address('I', RA): NULL; if(Na) { /* @@ -771,7 +769,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, * ADDR[7:0] ← (/a[4], a[4], a[6], a[5], a[3], a[2], a[1], a[0]) */ Ra = (Ra & 0xf) | ((Ra >> 1) & 0x30) | ((Ra & 0x10) << 2) | (((Ra & 0x10) ^ 0x10) << 3); - amemaddr = resolve_mem_address(Ra); + amemaddr = resolve_address('M', Ra); } switch(Nk) { @@ -794,7 +792,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, is_relative = 1; break; case 16: // lds/sts - kmemaddr = resolve_mem_address(Rk); + kmemaddr = resolve_address('M', Rk); break; case 22: if(cx->dis_flashsz && 2*Rk > cx->dis_flashsz) @@ -843,12 +841,12 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, add_operand(lc, "%s", regname); else add_operand(lc, "0x%02x", RA); - lc += strlen(lc); break; case 'a': - add_operand(lc, "0x%02x", Ra); if(amemaddr) - add_comment(line, str_ccprintf("%s", amemaddr)); + add_operand(lc, "%s", amemaddr); + else + add_operand(lc, "0x%02x", Ra); break; case 'k': if(is_jumpcall) { @@ -864,9 +862,10 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, add_operand(lc, "0x%0*x", awd, target); } } else { - add_operand(lc, "0x%0*x", swd, Rk); if(kmemaddr) - add_comment(line, str_ccprintf("%s", kmemaddr)); + add_operand(lc, "%s", kmemaddr); + else + add_operand(lc, "0x%0*x", swd, Rk); } break; case 'b': @@ -994,7 +993,7 @@ int disasm_init(const AVRPART *p) { } cx->dis_cycle_index = avr_get_cycle_index(p); - + cx->dis_io_offset = (mem = avr_locate_io(p))? mem->offset: 0; init_regfile(p); return 0; } diff --git a/src/libavrdude.h b/src/libavrdude.h index 68688a44..40439e07 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1829,7 +1829,7 @@ typedef struct { // Static variables from disasm.c int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth; - int dis_pass, dis_para, dis_cycle_index; + int dis_pass, dis_para, dis_cycle_index, dis_io_offset; Disasm_options dis_opts; int dis_jumpcallN, dis_symbolN, *dis_jumpable, dis_start, dis_end; Disasm_jumpcall *dis_jumpcalls; From d6c970543d4c984144a851fe81ba3bf7737e4cea Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 26 Jul 2024 13:53:34 +0100 Subject: [PATCH 358/422] Only provide main label if not in tagfile --- src/disasm.c | 107 +++++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 35a9ec7e..a2a27aca 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -72,14 +72,36 @@ static int symbol_qsort_stable(const void *v1, const void *v2) { return (char *) v1 - (char *) v2; // Keep original order if same keys (stable sort) } -static int find_symbol(int type, int address) { - Disasm_symbol key, *found; +static char *cleanup(char *str) { + for(char *s = str; *s; s++) + *s = *s == '.' || isalnum(*s & 0xff)? *s: '_'; + return str; +} + +// Width of memory a symbol covers (only valid for I/O and memory symbols) +static int symbol_width(Disasm_symbol *s) { + return s->count * (s->subtype == TYPE_WORD? 2: 1); +} + +static Disasm_symbol *find_symbol(int type, int address) { + Disasm_symbol key, *s = cx->dis_symbols, *found; key.type = type; key.address = address; - found = bsearch(&key, cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort); + if(!(found = bsearch(&key, s, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort))) + return NULL; - return found? found - cx->dis_symbols: -1; + // Determine m as first matching symbol that has smallest width + int k = found - s, m = k, w, width = symbol_width(s+k); + + for(int i = k-1; i >= 0 && symbol_sort(s+i, s+k) == 0; i--) + if((w = symbol_width(s+i)) <= width) // Want first entry of those with same min width + m = i, width = w; + for(int i = k+1; i < cx->dis_symbolN && symbol_sort(s+i, s+k) == 0; i++) + if((w = symbol_width(s+i)) < width) // < is deliberate, see above + m = i, width = w; + + return s+m; } static void add_symbol(int address, int type, int subtype, int count, const char *name, const char *comment) { @@ -91,7 +113,7 @@ static void add_symbol(int address, int type, int subtype, int count, const char cx->dis_symbols[N].subtype = subtype; cx->dis_symbols[N].count = count; cx->dis_symbols[N].used = 0; - cx->dis_symbols[N].name = name? mmt_strdup(name): NULL; + cx->dis_symbols[N].name = name? cleanup(mmt_strdup(name)): NULL; cx->dis_symbols[N].comment = comment? mmt_strdup(comment): NULL; } @@ -135,7 +157,7 @@ static int tagfile_readline(char *line, int lineno) { if(type == 'L') { name = token; // Name, comment is optional - add_symbol(address, 'L', 0, 0, name, strtok(NULL, "\t\n")); + add_symbol(address, 'L', 1, 1, name, strtok(NULL, "\t\n")); return 0; } @@ -191,17 +213,14 @@ static int tagfile_readline(char *line, int lineno) { return 0; } -// Allocate, copy, append a suffix (H, L, 0...8 or nothing), make upper case and return +// Allocate, copy, append a suffix (H, L, 0...8 or nothing), cleanup name and return static char *regname(const char *pre, const char *reg, int suf) { char *ret = suf <= -1? str_sprintf("%s%s", pre, reg): suf == 'h' || suf == 'l'? str_sprintf("%s%s%c", pre, reg, suf): str_sprintf("%s%s%d", pre, reg, suf); - for(char *s = ret; *s; s++) - *s = *s == '.'? '_': isascii(*s & 0xff)? toupper(*s & 0xff): *s; - - return ret; + return cleanup(ret); } // Return the basename of a register, ie, the part after the first . (if any) @@ -223,9 +242,9 @@ static const char *shortrname(const Register_file *rf, int nr, int i) { } static void add_register(int io_off, int addr, const char *name, int suffix) { - add_symbol(io_off+addr, 'M', TYPE_BYTE, 1, regname(io_off? "MEM_": "", name, suffix), NULL); + add_symbol(io_off+addr, 'M', TYPE_BYTE, 1, regname(io_off? "mem.": "", name, suffix), NULL); if(addr < 0x40 && io_off) // Only keep I/O addresses separate if memory addresses have an offset - add_symbol(addr, 'I', TYPE_BYTE, 1, regname(io_off? "IO_": "", name, suffix), NULL); + add_symbol(addr, 'I', TYPE_BYTE, 1, regname(io_off? "io.": "", name, suffix), NULL); } // Initialise cx->dis_symbols from part register file @@ -282,34 +301,8 @@ error: return -1; } -// Width of memory a symbol covers (only valid for I/O and memory symbols) -static int symbol_width(Disasm_symbol *s) { - return s->count * (s->subtype == TYPE_WORD? 2: 1); -} - -// Returns the first symbol for that address with the smallest width -static Disasm_symbol *symbol_address(int type, int address) { - int k = find_symbol(type, address), m = k; - - if(k < 0) - return NULL; - - // Determine m as a matching symbol that has smallest width - Disasm_symbol *s = cx->dis_symbols; - int w, width = symbol_width(s+k); - - for(int i = k-1; i >= 0 && symbol_sort(s+i, s+k) == 0; i--) - if((w = symbol_width(s+i)) <= width) // Want first entry of those with same min width - m = i, width = w; - for(int i = k+1; i < cx->dis_symbolN && symbol_sort(s+i, s+k) == 0; i++) - if((w = symbol_width(s+i)) < width) // < is deliberate, see above - m = i, width = w; - - return s+m; -} - static const char *resolve_address(int type, int address) { - Disasm_symbol *s = symbol_address(type == 'I' && !cx->dis_io_offset? 'M': type, address); + Disasm_symbol *s = find_symbol(type == 'I' && !cx->dis_io_offset? 'M': type, address); if(s && s->name) s->used = 1; @@ -332,11 +325,11 @@ static const char *cycles(int mnemo) { } static const char *get_label_name(int destination, char **comment) { - int index = find_symbol('L', destination); - if(index >= 0) { + Disasm_symbol *s = find_symbol('L', destination); + if(s) { if(comment) - *comment = cx->dis_symbols[index].comment; - return cx->dis_symbols[index].name; + *comment = s->comment; + return s->name; } for(int i = 0; i < cx->dis_jumpcallN; i++) @@ -491,16 +484,17 @@ static int process_string(const char *buf, int buflen, int pos, int offset) { // Returns number of bytes of PGM data at this position, printing them in pass 2 static int process_data(const char *buf, int buflen, int pos, int offset) { - int ret = 0, index = find_symbol('P', disasm_wrap(pos + offset)); - if(index < 0) { + int ret = 0; + Disasm_symbol *s = find_symbol('P', disasm_wrap(pos + offset)); + if(!s) { if(pos+1 >= buflen) return 0; - if((index = find_symbol('P', disasm_wrap(pos + offset + 1))) < 0) { // No PGM label, check for fill block + if(!(s = find_symbol('P', disasm_wrap(pos + offset + 1)))) { // No PGM label, check for fill block int k = 0; if((buf[pos] &0xff) == 0xff && (buf[pos+1] & 0xff) == 0xff) for(k=pos+2; k= 0) + if((buf[k] & 0xff) != 0xff || find_symbol('P', disasm_wrap(k + offset))) break; k &= ~1; return !k || k-pos < 4? 0: process_fill0xff(buf, buflen, k-pos, pos, offset); @@ -509,7 +503,6 @@ static int process_data(const char *buf, int buflen, int pos, int offset) { process_num(buf, buflen, 1, pos, offset); ret = 1; } - Disasm_symbol *s = cx->dis_symbols + index; if(s->name) { cx->dis_para = 1; @@ -904,6 +897,20 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, *lc = 0; } +// Is there a label called main and it is used as a destination by disasm()? +static int have_own_main() { + int mainaddr = -1; + Disasm_symbol *s = cx->dis_symbols; + for(int i = 0; i < cx->dis_symbolN; i++) + if(s[i].type == 'L' && s[i].name && str_eq(s[i].name, "main")) + mainaddr = s[i].address; + if(mainaddr >= 0) + for(int i = 0; i < cx->dis_jumpcallN; i++) + if(cx->dis_jumpcalls[i].to == mainaddr) + return 1; + return 0; +} + /* * Disassemble buflen bytes at buf which corresponds to address addr * @@ -931,7 +938,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { emit_used_io_registers(); if(cx->dis_opts.show_gcc_source) { cx->dis_para=1; - disasm_out(".text\nmain:\n"); + disasm_out(".text%s\n", have_own_main()? "": "main:\n"); } } for(pos = 0; pos < buflen; pos += oplen) { From c0aa3b68de662eb38c34414867d407d1d5dce191 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 26 Jul 2024 14:49:42 +0100 Subject: [PATCH 359/422] Rename gcc isr vector numbers with isr names --- src/disasm.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index a2a27aca..9b209ea3 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -125,9 +125,9 @@ static int line_error(const char *token, const char *message, int lineno) { return 0; } -static int tagfile_readline(char *line, int lineno) { +static int tagfile_readline(char *line, int lineno, const char * const *isrnames, int ni) { char *token, type, subtype, *name; - int address, count; + int vn, address, count; const char *errptr; if(line[0] == '#' || strlen(line) <= 1) @@ -157,7 +157,12 @@ static int tagfile_readline(char *line, int lineno) { if(type == 'L') { name = token; // Name, comment is optional - add_symbol(address, 'L', 1, 1, name, strtok(NULL, "\t\n")); + + if(str_starts(name, "__vector_") && looks_like_number(name + 9)) + if((vn = strtol(name+9, NULL, 0)) > 0 && vn < ni) // Don't replace __vectors_0 + name = str_lc((char *) str_ccprintf("__vector_%s", isrnames[vn])); + + add_symbol(address, 'L', TYPE_BYTE, 1, name, strtok(NULL, "\t\n")); return 0; } @@ -253,7 +258,7 @@ static void init_regfile(const AVRPART *p) { const Register_file *rf = avr_locate_register_file(p, &nr); if(rf) { - for(int i = 0; i< nr; i++) { + for(int i = 0; i < nr; i++) { const char *rname = io_off? shortrname(rf, nr, i): rf[i].reg; if(rf[i].size == 1) { @@ -272,8 +277,9 @@ static void init_regfile(const AVRPART *p) { int disasm_init_tagfile(const AVRPART *p, const char *fname) { FILE *inf = fopen(fname, "r"); - int lineno = 1; + int ni = 0, lineno = 1; const char *errstr; + const char * const * isrnames = avr_locate_isrtable(p, &ni); if(!inf) { pmsg_ext_error("cannot open tagfile %s: %s\n", fname, strerror(errno)); @@ -284,7 +290,7 @@ int disasm_init_tagfile(const AVRPART *p, const char *fname) { init_regfile(p); for(char *buffer; (buffer = str_fgets(inf, &errstr)); mmt_free(buffer)) - if(tagfile_readline(buffer, lineno++) < 0) + if(tagfile_readline(buffer, lineno++, isrnames, ni) < 0) goto error; if(errstr) { @@ -970,6 +976,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { return 0; } +// Should be called once per terminal session int disasm_init(const AVRPART *p) { AVRMEM *mem; From 68555d16888269961e73107e6d72a632be97b436 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 26 Jul 2024 16:15:37 +0100 Subject: [PATCH 360/422] Refrain from labelling zero-distance rjmps/branches --- src/disasm.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index 9b209ea3..e2433479 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -330,7 +330,7 @@ static const char *cycles(int mnemo) { return ret; } -static const char *get_label_name(int destination, char **comment) { +static const char *get_label_name(int destination, const char **comment) { Disasm_symbol *s = find_symbol('L', destination); if(s) { if(comment) @@ -340,9 +340,9 @@ static const char *get_label_name(int destination, char **comment) { for(int i = 0; i < cx->dis_jumpcallN; i++) if(cx->dis_jumpcalls[i].to == destination) - return str_ccprintf("%s%d", cx->dis_jumpcalls[i].is_func? "subroutine": "label", cx->dis_jumpcalls[i].labelno); + return str_ccprintf("%s%d", cx->dis_jumpcalls[i].is_func? "Subroutine": "Label", cx->dis_jumpcalls[i].labelno); - return "unknown"; + return NULL; } // Wrap around flash @@ -401,6 +401,7 @@ static void lineout(const char *code, const char *comment, if(cx->dis_opts.process_labels && showlabel) { int match = 0; + const char *comment = NULL, *name; for(int i = 0; i < cx->dis_jumpcallN; i++) { if(cx->dis_jumpcalls[i].to == here) { @@ -411,9 +412,7 @@ static void lineout(const char *code, const char *comment, } } - if(match) { - char *comment = NULL; - const char *name = get_label_name(here, &comment); + if(match && (name = get_label_name(here, &comment))) { if(comment == NULL) disasm_out("%s:\n", name); else @@ -777,7 +776,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, case 7: // Branches offset = (int8_t) (Rk<<1); // Sign-extend and multiply by 2 target = disasm_wrap(addr + offset + 2); - if(cx->dis_pass == 1) + if(cx->dis_pass == 1 && offset) register_jumpcall(addr, target, mnemo, 0); is_jumpcall = 1; is_relative = 1; @@ -785,7 +784,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, case 12: offset = (int16_t) (Rk<<4) >> 3; // Sign extend and multiply by 2 target = disasm_wrap(addr + offset + 2); - if(cx->dis_pass == 1) + if(cx->dis_pass == 1 && offset) register_jumpcall(addr, target, mnemo, is_function); is_jumpcall = 1; is_relative = 1; @@ -850,7 +849,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, case 'k': if(is_jumpcall) { const char *name = get_label_name(target, NULL); - if(cx->dis_opts.process_labels && is_jumpable(target)) { + if(name && target != disasm_wrap(addr+2) && cx->dis_opts.process_labels && is_jumpable(target)) { add_operand(lc, "%s", name); add_comment(line, str_ccprintf("L%0*x", awd, target)); } else { From 63e27021e2fa4688ad5c2e831eea7758d45db2d7 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 26 Jul 2024 16:21:33 +0100 Subject: [PATCH 361/422] Give disasm option variables punchier names --- src/disasm.c | 30 +++++++++++------------ src/libavrdude.h | 18 +++++++------- src/term.c | 62 ++++++++++++++++++++++++------------------------ 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index e2433479..4e3c57d6 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -370,13 +370,13 @@ typedef struct { // Column where opcode starts static int codecol() { int ret = 0; - if(cx->dis_opts.show_addresses) + if(cx->dis_opts.addresses) ret += 3 + cx->dis_addrwidth; - if(cx->dis_opts.show_flags) + if(cx->dis_opts.sreg_flags) ret += 9; - if(cx->dis_opts.show_cycles) + if(cx->dis_opts.cycles) ret += 4; - if(cx->dis_opts.show_opcodes) + if(cx->dis_opts.opcode_bytes) ret += 12; return ret? ret+1: 2; @@ -399,7 +399,7 @@ static void lineout(const char *code, const char *comment, int here = disasm_wrap(pos + addr), codewidth = 27; - if(cx->dis_opts.process_labels && showlabel) { + if(cx->dis_opts.labels && showlabel) { int match = 0; const char *comment = NULL, *name; @@ -420,17 +420,17 @@ static void lineout(const char *code, const char *comment, } } - if(cx->dis_opts.show_addresses) + if(cx->dis_opts.addresses) disasm_out("L%0*x: ", cx->dis_addrwidth, here); - if(cx->dis_opts.show_flags) + if(cx->dis_opts.sreg_flags) disasm_out("%s ", mnemo < 0? "--------": avr_opcodes[mnemo].flags); - if(cx->dis_opts.show_cycles) + if(cx->dis_opts.cycles) disasm_out("%3s ", cycles(mnemo)); - if(cx->dis_opts.show_opcodes) + if(cx->dis_opts.opcode_bytes) for(int i = 0; i < 4; i++) disasm_out(i < oplen? "%02x ": " ", buf[pos + i] & 0xff); disasm_out(codecol() > 2? " ": " "); - if(!comment || !*comment || !cx->dis_opts.show_comments) + if(!comment || !*comment || !cx->dis_opts.comments) disasm_out("%s\n", code); else disasm_out("%-*s ; %s\n", codewidth, code, comment); @@ -561,7 +561,7 @@ void disasm_zap_jumpcalls() { } static void register_jumpcall(int from, int to, int mnemo, unsigned char is_func) { - if(cx->dis_opts.process_labels) { + if(cx->dis_opts.labels) { Disasm_jumpcall *jc = cx->dis_jumpcalls; int N = cx->dis_jumpcallN; @@ -849,7 +849,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, case 'k': if(is_jumpcall) { const char *name = get_label_name(target, NULL); - if(name && target != disasm_wrap(addr+2) && cx->dis_opts.process_labels && is_jumpable(target)) { + if(name && target != disasm_wrap(addr+2) && cx->dis_opts.labels && is_jumpable(target)) { add_operand(lc, "%s", name); add_comment(line, str_ccprintf("L%0*x", awd, target)); } else { @@ -893,9 +893,9 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, } lc += strlen(lc); } - if(cx->dis_opts.show_name) + if(cx->dis_opts.op_names) add_comment(line, avr_opcodes[mnemo].description); - if(cx->dis_opts.show_explanation) + if(cx->dis_opts.op_explanations) add_comment(line, avr_opcodes[mnemo].operation); // Trim trailing spaces while(--lc >= line->code && *lc == ' ') @@ -941,7 +941,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { enumerate_labels(); if(cx->dis_opts.avrgcc_style) emit_used_io_registers(); - if(cx->dis_opts.show_gcc_source) { + if(cx->dis_opts.gcc_source) { cx->dis_para=1; disasm_out(".text%s\n", have_own_main()? "": "main:\n"); } diff --git a/src/libavrdude.h b/src/libavrdude.h index 40439e07..f2532580 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1456,16 +1456,16 @@ typedef enum { } AVR_cycle_index; typedef struct { - int show_gcc_source; - int show_addresses; - int show_opcodes; - int show_comments; - int show_flags; - int show_cycles; - int show_name; - int show_explanation; + int gcc_source; + int addresses; + int opcode_bytes; + int comments; + int sreg_flags; + int cycles; + int op_names; + int op_explanations; int avrgcc_style; - int process_labels; + int labels; int avrlevel; char *tagfile; } Disasm_options; diff --git a/src/term.c b/src/term.c index 17d43a50..d28685b6 100644 --- a/src/term.c +++ b/src/term.c @@ -214,16 +214,16 @@ static int hexdump_buf(const FILE *f, const AVRMEM *m, int startaddr, const unsi static int disasm_ison(char c) { switch(c) { - case 'g': return !!cx->dis_opts.show_gcc_source; - case 'a': return !!cx->dis_opts.show_addresses; - case 'o': return !!cx->dis_opts.show_opcodes; - case 'c': return !!cx->dis_opts.show_comments; - case 'f': return !!cx->dis_opts.show_flags; - case 'q': return !!cx->dis_opts.show_cycles; - case 'n': return !!cx->dis_opts.show_name; - case 'e': return !!cx->dis_opts.show_explanation; + case 'g': return !!cx->dis_opts.gcc_source; + case 'a': return !!cx->dis_opts.addresses; + case 'o': return !!cx->dis_opts.opcode_bytes; + case 'c': return !!cx->dis_opts.comments; + case 'f': return !!cx->dis_opts.sreg_flags; + case 'q': return !!cx->dis_opts.cycles; + case 'n': return !!cx->dis_opts.op_names; + case 'e': return !!cx->dis_opts.op_explanations; case 's': return !!cx->dis_opts.avrgcc_style; - case 'l': return !!cx->dis_opts.process_labels; + case 'l': return !!cx->dis_opts.labels; case 'd': return cx->dis_opts.avrlevel == (PART_ALL | OP_AVR_ILL); } return 0; @@ -488,16 +488,16 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c int help = 0, invalid = 0, itemac = 1, chr; if(!cx->dis_initopts) { - cx->dis_opts.show_gcc_source = 0; - cx->dis_opts.show_addresses = 1; - cx->dis_opts.show_opcodes = 1; - cx->dis_opts.show_comments = 1; - cx->dis_opts.show_flags = 0; - cx->dis_opts.show_cycles = 0; - cx->dis_opts.show_name = 0; - cx->dis_opts.show_explanation = 0; + cx->dis_opts.gcc_source = 0; + cx->dis_opts.addresses = 1; + cx->dis_opts.opcode_bytes = 1; + cx->dis_opts.comments = 1; + cx->dis_opts.sreg_flags = 0; + cx->dis_opts.cycles = 0; + cx->dis_opts.op_names = 0; + cx->dis_opts.op_explanations = 0; cx->dis_opts.avrgcc_style = 1; - cx->dis_opts.process_labels = 1; + cx->dis_opts.labels = 1; cx->dis_opts.tagfile = NULL; cx->dis_opts.avrlevel = avr_get_archlevel(p); disasm_init(p); @@ -516,40 +516,40 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c help++; break; case 'g': case 'G': - cx->dis_opts.show_gcc_source = !!islower(chr); - if(cx->dis_opts.show_gcc_source) { - cx->dis_opts.show_opcodes = 0; - cx->dis_opts.show_flags = 0; - cx->dis_opts.show_cycles = 0; + cx->dis_opts.gcc_source = !!islower(chr); + if(cx->dis_opts.gcc_source) { + cx->dis_opts.opcode_bytes = 0; + cx->dis_opts.sreg_flags = 0; + cx->dis_opts.cycles = 0; cx->dis_opts.avrgcc_style = 1; } break; case 'a': case 'A': - cx->dis_opts.show_addresses = !!islower(chr); + cx->dis_opts.addresses = !!islower(chr); break; case 'o': case 'O': - cx->dis_opts.show_opcodes = !!islower(chr); + cx->dis_opts.opcode_bytes = !!islower(chr); break; case 'c': case 'C': - cx->dis_opts.show_comments = !!islower(chr); + cx->dis_opts.comments = !!islower(chr); break; case 'f': case 'F': - cx->dis_opts.show_flags = !!islower(chr); + cx->dis_opts.sreg_flags = !!islower(chr); break; case 'q': case 'Q': - cx->dis_opts.show_cycles = !!islower(chr); + cx->dis_opts.cycles = !!islower(chr); break; case 'n': case 'N': - cx->dis_opts.show_name = !!islower(chr); + cx->dis_opts.op_names = !!islower(chr); break; case 'e': case 'E': - cx->dis_opts.show_explanation = !!islower(chr); + cx->dis_opts.op_explanations = !!islower(chr); break; case 's': case 'S': cx->dis_opts.avrgcc_style = !!islower(chr); break; case 'l': case 'L': - cx->dis_opts.process_labels = !!islower(chr); + cx->dis_opts.labels = !!islower(chr); break; case 'z': disasm_zap_jumpcalls(); From 8001aedfae305ee7a293a034b5b8cb2ee97d4b49 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 26 Jul 2024 16:45:07 +0100 Subject: [PATCH 362/422] Write is_opcode32() and ldi_register() in terms of mnemonics --- src/avr_opcodes.c | 31 +++++++++++++------------------ src/libavrdude.h | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 49df7a30..ea246c6a 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -77,7 +77,7 @@ * - Source: Table was curated from https://github.com/nlitsme/AVRInstructionSet */ -const AVR_opcode_data avr_opcodes[164] = { +const AVR_opcode_data avr_opcodes[OPCODE_N] = { #define OP_ID(nam) OPCODE_##nam, #nam // Arithmetic and Logic Instructions @@ -590,29 +590,24 @@ const AVR_opcode_data avr_opcodes[164] = { {"1-3", "1-3", "1-3", "1/2"}, ""}, }; +// Return whether or not the given 16-bit opcode is the mnemonic +int op16_is_mnemo(int op, int mnemo) { + return mnemo < 0 || mnemo >= OPCODE_N? 0: + (op & avr_opcodes[mnemo].mask) != avr_opcodes[mnemo].value? 0: + !(avr_opcodes[mnemo].type & OTY_CONSTRAINT)? 1: + (op>>0 & 15) == (op>>4 & 15) && (op>>9 & 1) == (op>>8 & 1); // Constraint Rd == Rr +} + // Return whether or not the given 16-bit opcode has a 16-bit address argument int is_opcode32(int op) { return - (op & 0xfe0e) == 0x940e || // call - (op & 0xfe0e) == 0x940c || // jmp - (op & 0xfe0f) == 0x9200 || // sts - (op & 0xfe0f) == 0x9000; // lds + op16_is_mnemo(op, OPCODE_call) || op16_is_mnemo(op, OPCODE_jmp) || + op16_is_mnemo(op, OPCODE_sts) || op16_is_mnemo(op, OPCODE_lds); } // Return the register number of the 16-bit ldi opcode (and 0 if it's not ldi) int ldi_register(int op) { - return (op & 0xf000) == 0xe000? 16 + ((op >> 4) & 15): 0; -} - -// Does the 16-bit opcode match the avr_opcodes table entry for mnemo? -int opcode_match(int op, AVR_opcode mnemo) { - if((op & avr_opcodes[mnemo].mask) == avr_opcodes[mnemo].value) { - if(!(avr_opcodes[mnemo].type & OTY_CONSTRAINT)) - return 1; - // Match constraint Rd == Rr as in "0010 00r= rrrr ====" - return (op>>0 & 15) == (op>>4 & 15) && (op>>9 & 1) == (op>>8 & 1); - } - return 0; + return op16_is_mnemo(op, OPCODE_ldi)? 16 + ((op >> 4) & 15): 0; } // Returns bitmask of first character chr in bits @@ -628,7 +623,7 @@ static int bitmask_first_chr(const char *bits, int chr) { AVR_opcode opcode_mnemo(int op, int avrlevel) { for(AVR_opcode i = 0; i < OPCODE_N; i++) if(avr_opcodes[i].avrlevel & avrlevel) - if(opcode_match(op, i)) { + if(op16_is_mnemo(op, i)) { if(avrlevel == PART_AVR_RC && (avr_opcodes[i].type & OTY_REG_MASK) == OTY_RALL) { // Reduced-core ATtiny does not have registers r0, ..., r15 int bmask; // Assert highest bit in 5-bit r/d is set diff --git a/src/libavrdude.h b/src/libavrdude.h index f2532580..d1f76bc4 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1726,7 +1726,7 @@ char *avr_cc_buffer(size_t n); int is_opcode32(int op); int ldi_register(int op); -int opcode_match(int op, AVR_opcode mnemo); +int op16_is_mnemo(int op, AVR_opcode mnemo); AVR_opcode opcode_mnemo(int op, int avrlevel); int avr_get_archlevel(const AVRPART *p); AVR_cycle_index avr_get_cycle_index(const AVRPART *p); From 16c3eedc53097ffcd37383b060b5731ee484a0b9 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 26 Jul 2024 16:53:37 +0100 Subject: [PATCH 363/422] Consistently use mnemo and opcode terminology - ldi is the mnemonic - Opcode is the (mostly 16-bit) machine instruction --- src/avr_opcodes.c | 26 ++++++------- src/disasm.c | 22 +++++------ src/libavrdude.h | 98 +++++++++++++++++++++++------------------------ 3 files changed, 71 insertions(+), 75 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index ea246c6a..2c9a7570 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -23,7 +23,7 @@ /* * AVR opcode table * - * - Order of enums OPCODE_... in libavedude.h must align with table + * - Order of enums MNEMO_... in libavedude.h must align with table * * - Order makes the first match of a 16-bit opcode a "good" one * + Unallocated opcodes come last @@ -77,8 +77,8 @@ * - Source: Table was curated from https://github.com/nlitsme/AVRInstructionSet */ -const AVR_opcode_data avr_opcodes[OPCODE_N] = { -#define OP_ID(nam) OPCODE_##nam, #nam +const AVR_opcode avr_opcodes[MNEMO_N] = { +#define OP_ID(nam) MNEMO_##nam, #nam // Arithmetic and Logic Instructions {OP_ID(lsl), 0xfc00, 0x0c00, 1, OP_AVR1, "0000 11d= dddd ====", OTY_ALBI|OTY_RALL|OTY_CONSTRAINT, @@ -592,7 +592,7 @@ const AVR_opcode_data avr_opcodes[OPCODE_N] = { // Return whether or not the given 16-bit opcode is the mnemonic int op16_is_mnemo(int op, int mnemo) { - return mnemo < 0 || mnemo >= OPCODE_N? 0: + return mnemo < 0 || mnemo >= MNEMO_N? 0: (op & avr_opcodes[mnemo].mask) != avr_opcodes[mnemo].value? 0: !(avr_opcodes[mnemo].type & OTY_CONSTRAINT)? 1: (op>>0 & 15) == (op>>4 & 15) && (op>>9 & 1) == (op>>8 & 1); // Constraint Rd == Rr @@ -601,13 +601,13 @@ int op16_is_mnemo(int op, int mnemo) { // Return whether or not the given 16-bit opcode has a 16-bit address argument int is_opcode32(int op) { return - op16_is_mnemo(op, OPCODE_call) || op16_is_mnemo(op, OPCODE_jmp) || - op16_is_mnemo(op, OPCODE_sts) || op16_is_mnemo(op, OPCODE_lds); + op16_is_mnemo(op, MNEMO_call) || op16_is_mnemo(op, MNEMO_jmp) || + op16_is_mnemo(op, MNEMO_sts) || op16_is_mnemo(op, MNEMO_lds); } // Return the register number of the 16-bit ldi opcode (and 0 if it's not ldi) int ldi_register(int op) { - return op16_is_mnemo(op, OPCODE_ldi)? 16 + ((op >> 4) & 15): 0; + return op16_is_mnemo(op, MNEMO_ldi)? 16 + ((op >> 4) & 15): 0; } // Returns bitmask of first character chr in bits @@ -619,22 +619,22 @@ static int bitmask_first_chr(const char *bits, int chr) { return ret; } -// Return first match of opcode that is compatible with avrlevel or OPCODE_NONE -AVR_opcode opcode_mnemo(int op, int avrlevel) { - for(AVR_opcode i = 0; i < OPCODE_N; i++) +// Return first match of opcode that is compatible with avrlevel or MNEMO_NONE +AVR_mnemo opcode_mnemo(int op, int avrlevel) { + for(AVR_mnemo i = 0; i < MNEMO_N; i++) if(avr_opcodes[i].avrlevel & avrlevel) if(op16_is_mnemo(op, i)) { if(avrlevel == PART_AVR_RC && (avr_opcodes[i].type & OTY_REG_MASK) == OTY_RALL) { // Reduced-core ATtiny does not have registers r0, ..., r15 int bmask; // Assert highest bit in 5-bit r/d is set if((bmask = bitmask_first_chr(avr_opcodes[i].bits, 'r')) && !(op & bmask)) - return OPCODE_NONE; + return MNEMO_NONE; if((bmask = bitmask_first_chr(avr_opcodes[i].bits, 'd')) && !(op & bmask)) - return OPCODE_NONE; + return MNEMO_NONE; } return i; } - return OPCODE_NONE; + return MNEMO_NONE; } // Opcodes in avr_opcodes[] that a part ought to be able to run diff --git a/src/disasm.c b/src/disasm.c index 4e3c57d6..b0545ec8 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -434,7 +434,7 @@ static void lineout(const char *code, const char *comment, disasm_out("%s\n", code); else disasm_out("%-*s ; %s\n", codewidth, code, comment); - if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_reti || mnemo == OPCODE_u_reti) + if(mnemo == MNEMO_ret || mnemo == MNEMO_u_ret || mnemo == MNEMO_reti || mnemo == MNEMO_u_reti) cx->dis_para = 1; } @@ -680,7 +680,7 @@ static unsigned bitcount(unsigned n) { return ret; } -static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, Disasm_line *line) { +static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, Disasm_line *line) { memset(line, 0, sizeof*line); if(mnemo < 0) { add_comment(line, "Invalid opcode"); @@ -688,7 +688,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, return; } - const AVR_opcode_data *oc = avr_opcodes+mnemo; + const AVR_opcode *oc = avr_opcodes+mnemo; int regs[128] = {0}, bits[128] = {0}; unsigned bmask = 0x8000; for(const char *p = oc->bits; *p && bmask; p++) { @@ -727,15 +727,11 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo, if(Ns && Ns != 3) pmsg_warning("unexpected number of s bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); - switch(mnemo) { // Exceptions go here - case OPCODE_andi: // cbr r17, 0x06 is marginally easier to read than andi r17, 0xf9 - if(bitcount(RK) >= 4) { - RK = ~RK & 0xff; - mnemo = OPCODE_cbr; - oc = avr_opcodes+mnemo; - } - default: - break; + // cbr r17, 0x06 is marginally easier to read than andi r17, 0xf9 + if(mnemo == MNEMO_andi && bitcount(RK) >= 4) { + RK = ~RK & 0xff; + mnemo = MNEMO_cbr; + oc = avr_opcodes+mnemo; } // Apply register formula @@ -981,7 +977,7 @@ int disasm_init(const AVRPART *p) { // Sanity check (problems only occur if avr_opcodes was changed) for(size_t i = 0; i < sizeof avr_opcodes/sizeof*avr_opcodes; i++) - if(avr_opcodes[i].mnemo != (AVR_opcode) i) { + if(avr_opcodes[i].mnemo != (AVR_mnemo) i) { msg_error("avr_opcodes[] table broken (this should never happen)\n"); return -1; } diff --git a/src/libavrdude.h b/src/libavrdude.h index d1f76bc4..ded62d4b 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1489,50 +1489,50 @@ typedef struct { // Order of enums must align with avr_opcodes[] table order typedef enum { - OPCODE_NONE = -1, - OPCODE_lsl, OPCODE_add, OPCODE_rol, OPCODE_adc, - OPCODE_ror, OPCODE_asr, OPCODE_adiw, OPCODE_sub, - OPCODE_subi, OPCODE_sbc, OPCODE_sbci, OPCODE_sbiw, - OPCODE_tst, OPCODE_and, OPCODE_andi, OPCODE_cbr, - OPCODE_or, OPCODE_ori, OPCODE_sbr, OPCODE_clr, - OPCODE_eor, OPCODE_com, OPCODE_neg, OPCODE_inc, - OPCODE_dec, OPCODE_mul, OPCODE_muls, OPCODE_mulsu, - OPCODE_fmul, OPCODE_fmuls, OPCODE_fmulsu, OPCODE_des, - OPCODE_rjmp, OPCODE_ijmp, OPCODE_eijmp, OPCODE_jmp, - OPCODE_rcall, OPCODE_icall, OPCODE_eicall, OPCODE_call, - OPCODE_ret, OPCODE_reti, OPCODE_cpse, OPCODE_cp, - OPCODE_cpc, OPCODE_cpi, OPCODE_sbrc, OPCODE_sbrs, - OPCODE_sbic, OPCODE_sbis, OPCODE_brcs, OPCODE_brlo, - OPCODE_breq, OPCODE_brmi, OPCODE_brvs, OPCODE_brlt, - OPCODE_brhs, OPCODE_brts, OPCODE_brie, OPCODE_brbs, - OPCODE_brcc, OPCODE_brsh, OPCODE_brne, OPCODE_brpl, - OPCODE_brvc, OPCODE_brge, OPCODE_brhc, OPCODE_brtc, - OPCODE_brid, OPCODE_brbc, OPCODE_mov, OPCODE_movw, - OPCODE_ser, OPCODE_ldi, OPCODE_lds, OPCODE_ld_1, - OPCODE_ld_2, OPCODE_ld_3, OPCODE_ld_4, OPCODE_ld_5, - OPCODE_ld_6, OPCODE_ldd_1, OPCODE_ld_7, OPCODE_ld_8, - OPCODE_ld_9, OPCODE_ldd_2, OPCODE_sts, OPCODE_st_1, - OPCODE_st_2, OPCODE_st_3, OPCODE_st_4, OPCODE_st_5, - OPCODE_st_6, OPCODE_std_1, OPCODE_st_7, OPCODE_st_8, - OPCODE_st_9, OPCODE_std_2, OPCODE_lpm_1, OPCODE_lpm_2, - OPCODE_lpm_3, OPCODE_elpm_1, OPCODE_elpm_2, OPCODE_elpm_3, - OPCODE_spm, OPCODE_spm_zz, OPCODE_in, OPCODE_out, - OPCODE_push, OPCODE_pop, OPCODE_xch, OPCODE_las, - OPCODE_lac, OPCODE_lat, OPCODE_lsr, OPCODE_swap, - OPCODE_sbi, OPCODE_cbi, OPCODE_bst, OPCODE_bld, - OPCODE_sec, OPCODE_clc, OPCODE_sen, OPCODE_cln, - OPCODE_sez, OPCODE_clz, OPCODE_sei, OPCODE_cli, - OPCODE_ses, OPCODE_cls, OPCODE_sev, OPCODE_clv, - OPCODE_set, OPCODE_clt, OPCODE_seh, OPCODE_clh, - OPCODE_bset, OPCODE_bclr, OPCODE_break, OPCODE_nop, - OPCODE_sleep, OPCODE_wdr, OPCODE_lds_rc, OPCODE_sts_rc, - OPCODE_u_nop_1, OPCODE_u_nop_2, OPCODE_u_nop_3, OPCODE_u_nop_4, - OPCODE_u_nop_5, OPCODE_u_nop_6, OPCODE_u_nop_7, OPCODE_u_icall, - OPCODE_u_eicall, OPCODE_u_ret, OPCODE_u_reti, OPCODE_u_nop_8, - OPCODE_u_nop_9, OPCODE_u_nop_a, OPCODE_u_ijmp, OPCODE_u_eijmp, - OPCODE_u_bld, OPCODE_u_bst, OPCODE_u_sbrc, OPCODE_u_sbrs, - OPCODE_N -} AVR_opcode; + MNEMO_NONE = -1, + MNEMO_lsl, MNEMO_add, MNEMO_rol, MNEMO_adc, + MNEMO_ror, MNEMO_asr, MNEMO_adiw, MNEMO_sub, + MNEMO_subi, MNEMO_sbc, MNEMO_sbci, MNEMO_sbiw, + MNEMO_tst, MNEMO_and, MNEMO_andi, MNEMO_cbr, + MNEMO_or, MNEMO_ori, MNEMO_sbr, MNEMO_clr, + MNEMO_eor, MNEMO_com, MNEMO_neg, MNEMO_inc, + MNEMO_dec, MNEMO_mul, MNEMO_muls, MNEMO_mulsu, + MNEMO_fmul, MNEMO_fmuls, MNEMO_fmulsu, MNEMO_des, + MNEMO_rjmp, MNEMO_ijmp, MNEMO_eijmp, MNEMO_jmp, + MNEMO_rcall, MNEMO_icall, MNEMO_eicall, MNEMO_call, + MNEMO_ret, MNEMO_reti, MNEMO_cpse, MNEMO_cp, + MNEMO_cpc, MNEMO_cpi, MNEMO_sbrc, MNEMO_sbrs, + MNEMO_sbic, MNEMO_sbis, MNEMO_brcs, MNEMO_brlo, + MNEMO_breq, MNEMO_brmi, MNEMO_brvs, MNEMO_brlt, + MNEMO_brhs, MNEMO_brts, MNEMO_brie, MNEMO_brbs, + MNEMO_brcc, MNEMO_brsh, MNEMO_brne, MNEMO_brpl, + MNEMO_brvc, MNEMO_brge, MNEMO_brhc, MNEMO_brtc, + MNEMO_brid, MNEMO_brbc, MNEMO_mov, MNEMO_movw, + MNEMO_ser, MNEMO_ldi, MNEMO_lds, MNEMO_ld_1, + MNEMO_ld_2, MNEMO_ld_3, MNEMO_ld_4, MNEMO_ld_5, + MNEMO_ld_6, MNEMO_ldd_1, MNEMO_ld_7, MNEMO_ld_8, + MNEMO_ld_9, MNEMO_ldd_2, MNEMO_sts, MNEMO_st_1, + MNEMO_st_2, MNEMO_st_3, MNEMO_st_4, MNEMO_st_5, + MNEMO_st_6, MNEMO_std_1, MNEMO_st_7, MNEMO_st_8, + MNEMO_st_9, MNEMO_std_2, MNEMO_lpm_1, MNEMO_lpm_2, + MNEMO_lpm_3, MNEMO_elpm_1, MNEMO_elpm_2, MNEMO_elpm_3, + MNEMO_spm, MNEMO_spm_zz, MNEMO_in, MNEMO_out, + MNEMO_push, MNEMO_pop, MNEMO_xch, MNEMO_las, + MNEMO_lac, MNEMO_lat, MNEMO_lsr, MNEMO_swap, + MNEMO_sbi, MNEMO_cbi, MNEMO_bst, MNEMO_bld, + MNEMO_sec, MNEMO_clc, MNEMO_sen, MNEMO_cln, + MNEMO_sez, MNEMO_clz, MNEMO_sei, MNEMO_cli, + MNEMO_ses, MNEMO_cls, MNEMO_sev, MNEMO_clv, + MNEMO_set, MNEMO_clt, MNEMO_seh, MNEMO_clh, + MNEMO_bset, MNEMO_bclr, MNEMO_break, MNEMO_nop, + MNEMO_sleep, MNEMO_wdr, MNEMO_lds_rc, MNEMO_sts_rc, + MNEMO_u_nop_1, MNEMO_u_nop_2, MNEMO_u_nop_3, MNEMO_u_nop_4, + MNEMO_u_nop_5, MNEMO_u_nop_6, MNEMO_u_nop_7, MNEMO_u_icall, + MNEMO_u_eicall, MNEMO_u_ret, MNEMO_u_reti, MNEMO_u_nop_8, + MNEMO_u_nop_9, MNEMO_u_nop_a, MNEMO_u_ijmp, MNEMO_u_eijmp, + MNEMO_u_bld, MNEMO_u_bst, MNEMO_u_sbrc, MNEMO_u_sbrs, + MNEMO_N +} AVR_mnemo; typedef enum { OP_AVR_RC = 1, // Reduced-core Tiny only (128 byte STS/LDS) @@ -1605,7 +1605,7 @@ typedef enum { #define OTY_ZWRN 0xc00 // Operand register must not be r29/r30 typedef struct { - AVR_opcode mnemo; // Eg, OPCODE_add + AVR_mnemo mnemo; // Eg, MNEMO_add const char *idname; // Unique id, eg, "ldx_1" (for error msgs or debugging) int mask, value, nwords; AVR_archlevel avrlevel; // OP_AVR1 @@ -1619,9 +1619,9 @@ typedef struct { *flags, // "--HSVNZC" *clock[OP_AVR_cycle_N], // Timings for AVRe, AVRxm, AVRxt and AVRrc *remarks; -} AVR_opcode_data; +} AVR_opcode; -extern const AVR_opcode_data avr_opcodes[164]; +extern const AVR_opcode avr_opcodes[164]; #ifdef __cplusplus extern "C" { @@ -1726,8 +1726,8 @@ char *avr_cc_buffer(size_t n); int is_opcode32(int op); int ldi_register(int op); -int op16_is_mnemo(int op, AVR_opcode mnemo); -AVR_opcode opcode_mnemo(int op, int avrlevel); +int op16_is_mnemo(int op, AVR_mnemo mnemo); +AVR_mnemo opcode_mnemo(int op, int avrlevel); int avr_get_archlevel(const AVRPART *p); AVR_cycle_index avr_get_cycle_index(const AVRPART *p); From 5f3d2b445269c0126fc4c73fb7039210e09b4d6f Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 26 Jul 2024 17:17:17 +0100 Subject: [PATCH 364/422] Provide ldi_Rd() and ldi_K() extractors --- src/avr_opcodes.c | 9 +++++++-- src/disasm.c | 3 ++- src/libavrdude.h | 28 +++++++++------------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 2c9a7570..7c285bc7 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -605,11 +605,16 @@ int is_opcode32(int op) { op16_is_mnemo(op, MNEMO_sts) || op16_is_mnemo(op, MNEMO_lds); } -// Return the register number of the 16-bit ldi opcode (and 0 if it's not ldi) -int ldi_register(int op) { +// Return the register number of the 16-bit ldi opcode and 0 if it's not ldi +int ldi_Rd(int op) { return op16_is_mnemo(op, MNEMO_ldi)? 16 + ((op >> 4) & 15): 0; } +// Return the constant number in the 16-bit ldi opcode and -1 if it's not ldi +int ldi_K(int op) { + return op16_is_mnemo(op, MNEMO_ldi)? ((op & 0x0f00) >> 4) | (op & 0x0f): -1; +} + // Returns bitmask of first character chr in bits static int bitmask_first_chr(const char *bits, int chr) { int ret = 0x8000; diff --git a/src/disasm.c b/src/disasm.c index b0545ec8..b05288c9 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -340,7 +340,8 @@ static const char *get_label_name(int destination, const char **comment) { for(int i = 0; i < cx->dis_jumpcallN; i++) if(cx->dis_jumpcalls[i].to == destination) - return str_ccprintf("%s%d", cx->dis_jumpcalls[i].is_func? "Subroutine": "Label", cx->dis_jumpcalls[i].labelno); + return str_ccprintf("%s%d", cx->dis_jumpcalls[i].is_func? "Subroutine": "Label", + cx->dis_jumpcalls[i].labelno); return NULL; } diff --git a/src/libavrdude.h b/src/libavrdude.h index ded62d4b..d8acc357 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1456,26 +1456,15 @@ typedef enum { } AVR_cycle_index; typedef struct { - int gcc_source; - int addresses; - int opcode_bytes; - int comments; - int sreg_flags; - int cycles; - int op_names; - int op_explanations; - int avrgcc_style; - int labels; - int avrlevel; - char *tagfile; + // Flags how to display lines + int gcc_source, addresses, opcode_bytes, comments, sreg_flags, cycles; + int op_names, op_explanations, avrgcc_style, labels; + int avrlevel; // Eg, PART_AVR_XM or PART_AVR_51 (describes opcodes for the part) + char *tagfile; // Maps addresses to labels, PGM data, memory and I/O variables } Disasm_options; typedef struct { - int from; - int to; - int mnemo; - unsigned int labelno; - int is_func; + int from, to, mnemo, labelno, is_func; } Disasm_jumpcall; typedef struct { @@ -1724,9 +1713,10 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); -int is_opcode32(int op); -int ldi_register(int op); int op16_is_mnemo(int op, AVR_mnemo mnemo); +int is_opcode32(int op); +int ldi_Rd(int op); +int ldi_K(int op); AVR_mnemo opcode_mnemo(int op, int avrlevel); int avr_get_archlevel(const AVRPART *p); AVR_cycle_index avr_get_cycle_index(const AVRPART *p); From 8f7afd6b56672e05d15e2fb19ad8fd4c3d2e4124 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 27 Jul 2024 00:17:00 +0100 Subject: [PATCH 365/422] Make opcode mnemonic variants more memorable --- src/avr_opcodes.c | 66 ++++++++++++++++++++++++++--------------------- src/libavrdude.h | 22 +++++++++------- 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index 7c285bc7..f7127a65 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -310,97 +310,97 @@ const AVR_opcode avr_opcodes[MNEMO_N] = { {OP_ID(lds), 0xfe0f, 0x9000, 2, OP_AVR2nRC, "1001 000d dddd 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, "lds", "Rd, k", "load direct from data space", "Rd <-- (k)", "--------", {"2", "3", "3", "2"}, ""}, - {OP_ID(ld_1), 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, + {OP_ID(ld_x), 0xfe0f, 0x900c, 1, OP_AVR2, "1001 000d dddd 1100", OTY_XFRX|OTY_RALL, "ld", "Rd, X", "load indirect", "Rd <-- (X)", "--------", {"2", "2", "2", "1/2"}, ""}, - {OP_ID(ld_2), 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL|OTY_XWRN, + {OP_ID(ld_xp), 0xfe0f, 0x900d, 1, OP_AVR2, "1001 000d dddd 1101", OTY_XFRX|OTY_RALL|OTY_XWRN, "ld", "Rd, X+", "load indirect and post-increment", "Rd <-- (X), X <-- X + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OP_ID(ld_3), 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL|OTY_XWRN, + {OP_ID(ld_mx), 0xfe0f, 0x900e, 1, OP_AVR2, "1001 000d dddd 1110", OTY_XFRX|OTY_RALL|OTY_XWRN, "ld", "Rd, -X", "load indirect and pre-decrement", "X <-- X - 1, Rd <-- (X)", "--------", {"2", "3", "2", "2/3"}, ""}, - {OP_ID(ld_4), 0xfe0f, 0x8008, 1, OP_AVR2, "1000 000d dddd 1000", OTY_XFRX|OTY_RALL, + {OP_ID(ld_y), 0xfe0f, 0x8008, 1, OP_AVR2, "1000 000d dddd 1000", OTY_XFRX|OTY_RALL, "ld", "Rd, Y", "load indirect", "Rd <-- (Y) <-- (Y)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Y+0"}, - {OP_ID(ld_5), 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL|OTY_YWRN, + {OP_ID(ld_yp), 0xfe0f, 0x9009, 1, OP_AVR2, "1001 000d dddd 1001", OTY_XFRX|OTY_RALL|OTY_YWRN, "ld", "Rd, Y+", "load indirect and post-increment", "Rd <-- (Y), Y <-- Y + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OP_ID(ld_6), 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL|OTY_YWRN, + {OP_ID(ld_my), 0xfe0f, 0x900a, 1, OP_AVR2, "1001 000d dddd 1010", OTY_XFRX|OTY_RALL|OTY_YWRN, "ld", "Rd, -Y", "load indirect and pre-decrement", "Y <-- Y - 1 Rd <-- (Y)", "--------", {"2", "3", "2", "2/3"}, ""}, - {OP_ID(ldd_1), 0xd208, 0x8008, 1, OP_AVR2nRC, "10q0 qq0d dddd 1qqq", OTY_XFRX|OTY_RALL, + {OP_ID(ldd_y), 0xd208, 0x8008, 1, OP_AVR2nRC, "10q0 qq0d dddd 1qqq", OTY_XFRX|OTY_RALL, "ldd", "Rd, Y+q", "load indirect with displacement", "Rd <-- (Y+q)", "--------", {"2", "3", "2", "n/a"}, ""}, - {OP_ID(ld_7), 0xfe0f, 0x8000, 1, OP_AVR1, "1000 000d dddd 0000", OTY_XFRX|OTY_RALL, + {OP_ID(ld_z), 0xfe0f, 0x8000, 1, OP_AVR1, "1000 000d dddd 0000", OTY_XFRX|OTY_RALL, "ld", "Rd, Z", "load indirect", "Rd <-- (Z)", "--------", {"2", "2", "2", "1/2"}, "alias for ldd Rd, Z+0"}, - {OP_ID(ld_8), 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL|OTY_ZWRN, + {OP_ID(ld_zp), 0xfe0f, 0x9001, 1, OP_AVR1, "1001 000d dddd 0001", OTY_XFRX|OTY_RALL|OTY_ZWRN, "ld", "Rd, Z+", "load indirect and post-increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"2", "2", "2", "2/3"}, ""}, - {OP_ID(ld_9), 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL|OTY_ZWRN, + {OP_ID(ld_mz), 0xfe0f, 0x9002, 1, OP_AVR1, "1001 000d dddd 0010", OTY_XFRX|OTY_RALL|OTY_ZWRN, "ld", "Rd, -Z", "load indirect and pre-decrement", "Z <-- Z - 1, Rd <-- (Z)", "--------", {"2", "3", "2", "2/3"}, ""}, - {OP_ID(ldd_2), 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, + {OP_ID(ldd_z), 0xd208, 0x8000, 1, OP_AVR2nRC, "10q0 qq0d dddd 0qqq", OTY_XFRX|OTY_RALL, "ldd", "Rd, Z+q", "load indirect with displacement", "Rd <-- (Z+q)", "--------", {"2", "3", "2", "n/a"}, ""}, {OP_ID(sts), 0xfe0f, 0x9200, 2, OP_AVR2nRC, "1001 001r rrrr 0000 kkkk kkkk kkkk kkkk", OTY_XFRX|OTY_RALL, "sts", "k, Rr", "store direct to data space", "(k) <-- Rr", "--------", {"2", "2", "2", "1"}, ""}, - {OP_ID(st_1), 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, + {OP_ID(st_x), 0xfe0f, 0x920c, 1, OP_AVR2, "1001 001r rrrr 1100", OTY_XFRX|OTY_RALL, "st", "X, Rr", "store indirect", "(X) <-- Rr", "--------", {"2", "1", "1", "1"}, ""}, - {OP_ID(st_2), 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL|OTY_XWRN, + {OP_ID(st_xp), 0xfe0f, 0x920d, 1, OP_AVR2, "1001 001r rrrr 1101", OTY_XFRX|OTY_RALL|OTY_XWRN, "st", "X+, Rr", "store indirect and post-increment", "(X) <-- Rr, X <-- X + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OP_ID(st_3), 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL|OTY_XWRN, + {OP_ID(st_mx), 0xfe0f, 0x920e, 1, OP_AVR2, "1001 001r rrrr 1110", OTY_XFRX|OTY_RALL|OTY_XWRN, "st", "-X, Rr", "store indirect and pre-decrement", "X <-- X - 1, (X) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, - {OP_ID(st_4), 0xfe0f, 0x8208, 1, OP_AVR2, "1000 001r rrrr 1000", OTY_XFRX|OTY_RALL, + {OP_ID(st_y), 0xfe0f, 0x8208, 1, OP_AVR2, "1000 001r rrrr 1000", OTY_XFRX|OTY_RALL, "st", "Y, Rr", "store indirect", "(Y) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Y+0, Rr"}, - {OP_ID(st_5), 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL|OTY_YWRN, + {OP_ID(st_yp), 0xfe0f, 0x9209, 1, OP_AVR2, "1001 001r rrrr 1001", OTY_XFRX|OTY_RALL|OTY_YWRN, "st", "Y+, Rr", "store indirect and post-increment", "(Y) <-- Rr, Y <-- Y + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OP_ID(st_6), 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL|OTY_YWRN, + {OP_ID(st_my), 0xfe0f, 0x920a, 1, OP_AVR2, "1001 001r rrrr 1010", OTY_XFRX|OTY_RALL|OTY_YWRN, "st", "-Y, Rr", "store indirect and pre-decrement", "Y <-- Y - 1, (Y) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, - {OP_ID(std_1), 0xd208, 0x8208, 1, OP_AVR2nRC, "10q0 qq1r rrrr 1qqq", OTY_XFRX|OTY_RALL, + {OP_ID(std_y), 0xd208, 0x8208, 1, OP_AVR2nRC, "10q0 qq1r rrrr 1qqq", OTY_XFRX|OTY_RALL, "std", "Y+q, Rr", "store indirect with displacement", "(Y+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, - {OP_ID(st_7), 0xfe0f, 0x8200, 1, OP_AVR1, "1000 001r rrrr 0000", OTY_XFRX|OTY_RALL, + {OP_ID(st_z), 0xfe0f, 0x8200, 1, OP_AVR1, "1000 001r rrrr 0000", OTY_XFRX|OTY_RALL, "st", "Z, Rr", "store indirect", "(Z) <-- Rr", "--------", {"2", "1", "1", "1"}, "alias for std Z+0, Rr"}, - {OP_ID(st_8), 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL|OTY_ZWRN, + {OP_ID(st_zp), 0xfe0f, 0x9201, 1, OP_AVR1, "1001 001r rrrr 0001", OTY_XFRX|OTY_RALL|OTY_ZWRN, "st", "Z+, Rr", "store indirect and post-increment", "(Z) <-- Rr, Z <-- Z + 1", "--------", {"2", "1", "1", "1"}, ""}, - {OP_ID(st_9), 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL|OTY_ZWRN, + {OP_ID(st_mz), 0xfe0f, 0x9202, 1, OP_AVR1, "1001 001r rrrr 0010", OTY_XFRX|OTY_RALL|OTY_ZWRN, "st", "-Z, Rr", "store indirect and pre-decrement", "Z <-- Z - 1, (Z) <-- Rr", "--------", {"2", "2", "1", "1"}, ""}, - {OP_ID(std_2), 0xd208, 0x8200, 1, OP_AVR2nRC, "10q0 qq1r rrrr 0qqq", OTY_XFRX|OTY_RALL, + {OP_ID(std_z), 0xd208, 0x8200, 1, OP_AVR2nRC, "10q0 qq1r rrrr 0qqq", OTY_XFRX|OTY_RALL, "std", "Z+q, Rr", "store indirect with displacement", "(Z+q) <-- Rr", "--------", {"2", "2", "1", "n/a"}, ""}, - {OP_ID(lpm_1), 0xffff, 0x95c8, 1, OP_AVR1nRC, "1001 0101 1100 1000", OTY_XFRX, + {OP_ID(lpm_0), 0xffff, 0x95c8, 1, OP_AVR1nRC, "1001 0101 1100 1000", OTY_XFRX, "lpm", "", "load program memory", "R0 <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OP_ID(lpm_2), 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, + {OP_ID(lpm_z), 0xfe0f, 0x9004, 1, OP_AVR25, "1001 000d dddd 0100", OTY_XFRX|OTY_RALL, "lpm", "Rd, Z", "load program memory", "Rd <-- (Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OP_ID(lpm_3), 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL|OTY_ZWRN, + {OP_ID(lpm_zp), 0xfe0f, 0x9005, 1, OP_AVR25, "1001 000d dddd 0101", OTY_XFRX|OTY_RALL|OTY_ZWRN, "lpm", "Rd, Z+", "load program memory and post-increment", "Rd <-- (Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, - {OP_ID(elpm_1), 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, + {OP_ID(elpm_0), 0xffff, 0x95d8, 1, OP_AVR_L, "1001 0101 1101 1000", OTY_XFRX, "elpm", "", "extended load program memory", "R0 <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OP_ID(elpm_2), 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, + {OP_ID(elpm_z), 0xfe0f, 0x9006, 1, OP_AVR_L, "1001 000d dddd 0110", OTY_XFRX|OTY_RALL, "elpm", "Rd, Z", "extended load program memory", "Rd <-- (RAMPZ:Z)", "--------", {"3", "3", "3", "n/a"}, ""}, - {OP_ID(elpm_3), 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL|OTY_ZWRN, + {OP_ID(elpm_zp), 0xfe0f, 0x9007, 1, OP_AVR_L, "1001 000d dddd 0111", OTY_XFRX|OTY_RALL|OTY_ZWRN, "elpm", "Rd, Z+", "extended load program memory and post-increment", "Rd <-- (RAMPZ:Z), Z <-- Z + 1", "--------", {"3", "3", "3", "n/a"}, ""}, {OP_ID(spm), 0xffff, 0x95e8, 1, OP_AVR25, "1001 0101 1110 1000", OTY_XFRX, "spm", "", "store program memory", "(RAMPZ:Z) <-- R1:R0", "--------", {"-", "-", "-", "-"}, ""}, - {OP_ID(spm_zz), 0xffff, 0x95f8, 1, OP_AVR_XTM, "1001 0101 1111 1000", OTY_XFRX, + {OP_ID(spm_zp), 0xffff, 0x95f8, 1, OP_AVR_XTM, "1001 0101 1111 1000", OTY_XFRX, "spm", "Z+", "store program memory and post-increment by 2", "(RAMPZ:Z) <-- R1:R0, Z <-- Z + 2", "--------", {"n/a", "-", "-", "n/a"}, ""}, {OP_ID(in), 0xf800, 0xb000, 1, OP_AVR1, "1011 0AAd dddd AAAA", OTY_XFRX|OTY_RALL, @@ -699,3 +699,11 @@ AVR_cycle_index avr_get_cycle_index(const AVRPART *p) { p->prog_modes & PM_PDI? OP_AVRxm: p->prog_modes & PM_TPI? OP_AVRrc: OP_AVRe; } + +// Return the mnemonic string of an opcode +const char *mnemo_str(int op) { + AVR_mnemo mnemo = opcode_mnemo(op, PART_ALL | OP_AVR_ILL); + if(mnemo < 0 || mnemo >= MNEMO_N) + return "illegal"; + return avr_opcodes[mnemo].opcode; +} diff --git a/src/libavrdude.h b/src/libavrdude.h index d8acc357..8ec8d7c7 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1473,7 +1473,8 @@ typedef struct { int type; // I: I/O vars, M: mem vars, L: labels, P: PGM vars int subtype; // B: byte, W: word, A: autoterminated string, S: string int count; // array length for tag file variables - int used; // Whether used by disassembly process + int used; // Whether symbol was referenced by disassembly process + int printed; // Whether this L/P label will be printed in pass 2 } Disasm_symbol; // Order of enums must align with avr_opcodes[] table order @@ -1497,15 +1498,15 @@ typedef enum { MNEMO_brcc, MNEMO_brsh, MNEMO_brne, MNEMO_brpl, MNEMO_brvc, MNEMO_brge, MNEMO_brhc, MNEMO_brtc, MNEMO_brid, MNEMO_brbc, MNEMO_mov, MNEMO_movw, - MNEMO_ser, MNEMO_ldi, MNEMO_lds, MNEMO_ld_1, - MNEMO_ld_2, MNEMO_ld_3, MNEMO_ld_4, MNEMO_ld_5, - MNEMO_ld_6, MNEMO_ldd_1, MNEMO_ld_7, MNEMO_ld_8, - MNEMO_ld_9, MNEMO_ldd_2, MNEMO_sts, MNEMO_st_1, - MNEMO_st_2, MNEMO_st_3, MNEMO_st_4, MNEMO_st_5, - MNEMO_st_6, MNEMO_std_1, MNEMO_st_7, MNEMO_st_8, - MNEMO_st_9, MNEMO_std_2, MNEMO_lpm_1, MNEMO_lpm_2, - MNEMO_lpm_3, MNEMO_elpm_1, MNEMO_elpm_2, MNEMO_elpm_3, - MNEMO_spm, MNEMO_spm_zz, MNEMO_in, MNEMO_out, + MNEMO_ser, MNEMO_ldi, MNEMO_lds, MNEMO_ld_x, + MNEMO_ld_xp, MNEMO_ld_mx, MNEMO_ld_y, MNEMO_ld_yp, + MNEMO_ld_my, MNEMO_ldd_y, MNEMO_ld_z, MNEMO_ld_zp, + MNEMO_ld_mz, MNEMO_ldd_z, MNEMO_sts, MNEMO_st_x, + MNEMO_st_xp, MNEMO_st_mx, MNEMO_st_y, MNEMO_st_yp, + MNEMO_st_my, MNEMO_std_y, MNEMO_st_z, MNEMO_st_zp, + MNEMO_st_mz, MNEMO_std_z, MNEMO_lpm_0, MNEMO_lpm_z, + MNEMO_lpm_zp, MNEMO_elpm_0, MNEMO_elpm_z, MNEMO_elpm_zp, + MNEMO_spm, MNEMO_spm_zp, MNEMO_in, MNEMO_out, MNEMO_push, MNEMO_pop, MNEMO_xch, MNEMO_las, MNEMO_lac, MNEMO_lat, MNEMO_lsr, MNEMO_swap, MNEMO_sbi, MNEMO_cbi, MNEMO_bst, MNEMO_bld, @@ -1720,6 +1721,7 @@ int ldi_K(int op); AVR_mnemo opcode_mnemo(int op, int avrlevel); int avr_get_archlevel(const AVRPART *p); AVR_cycle_index avr_get_cycle_index(const AVRPART *p); +const char *mnemo_str(int op); int disasm(const char *buf, int len, int addr, int leadin, int leadout); int disasm_init(const AVRPART *p); From e594863f951baa3cecfb524fc5219be696011a33 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 27 Jul 2024 11:05:06 +0100 Subject: [PATCH 366/422] Provide op_width() and z_width() --- src/avr_opcodes.c | 50 +++++++++++++++++++++++++++++++++++++---------- src/libavrdude.h | 17 +++++++++------- src/term.c | 6 +++--- src/urclock.c | 4 ++-- 4 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/avr_opcodes.c b/src/avr_opcodes.c index f7127a65..944ef0e3 100644 --- a/src/avr_opcodes.c +++ b/src/avr_opcodes.c @@ -26,7 +26,7 @@ * - Order of enums MNEMO_... in libavedude.h must align with table * * - Order makes the first match of a 16-bit opcode a "good" one - * + Unallocated opcodes come last + * + Undocumented opcodes come last * + Specific reduced-core sts/lds opcodes are penultimate * + More specific opcodes before less specific ones (clr before eor) * + Opcodes labelled alias come behind those not labelled so @@ -182,10 +182,10 @@ const AVR_opcode avr_opcodes[MNEMO_N] = { {OP_ID(rjmp), 0xf000, 0xc000, 1, OP_AVR1, "1100 kkkk kkkk kkkk", OTY_RJMI, "rjmp", "k", "relative jump", "PC <-- PC + k + 1", "--------", {"2", "2", "2", "2"}, ""}, - {OP_ID(ijmp), 0xffff, 0x9409, 1, OP_AVR2, "1001 0100 0000 1001", OTY_JMPI, + {OP_ID(ijmp), 0xffff, 0x9409, 1, OP_AVR2, "1001 0100 0000 1001", OTY_JMPI|OTY_ZWORD, "ijmp", "", "indirect jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, ""}, - {OP_ID(eijmp), 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPI, + {OP_ID(eijmp), 0xffff, 0x9419, 1, OP_AVR_XL, "1001 0100 0001 1001", OTY_JMPX|OTY_ZWORD, "eijmp", "", "extended indirect jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, ""}, {OP_ID(jmp), 0xfe0e, 0x940c, 2, OP_AVR_M, "1001 010k kkkk 110k kkkk kkkk kkkk kkkk", OTY_JMPI, @@ -194,10 +194,10 @@ const AVR_opcode avr_opcodes[MNEMO_N] = { {OP_ID(rcall), 0xf000, 0xd000, 1, OP_AVR1, "1101 kkkk kkkk kkkk", OTY_RJMX, "rcall", "k", "relative call subroutine", "PC <-- PC + k + 1", "--------", {"3+", "2+", "2+", "3"}, ""}, - {OP_ID(icall), 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPI, + {OP_ID(icall), 0xffff, 0x9509, 1, OP_AVR2, "1001 0101 0000 1001", OTY_JMPX|OTY_ZWORD, "icall", "", "indirect call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3+", "2+", "2+", "3"}, ""}, - {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX, + {OP_ID(eicall), 0xffff, 0x9519, 1, OP_AVR_XL, "1001 0101 0001 1001", OTY_JMPX|OTY_ZWORD, "eicall", "", "extended indirect call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, ""}, {OP_ID(call), 0xfe0e, 0x940e, 2, OP_AVR_M, "1001 010k kkkk 111k kkkk kkkk kkkk kkkk", OTY_JMPX, @@ -527,7 +527,7 @@ const AVR_opcode avr_opcodes[MNEMO_N] = { "sts", "a, Rr", "store direct to data space", "(a) <-- Rr", "--------", {"n/a", "n/a", "n/a", "1"}, "AVRrc only (TPI parts); a = 0x40..0xbf"}, - // Unallocated codes: they are said(!) to do the following + // Undocumented opcodes: they are said(!) to do the following {OP_ID(u_nop_1), 0xff00, 0x0000, 1, OP_AVR_ILL, "0000 0000 xxxx xxxx", OTY_MCUI, "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, "xxxx xxxx != 0000 0000"}, @@ -549,10 +549,10 @@ const AVR_opcode avr_opcodes[MNEMO_N] = { {OP_ID(u_nop_7), 0xfe0f, 0x920b, 1, OP_AVR_ILL, "1001 001x xxxx 1011", OTY_MCUI, "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPI, + {OP_ID(u_icall), 0xff1f, 0x9509, 1, OP_AVR_ILL, "1001 0101 xxx0 1001", OTY_JMPX|OTY_ZWORD, "u/icall", "", "indirect call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"3+", "2+", "2+", "3"}, "xxx != 000"}, - {OP_ID(u_eicall), 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX, + {OP_ID(u_eicall), 0xff1f, 0x9519, 1, OP_AVR_ILL, "1001 0101 xxx1 1001", OTY_JMPX|OTY_ZWORD, "u/eicall", "", "extended indirect call to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"4", "3", "3", "n/a"}, "xxx != 000"}, {OP_ID(u_ret), 0xff9f, 0x9508, 1, OP_AVR_ILL, "1001 0101 0xx0 1000", OTY_JMPX, @@ -570,10 +570,10 @@ const AVR_opcode avr_opcodes[MNEMO_N] = { {OP_ID(u_nop_a), 0xff0f, 0x950b, 1, OP_AVR_ILL, "1001 0101 xxxx 1011", OTY_MCUI, "u/nop", "", "no operation", "-", "--------", {"1", "1", "1", "1"}, ""}, - {OP_ID(u_ijmp), 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI, + {OP_ID(u_ijmp), 0xff1f, 0x9409, 1, OP_AVR_ILL, "1001 0100 xxx0 1001", OTY_JMPI|OTY_ZWORD, "u/ijmp", "", "indirect jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- 0", "--------", {"2", "2", "2", "2"}, "xxx != 000"}, - {OP_ID(u_eijmp), 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPI, + {OP_ID(u_eijmp), 0xff1f, 0x9419, 1, OP_AVR_ILL, "1001 0100 xxx1 1001", OTY_JMPX|OTY_ZWORD, "u/eijmp", "", "extended indirect jump to (Z)", "PC(15:0) <-- Z, PC(21:16) <-- EIND", "--------", {"2", "2", "2", "n/a"}, "xxx != 000"}, {OP_ID(u_bld), 0xfe08, 0xf808, 1, OP_AVR_ILL, "1111 100d dddd 1bbb", OTY_ALBI|OTY_RALL, @@ -605,6 +605,11 @@ int is_opcode32(int op) { op16_is_mnemo(op, MNEMO_sts) || op16_is_mnemo(op, MNEMO_lds); } +// Return width of opcode in bytes (2 or 4) +int op_width(int op16) { + return is_opcode32(op16)? 4: 2; +} + // Return the register number of the 16-bit ldi opcode and 0 if it's not ldi int ldi_Rd(int op) { return op16_is_mnemo(op, MNEMO_ldi)? 16 + ((op >> 4) & 15): 0; @@ -707,3 +712,28 @@ const char *mnemo_str(int op) { return "illegal"; return avr_opcodes[mnemo].opcode; } + +/* + * Return + * 2 if opcode treats Z register as word address + * 1 if opcode treats Z as byte address + * 0 otherwise (Z not involved in opcode) + */ +int z_width(int op16, AVR_mnemo *mnemop) { + AVR_mnemo mlist[] = { + MNEMO_ijmp, MNEMO_eijmp, MNEMO_icall, MNEMO_eicall, MNEMO_u_icall, MNEMO_u_eicall, + MNEMO_u_ijmp, MNEMO_u_eijmp, MNEMO_ld_z, MNEMO_ld_zp, MNEMO_ld_mz, MNEMO_ldd_z, + MNEMO_st_z, MNEMO_st_zp, MNEMO_st_mz, MNEMO_std_z, MNEMO_lpm_0, MNEMO_lpm_z, + MNEMO_lpm_zp, MNEMO_elpm_0, MNEMO_elpm_z, MNEMO_elpm_zp, MNEMO_spm, MNEMO_spm_zp, + MNEMO_xch, MNEMO_las, MNEMO_lac, MNEMO_lat, + }; + + for(AVR_mnemo m=0; m < (AVR_mnemo) (sizeof mlist/sizeof*mlist); m++) + if(op16_is_mnemo(op16, mlist[m])) { + if(mnemop) + *mnemop = mlist[m]; + return avr_opcodes[mlist[m]].type & OTY_ZWORD? 2: 1; + } + + return 0; +} diff --git a/src/libavrdude.h b/src/libavrdude.h index 8ec8d7c7..3a44c2ae 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1537,7 +1537,7 @@ typedef enum { OP_AVR_XL = 512, // AVR with flash > 128 kB (EIJMP, EICALL) OP_AVR_XM = 1024, // XMEGA only (DES, XCH, LAC, LAS, LAT) OP_AVR_XTM = 2048, // XMEGA and UPDI only (SPM Z+) - OP_AVR_ILL = 4096, // Unallocated (illegal) opcodes + OP_AVR_ILL = 4096, // Undocumented (illegal) opcodes } AVR_archlevel; /* @@ -1586,6 +1586,7 @@ typedef enum { #define OTY_SKPI 0x60 // Conditional skip, range [.+0, .+4] (cpse, sbrc, sbrs) #define OTY_SKPX 0x68 // Conditional skip, range [.+0, .+4] (sbic, sbis) +#define OTY_ZWORD 0x080 // Opcode uses Z register for word address (ijmp, ical etc) #define OTY_ALIAS 0x100 // Opcode is a strict alias for another one, eg, sbr == ori #define OTY_CONSTRAINT 0x200 // Opcode has constraints: Rr == Rd (tst, clr, lsl, rol) @@ -1714,14 +1715,16 @@ void terminal_setup_update_progress(void); char *avr_cc_buffer(size_t n); -int op16_is_mnemo(int op, AVR_mnemo mnemo); -int is_opcode32(int op); -int ldi_Rd(int op); -int ldi_K(int op); -AVR_mnemo opcode_mnemo(int op, int avrlevel); +int op16_is_mnemo(int op16, AVR_mnemo mnemo); +int is_opcode32(int op16); +int op_width(int op16); +int ldi_Rd(int op16); +int ldi_K(int op16); +AVR_mnemo opcode_mnemo(int op16, int avrlevel); int avr_get_archlevel(const AVRPART *p); AVR_cycle_index avr_get_cycle_index(const AVRPART *p); -const char *mnemo_str(int op); +const char *mnemo_str(int op16); +int z_width(int op16, AVR_mnemo *mnenop); int disasm(const char *buf, int len, int addr, int leadin, int leadout); int disasm_init(const AVRPART *p); diff --git a/src/term.c b/src/term.c index d28685b6..96f00ebb 100644 --- a/src/term.c +++ b/src/term.c @@ -396,7 +396,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, if (cx->term_rmem[mi].len > maxsize) cx->term_rmem[mi].len = maxsize; - uint8_t *buf = mmt_malloc(cx->term_rmem[mi].len + 16); // Add margin for disasm + uint8_t *buf = mmt_malloc(cx->term_rmem[mi].len + 32); // Add margin for disasm if(argc < 4 && verbose) term_out(">>> %s %s 0x%x 0x%x\n", cmd, cx->term_rmem[mi].mem->desc, cx->term_rmem[mi].addr, cx->term_rmem[mi].len); @@ -410,7 +410,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, if(whence + toread > maxsize) // Clip to end of memory toread = maxsize - whence; int gap = maxsize - whence - toread; - after = gap >= 7? 7: gap < 0? 0: gap; + after = gap >= 16? 16: gap < 0? 0: gap; toread += after; if(toread-before < 2) // Cannot disassemble just one byte goto nocontent; @@ -434,7 +434,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, if(is_disasm) { // Adjust length so buffer does not split opcodes int j = before, end = toread-after, wend = after? end: end-1; while(j < wend) - j += is_opcode32(buf[j] | buf[j+1]<<8)? 4: 2; + j += op_width(buf[j] | buf[j+1]<<8); if(j < end) // Odd length: shorten by one byte after += end-j; else if(j > end && after >= j-end) // Increase length to accommodate last 32-bit opcode diff --git a/src/urclock.c b/src/urclock.c index cc27079c..04cd3d15 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -435,7 +435,7 @@ static uint16_t buf2uint16(const unsigned char *buf) { // Write little endian 32-bit word into buffer -void uint32tobuf(unsigned char *buf, uint32_t opcode32) { +static void uint32tobuf(unsigned char *buf, uint32_t opcode32) { buf[0] = opcode32; buf[1] = opcode32>>8; buf[2] = opcode32>>16; @@ -444,7 +444,7 @@ void uint32tobuf(unsigned char *buf, uint32_t opcode32) { // Write little endian 16-bit word into buffer -void uint16tobuf(unsigned char *buf, uint16_t opcode16) { +static void uint16tobuf(unsigned char *buf, uint16_t opcode16) { buf[0] = opcode16; buf[1] = opcode16>>8; } From 95bc4db4b963657f00a25f4f8c14a22ea5556a62 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 27 Jul 2024 13:32:58 +0100 Subject: [PATCH 367/422] Generate symbolic names for ldi on register pairs --- src/disasm.c | 220 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 159 insertions(+), 61 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index b05288c9..a404032b 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -20,11 +20,16 @@ /* $Id$ */ /* - * The disassembly code originates from the avrdisas disassembler written in - * 2007 by Johannes Bauer. This code has been rewritten by Stefan Rueger to + * This disassembly code originates from the avrdisas disassembler written in + * 2007 by Johannes Bauer. It has been rewritten by Stefan Rueger to * - Enable disassembly of small memory chunks in AVRDUDE's terminal * - Drive disassembly from the avr_opcodes[] table alone * - Generate a compilable source + * - Find symbolic values for ldi constants that initialise register pais + * + * Like the ship of Theseus there is little of the avrdisas orginal code that + * has remained, but it is fair to say that without it the AVRDUDE disasm + * command would not have happened. */ #include @@ -44,6 +49,7 @@ #define TYPE_ASTRING 3 // Autoaligned string #define TYPE_STRING 4 // String +#define buf2op16(i) ((buf[i] & 0xff) | (buf[(i)+1] & 0xff)<<8) static void zap_symbols() { if(cx->dis_symbols) { @@ -57,15 +63,25 @@ static void zap_symbols() { cx->dis_symbolN = 0; } +static int type_order(int type) { + switch(type) { + case 'I': return '1'; + case 'M': return '2'; + case 'L': return '3'; + case 'P': return '4'; + default: return type; + } +} + static int symbol_sort(const void *v1, const void *v2) { const Disasm_symbol *p1 = v1, *p2 = v2; int diff; - if((diff = p1->type - p2->type)) + if((diff = type_order(p1->type) - type_order(p2->type))) return diff; return p1->address - p2->address; } -static int symbol_qsort_stable(const void *v1, const void *v2) { +static int symbol_stable_qsort(const void *v1, const void *v2) { int diff = symbol_sort(v1, v2); if(diff) return diff; @@ -78,7 +94,7 @@ static char *cleanup(char *str) { return str; } -// Width of memory a symbol covers (only valid for I/O and memory symbols) +// Width of memory a symbol covers static int symbol_width(Disasm_symbol *s) { return s->count * (s->subtype == TYPE_WORD? 2: 1); } @@ -113,6 +129,7 @@ static void add_symbol(int address, int type, int subtype, int count, const char cx->dis_symbols[N].subtype = subtype; cx->dis_symbols[N].count = count; cx->dis_symbols[N].used = 0; + cx->dis_symbols[N].printed = 0; cx->dis_symbols[N].name = name? cleanup(mmt_strdup(name)): NULL; cx->dis_symbols[N].comment = comment? mmt_strdup(comment): NULL; } @@ -271,7 +288,7 @@ static void init_regfile(const AVRPART *p) { add_register(io_off, rf[i].addr+k, rname, k); } } - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_qsort_stable); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_stable_qsort); } } @@ -299,7 +316,7 @@ int disasm_init_tagfile(const AVRPART *p, const char *fname) { } fclose(inf); - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_qsort_stable); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_stable_qsort); return 0; error: @@ -330,11 +347,12 @@ static const char *cycles(int mnemo) { return ret; } -static const char *get_label_name(int destination, const char **comment) { +static const char *get_label_name(int destination, const char **commentp) { Disasm_symbol *s = find_symbol('L', destination); - if(s) { - if(comment) - *comment = s->comment; + if(s && s->name) { + if(commentp) + *commentp = s->comment; + s->printed = 1; // Will be printed in pass 2 return s->name; } @@ -395,9 +413,6 @@ static int is_jumpable(int address) { static void lineout(const char *code, const char *comment, int mnemo, int oplen, const char *buf, int pos, int addr, int showlabel) { - if(cx->dis_pass == 1) - return; - int here = disasm_wrap(pos + addr), codewidth = 27; if(cx->dis_opts.labels && showlabel) { @@ -408,16 +423,16 @@ static void lineout(const char *code, const char *comment, if(cx->dis_jumpcalls[i].to == here) { if(!match++) cx->dis_para = 1; - disasm_out("; Referenced from L%0*x by %s\n", cx->dis_addrwidth, - cx->dis_jumpcalls[i].from, avr_opcodes[cx->dis_jumpcalls[i].mnemo].opcode); + disasm_out("; %s from L%0*x\n", avr_opcodes[cx->dis_jumpcalls[i].mnemo].opcode, + cx->dis_addrwidth, cx->dis_jumpcalls[i].from); } } if(match && (name = get_label_name(here, &comment))) { - if(comment == NULL) - disasm_out("%s:\n", name); - else + if(comment) disasm_out("%-*s ; %s\n", codecol() + codewidth, str_ccprintf("%s:", name), comment); + else + disasm_out("%s:\n", name); } } @@ -448,9 +463,8 @@ static int process_num(const char *buf, int buflen, int nbytes, int pos, int off const char *str = nbytes == 1? str_ccprintf(".byte 0x%02x", buf[pos] & 0xff): - nbytes == 2? str_ccprintf(".word 0x%02x%02x", buf[pos+1] & 0xff, buf[pos] & 0xff): - nbytes == 4? str_ccprintf(".long 0x%02x%02x%02x%02x", buf[pos+3] & 0xff, buf[pos+2] & 0xff, - buf[pos+1] & 0xff, buf[pos] & 0xff): "nbytes?"; + nbytes == 2? str_ccprintf(".word 0x%04x", buf2op16(pos)): + nbytes == 4? str_ccprintf(".long 0x%04x%04x", buf2op16(pos+2), buf2op16(pos)): "nbytes?"; lineout(str, NULL, -1, 1, buf, pos, offset, 0); return nbytes; @@ -505,13 +519,14 @@ static int process_data(const char *buf, int buflen, int pos, int offset) { k &= ~1; return !k || k-pos < 4? 0: process_fill0xff(buf, buflen, k-pos, pos, offset); } - // Found PGM label at odd address, print byte and continue + // Found PGM label at odd address, print byte before label and continue process_num(buf, buflen, 1, pos, offset); ret = 1; } if(s->name) { cx->dis_para = 1; + s->printed = 1; // Will be printed in pass 2 disasm_out("%s:\n", s->name); } @@ -539,20 +554,19 @@ static int process_data(const char *buf, int buflen, int pos, int offset) { return ret; } -void emit_used_io_registers() { - int maxlen = 0; +static void emit_used_symbols() { + Disasm_symbol *s = cx->dis_symbols; + int len, maxlen = 0; for(int i = 0; i < cx->dis_symbolN; i++) - if(cx->dis_symbols[i].used) { - int len = strlen(cx->dis_symbols[i].name); - if(len > maxlen) + if(s[i].used && !s[i].printed) + if((len = strlen(s[i].name)) > maxlen) maxlen = len; - } for(int i = 0; i < cx->dis_symbolN; i++) - if(cx->dis_symbols[i].used && (cx->dis_io_offset || cx->dis_symbols[i].type == 'M')) - disasm_out(".equ %s,%*s 0x%02x\n", cx->dis_symbols[i].name, - (int) (maxlen-strlen(cx->dis_symbols[i].name)), "", cx->dis_symbols[i].address); + if(s[i].used && !s[i].printed) + disasm_out(".equ %s,%*s 0x%02x\n", s[i].name, + (int) (maxlen-strlen(s[i].name)), "", s[i].address); } void disasm_zap_jumpcalls() { @@ -561,7 +575,7 @@ void disasm_zap_jumpcalls() { cx->dis_jumpcallN = 0; } -static void register_jumpcall(int from, int to, int mnemo, unsigned char is_func) { +static void register_jumpcall(int from, int to, int mnemo, int is_func) { if(cx->dis_opts.labels) { Disasm_jumpcall *jc = cx->dis_jumpcalls; int N = cx->dis_jumpcallN; @@ -608,6 +622,8 @@ static int jumpcall_sort(const void *v1, const void *v2) { int diff; if((diff = p1->to - p2->to)) return diff; + if((diff = p1->mnemo - p2->mnemo)) + return diff; return p1->from - p2->from; } @@ -681,7 +697,58 @@ static unsigned bitcount(unsigned n) { return ret; } -static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, Disasm_line *line) { +typedef struct { + int from, is_func, is_lpm, preop, postop, zwd; +} Op_context; + +static const char *get_ldi_name(int op1, int op2, Op_context *oxp) { + Disasm_symbol *s; + char buf[2]; + + int ra = ldi_Rd(op1), rb = ldi_Rd(op2); + if((ra ^ rb) == 1) { // Two successive ldi opcodes initialise a register pair + buf[ra & 1] = ldi_K(op1); + buf[rb & 1] = ldi_K(op2); + int addr = buf2op16(0); // Address of register pair + // Assume address width is 2 if ldi acts on Z and is followed by e/icall within 5 opcodes + int awidth = (ra | 1) == 31 && oxp->zwd == 2? 2: 1; + for(const char *c = awidth == 2 || oxp->is_lpm? "LP": "MLP"; *c; c++) + if((s = find_symbol(*c, addr*awidth))) + break; + if(s && s->name) { // Label matches the address loaded into register pair + s->used = 1; + return str_ccprintf("%s%s(%s)", awidth == 2? "pm_": "", ra & 1? "hi8": "lo8", s->name); + } + if((ra | 1) == 31 && oxp->is_lpm && addr >= cx->dis_start && addr < cx->dis_end) { + if(cx->dis_pass == 1) + register_jumpcall(oxp->from, addr, MNEMO_ldi, 0); + const char *name = get_label_name(addr, NULL); + if(name && cx->dis_opts.labels && is_jumpable(addr)) + return str_ccprintf("%s(%s)", ra & 1? "hi8": "lo8", name); + } else if(awidth == 2 && 2*addr >= cx->dis_start && 2*addr < cx->dis_end) { + if(cx->dis_pass == 1) + register_jumpcall(oxp->from, 2*addr, MNEMO_ldi, oxp->is_func); + const char *name = get_label_name(2*addr, NULL); + if(name && cx->dis_opts.labels && is_jumpable(2*addr)) + return str_ccprintf("pm_%s(%s)", ra & 1? "hi8": "lo8", name); + } + } + return NULL; +} + +static const char *get_ldi_context(Op_context *oxp, int opcode) { + const char *ret; + + if(oxp->preop >= 0 && (ret = get_ldi_name(opcode, oxp->preop, oxp))) + return ret; + if(oxp->postop >= 0 && (ret = get_ldi_name(opcode, oxp->postop, oxp))) + return ret; + return NULL; +} + +static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, + Op_context *oxp, Disasm_line *line) { + memset(line, 0, sizeof*line); if(mnemo < 0) { add_comment(line, "Invalid opcode"); @@ -705,7 +772,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, if(oc->nwords == 2) { bits['k'] += 16; regs['k'] <<= 16; - regs['k'] |= (buf[2] & 0xff) | (buf[3] & 0xff)<<8; + regs['k'] |= buf2op16(2); } // Some sanity checks for things the code relies on @@ -755,7 +822,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, int target = 0, offset = 0, is_jumpcall = 0, is_relative = 0; int is_function = !!(oc->type & OTY_EXTERNAL); // call/rcall affects stack memory - const char *kmemaddr = NULL, *amemaddr = NULL, *regname = NA? resolve_address('I', RA): NULL; + const char *name, *ksym = NULL, *asym = NULL, *rsym = NA? resolve_address('I', RA): NULL; if(Na) { /* @@ -764,7 +831,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, * ADDR[7:0] ← (/a[4], a[4], a[6], a[5], a[3], a[2], a[1], a[0]) */ Ra = (Ra & 0xf) | ((Ra >> 1) & 0x30) | ((Ra & 0x10) << 2) | (((Ra & 0x10) ^ 0x10) << 3); - amemaddr = resolve_address('M', Ra); + asym = resolve_address('M', Ra); } switch(Nk) { @@ -787,7 +854,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, is_relative = 1; break; case 16: // lds/sts - kmemaddr = resolve_address('M', Rk); + ksym = resolve_address('M', Rk); break; case 22: if(cx->dis_flashsz && 2*Rk > cx->dis_flashsz) @@ -800,9 +867,6 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, break; } - if(cx->dis_pass == 1) - return; - snprintf(line->code, LINE_N, "%-7s ", oc->opcode); char *lc = line->code + strlen(line->code); #define add_operand(lc, ...) snprintf((lc), LINE_N - ((lc) - line->code), __VA_ARGS__) @@ -832,20 +896,20 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, *lc++ = *o, *lc = 0; break; case 'A': - if(regname) - add_operand(lc, "%s", regname); + if(rsym) + add_operand(lc, "%s", rsym); else add_operand(lc, "0x%02x", RA); break; case 'a': - if(amemaddr) - add_operand(lc, "%s", amemaddr); + if(asym) + add_operand(lc, "%s", asym); else add_operand(lc, "0x%02x", Ra); break; case 'k': if(is_jumpcall) { - const char *name = get_label_name(target, NULL); + name = get_label_name(target, NULL); if(name && target != disasm_wrap(addr+2) && cx->dis_opts.labels && is_jumpable(target)) { add_operand(lc, "%s", name); add_comment(line, str_ccprintf("L%0*x", awd, target)); @@ -857,8 +921,8 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, add_operand(lc, "0x%0*x", awd, target); } } else { - if(kmemaddr) - add_operand(lc, "%s", kmemaddr); + if(ksym) + add_operand(lc, "%s", ksym); else add_operand(lc, "0x%0*x", swd, Rk); } @@ -880,8 +944,13 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, if(NK == 4) add_operand(lc, "%d", RK); else { - add_operand(lc, "0x%02x", RK); - add_comment(line, str_ccprintf("%d", RK)); + if(op16_is_mnemo(opcode, MNEMO_ldi) && (name = get_ldi_context(oxp, opcode))) { + add_operand(lc, "%s", name); + add_comment(line, str_ccprintf("0x%02x", RK)); + } else { + add_operand(lc, "0x%02x", RK); + add_comment(line, str_ccprintf("%d", RK)); + } } break; case 'q': @@ -913,20 +982,47 @@ static int have_own_main() { return 0; } +static void set_context(Op_context *oxp, const char *buf, int pos, int buflen, int addr, int leadin, int leadout) { + // Compute initial context structure: the opcode before and the following one + oxp->from = disasm_wrap(pos+addr); + oxp->is_func = 0; // the next Z-opcode ahead is an icall/eicall + oxp->is_lpm = 0; // the next Z-opcode ahead is a lpm/elpm + oxp->preop = pos+leadin > 1? buf2op16(pos-2): -1; + oxp->postop = -1; + oxp->zwd = 0; // 2: the next Z-opcode ahead uses Z as word addr, 1: as byte addr + int k = 0, op16, i = pos + op_width(buf2op16(pos)); + if(i < buflen+leadout-1) { + AVR_mnemo zm = 0; + + oxp->postop = op16 = buf2op16(i); + // Check whether there is an opcode ahead that uses the Z register + for(k=0, i += op_width(op16); k < 6 && i < buflen+leadout-1; k++, i += op_width(op16)) + if(op16_is_mnemo(op16, MNEMO_rjmp) || op16_is_mnemo(op16, MNEMO_jmp) || + op16_is_mnemo(op16, MNEMO_ret) || op16_is_mnemo(op16, MNEMO_reti) || + op16_is_mnemo(op16, MNEMO_u_ret) || op16_is_mnemo(op16, MNEMO_u_reti) || + (oxp->zwd = z_width((op16 = buf2op16(i)), &zm))) + break; + if(oxp->zwd == 2) + oxp->is_func = zm == MNEMO_icall || zm == MNEMO_eicall || zm == MNEMO_u_icall || zm == MNEMO_u_eicall; + else + oxp->is_lpm = zm >= MNEMO_lpm_0 && zm <= MNEMO_elpm_zp; + } +} + /* * Disassemble buflen bytes at buf which corresponds to address addr * * - Caller is responsible that buflen does not split an opcode * - Before(!) the location buf there are leadin bytes available (0-2) - * - After the location buf+readlen there are leadout bytes available (0-4) + * - After the location buf+readlen there are leadout bytes available (0-16) */ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { int pos, opcode, mnemo, oplen; - Disasm_line line; + Disasm_line line = {0}; + Op_context ox = {0}; - for(int i = 0; i < cx->dis_symbolN; i++) // Clear used-state of symbols - if(cx->dis_symbols[i].type == 'I') - cx->dis_symbols[i].used = 0; + for(int i = 0; i < cx->dis_symbolN; i++) // Clear used/printed state of symbols + cx->dis_symbols[i].used = cx->dis_symbols[i].printed = 0; cx->dis_jumpable = mmt_malloc((buflen+1)/2/8); // Allocate one bit per word address cx->dis_start = addr, cx->dis_end = addr + buflen - 1; @@ -937,10 +1033,10 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { cx->dis_para = 0; enumerate_labels(); if(cx->dis_opts.avrgcc_style) - emit_used_io_registers(); + emit_used_symbols(); if(cx->dis_opts.gcc_source) { cx->dis_para=1; - disasm_out(".text%s\n", have_own_main()? "": "main:\n"); + disasm_out(".text\n%s", have_own_main()? "": "main:\n"); } } for(pos = 0; pos < buflen; pos += oplen) { @@ -955,13 +1051,15 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { continue; } - opcode = (buf[pos] & 0xff) | (buf[pos+1] & 0xff)<<8; + opcode = buf2op16(pos); mnemo = opcode_mnemo(opcode, cx->dis_opts.avrlevel); oplen = mnemo < 0? 2: 2*avr_opcodes[mnemo].nwords; - disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &line); + if(op16_is_mnemo(opcode, MNEMO_ldi)) + set_context(&ox, buf, pos, buflen, addr, leadin, leadout); + disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &ox, &line); lineout(line.code, line.comment, mnemo, oplen, buf, pos, addr, 1); - if(cx->dis_pass == 1) { // Mark this position as one that can be a jump/call destination + if(cx->dis_pass == 1) { // Mark this position as potential jump/call destination int n = sizeof(int)*8, idx = pos/2; cx->dis_jumpable[idx/n] |= (1<<(idx%n)); } @@ -986,7 +1084,7 @@ int disasm_init(const AVRPART *p) { cx->dis_flashsz = 0; // Flash size cx->dis_flashsz2 = 0; // Flash size rounded up to next power of two cx->dis_addrwidth = 4; // Number of hex digits needed for flash addresses - cx->dis_sramwidth = 3; // Number of hex digits needed for sram addresses + cx->dis_sramwidth = 4; // Number of hex digits needed for sram addresses if((mem = avr_locate_flash(p)) && mem->size > 1) { int nbits = intlog2(mem->size - 1) + 1; From 7c92a355f955ab46b90290ccfda87e3cd94ca435 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 27 Jul 2024 16:50:04 +0100 Subject: [PATCH 368/422] Strengthen tagfile parsing --- src/disasm.c | 205 ++++++++++++++++++++++++++--------------------- src/libavrdude.h | 2 +- 2 files changed, 115 insertions(+), 92 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index a404032b..a01c8f3b 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -130,108 +130,125 @@ static void add_symbol(int address, int type, int subtype, int count, const char cx->dis_symbols[N].count = count; cx->dis_symbols[N].used = 0; cx->dis_symbols[N].printed = 0; - cx->dis_symbols[N].name = name? cleanup(mmt_strdup(name)): NULL; - cx->dis_symbols[N].comment = comment? mmt_strdup(comment): NULL; + cx->dis_symbols[N].name = name? cleanup(str_rtrim(mmt_strdup(str_ltrim(name)))): NULL; + cx->dis_symbols[N].comment = comment? str_rtrim(mmt_strdup(str_ltrim(comment))): NULL; } -static int line_error(const char *token, const char *message, int lineno) { - if((token == NULL) || (strlen(token) == 0)) { - pmsg_error("%s in tagfile, line %d\n", message, lineno); - return 1; +/* + * Tokenising of a tagfile line returning (argc, argv); parsing ends when + * - A token starts with a comment character # + * - The comment field after the name of the symbol is encountered + * - The end of the string is encountered + * + * Argv is allocated once, so the caller only needs to mmt_free argv. + * On error NULL is returned (when input line was too long). + * + */ +static int tagfile_tokenize(char *s, int *argcp, const char ***argvp) { + size_t slen; + int n, nargs; + const char **argv; + char *buf, *q, *r; + + // Upper estimate of the number of arguments + for(nargs=0, q=s; *q; nargs++) { + while(*q && !isspace((unsigned char) *q)) + q++; + while(*q && isspace((unsigned char) *q)) + q++; } - return 0; -} + slen = q - s; -static int tagfile_readline(char *line, int lineno, const char * const *isrnames, int ni) { - char *token, type, subtype, *name; - int vn, address, count; - const char *errptr; - - if(line[0] == '#' || strlen(line) <= 1) + // Limit input line to some 186 Megabytes as max nargs is (slen+1)/2 + if(slen > 2*((INT_MAX - 2*sizeof(char *))/(sizeof(char *)+3))) return 0; - token = strtok(line, " \t\n"); - if(line_error(token, "nonempty line", lineno)) - return -1; - address = str_int(token, STR_INT32, &errptr); - if(errptr) { - pmsg_error("address %s: %s\n", token, errptr); - return -1; + // Allocate once for pointers and contents, so caller only needs to mmt_free(argv) + argv = mmt_malloc((nargs+2)*sizeof(char *) + slen + nargs); + buf = (char *) (argv+nargs+1); + + for(n=0, r=s; *r; ) { + q = str_nexttok(r, " \t\n\r\v\f", &r); + size_t len = strlen(q); + + if(*q == '#') { // Inline comment: ignore rest of line + r = q+len; + break; + } + strcpy(buf, q); + if(*buf) // Don't record empty arguments + argv[n++] = buf; + + if(n > 1 && n == (str_eq(argv[1], "L")? 3: 5)) { // Stop parsing after symbol name + if(*r) + argv[n] = r; // Comment, if any + break; + } + + buf += len + 1; } - token = strtok(NULL, " \t\n"); - if(line_error(token, "no second argument", lineno)) - return -1; - if(strlen(token) != 1) { - line_error(NULL, "second argument should be a type (L, P or M)", lineno); - return -1; - } - type = token[0]; + *argcp = n; + *argvp = argv; + return 1; +} - token = strtok(NULL, " \t\n"); - if(line_error(token, "no third argument", lineno)) - return -1; +#define Return(fmt, ...) do { \ + pmsg_error("tagfile line %d " fmt, lineno, __VA_ARGS__); msg_error("\n"); \ + return -1; \ +} while (0) + +static int tagfile_readline(char *line, int lineno, const char * const *isrnames, int ni) { + int type, subtype, vn, address, count, argc = 0; + const char *errptr, **argv = NULL; + + if(!tagfile_tokenize(line, &argc, &argv)) + Return("%s", "is too long"); + if(argc == 0) + return 0; + if(argc < 3) + Return("%s", "needs at least address, symbol type (L/P/M) and name"); + + address = str_int(argv[0], STR_INT32, &errptr); + if(errptr) + Return("address %s: %s", argv[0], errptr); + + if(strlen(argv[1]) != 1 || !strchr("LPM", *argv[1])) + Return("%s", "2nd argument must be L, P or M"); + type = *argv[1]; if(type == 'L') { - name = token; // Name, comment is optional - + const char *name = argv[2]; if(str_starts(name, "__vector_") && looks_like_number(name + 9)) if((vn = strtol(name+9, NULL, 0)) > 0 && vn < ni) // Don't replace __vectors_0 name = str_lc((char *) str_ccprintf("__vector_%s", isrnames[vn])); - - add_symbol(address, 'L', TYPE_BYTE, 1, name, strtok(NULL, "\t\n")); + add_symbol(address, 'L', TYPE_BYTE, 1, name, argv[3]); return 0; } - if(line_error(token, "no fourth argument", lineno)) - return -1; - if(strlen(token) != 1) { - line_error(NULL, "fourth argument should be a subtype (B, W, A or S)", lineno); - return -1; - } - subtype = token[0]; + if(argc < 5 || strlen(argv[2]) != 1 || !strchr("BWAS", *argv[2])) + Return("needs to be
%c [%s] ", type, type == 'M'? "BW": "BWAS"); - switch(subtype) { - case 'B': - subtype = TYPE_BYTE; - break; - case 'W': - subtype = TYPE_WORD; - break; - case 'A': - subtype = TYPE_ASTRING; - break; - case 'S': - subtype = TYPE_STRING; - break; - default: - line_error(NULL, "invalid subtype (expected one of B, W, A or S)", lineno); + switch(*argv[2]) { + default: subtype = TYPE_BYTE; break; + case 'W': subtype = TYPE_WORD; break; + case 'A': subtype = TYPE_ASTRING; break; + case 'S': subtype = TYPE_STRING; + } + + if(type == 'M' && subtype != TYPE_BYTE && subtype != TYPE_WORD) { + pmsg_error("memory label type can only be B(yte) or W(ord)"); return -1; } - if((type == 'M') && ((subtype != TYPE_BYTE) && (subtype != TYPE_WORD))) { - line_error(NULL, "memory labels can only be of type B or W", lineno); - return -1; - } + count = str_int(argv[3], STR_INT32, &errptr); + if(errptr) + Return("count %s: %s\n", argv[3], errptr); + if(count < 1) + Return("tagfile line %d has invalid count %d", lineno, count); - token = strtok(NULL, " \t\n"); - count = str_int(token, STR_INT32, &errptr); - if(errptr) { - pmsg_error("count %s: %s\n", token, errptr); - return -1; - } - if(count < 1) { - line_error(NULL, str_ccprintf("invalid count %d given", count), lineno); - return -1; - } - - name = strtok(NULL, " \t\n"); - if(type != 'P' && type != 'M') { - pmsg_error("invalid tag type %c (must be L, P or M)\n", type); - return -1; - } - - add_symbol(address, type, subtype, count, name, NULL); + add_symbol(address, type, subtype, count, argv[4], argv[5]); + mmt_free(argv); return 0; } @@ -386,8 +403,8 @@ typedef struct { char label[LINE_N], code[LINE_N], comment[LINE_N]; } Disasm_line; -// Column where opcode starts -static int codecol() { +// Comments start in commentcol() + 1 +static int commentcol() { int ret = 0; if(cx->dis_opts.addresses) ret += 3 + cx->dis_addrwidth; @@ -398,7 +415,7 @@ static int codecol() { if(cx->dis_opts.opcode_bytes) ret += 12; - return ret? ret+1: 2; + return (ret? ret+1: 2) + cx->dis_codewidth; } static int is_jumpable(int address) { @@ -413,7 +430,7 @@ static int is_jumpable(int address) { static void lineout(const char *code, const char *comment, int mnemo, int oplen, const char *buf, int pos, int addr, int showlabel) { - int here = disasm_wrap(pos + addr), codewidth = 27; + int here = disasm_wrap(pos + addr); if(cx->dis_opts.labels && showlabel) { int match = 0; @@ -430,7 +447,7 @@ static void lineout(const char *code, const char *comment, if(match && (name = get_label_name(here, &comment))) { if(comment) - disasm_out("%-*s ; %s\n", codecol() + codewidth, str_ccprintf("%s:", name), comment); + disasm_out("%-*s ; %s\n", commentcol(), str_ccprintf("%s:", name), comment); else disasm_out("%s:\n", name); } @@ -445,11 +462,11 @@ static void lineout(const char *code, const char *comment, if(cx->dis_opts.opcode_bytes) for(int i = 0; i < 4; i++) disasm_out(i < oplen? "%02x ": " ", buf[pos + i] & 0xff); - disasm_out(codecol() > 2? " ": " "); + disasm_out(commentcol() > 2 + cx->dis_codewidth? " ": " "); if(!comment || !*comment || !cx->dis_opts.comments) disasm_out("%s\n", code); else - disasm_out("%-*s ; %s\n", codewidth, code, comment); + disasm_out("%-*s ; %s\n", cx->dis_codewidth, code, comment); if(mnemo == MNEMO_ret || mnemo == MNEMO_u_ret || mnemo == MNEMO_reti || mnemo == MNEMO_u_reti) cx->dis_para = 1; } @@ -559,14 +576,19 @@ static void emit_used_symbols() { int len, maxlen = 0; for(int i = 0; i < cx->dis_symbolN; i++) - if(s[i].used && !s[i].printed) + if(s[i].used && !s[i].printed && s[i].name) if((len = strlen(s[i].name)) > maxlen) maxlen = len; for(int i = 0; i < cx->dis_symbolN; i++) - if(s[i].used && !s[i].printed) - disasm_out(".equ %s,%*s 0x%02x\n", s[i].name, - (int) (maxlen-strlen(s[i].name)), "", s[i].address); + if(s[i].used && !s[i].printed && s[i].name) { + const char *equ = str_ccprintf(".equ %s,%*s 0x%02x", s[i].name, + (int) (maxlen-strlen(s[i].name)), "", s[i].address); + if(s[i].comment) + disasm_out("%-*s ; %s\n", commentcol(), equ, s[i].comment); + else + disasm_out("%s\n", equ); + } } void disasm_zap_jumpcalls() { @@ -1085,6 +1107,7 @@ int disasm_init(const AVRPART *p) { cx->dis_flashsz2 = 0; // Flash size rounded up to next power of two cx->dis_addrwidth = 4; // Number of hex digits needed for flash addresses cx->dis_sramwidth = 4; // Number of hex digits needed for sram addresses + cx->dis_codewidth = 27; // Width of the code column (ldi r17, 0x32) if((mem = avr_locate_flash(p)) && mem->size > 1) { int nbits = intlog2(mem->size - 1) + 1; diff --git a/src/libavrdude.h b/src/libavrdude.h index 3a44c2ae..7f085136 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1824,7 +1824,7 @@ typedef struct { // Static variables from disasm.c int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth; - int dis_pass, dis_para, dis_cycle_index, dis_io_offset; + int dis_pass, dis_para, dis_cycle_index, dis_io_offset, dis_codewidth; Disasm_options dis_opts; int dis_jumpcallN, dis_symbolN, *dis_jumpable, dis_start, dis_end; Disasm_jumpcall *dis_jumpcalls; From a107d02a1bdb198cb9184d60643a367793305038 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 27 Jul 2024 23:34:26 +0100 Subject: [PATCH 369/422] Format references to labels in space-saving way --- src/disasm.c | 204 +++++++++++++++++++++++++++++------------------ src/libavrdude.h | 12 +-- 2 files changed, 134 insertions(+), 82 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index a01c8f3b..d9eafbfa 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -74,7 +74,7 @@ static int type_order(int type) { } static int symbol_sort(const void *v1, const void *v2) { - const Disasm_symbol *p1 = v1, *p2 = v2; + const Dis_symbol *p1 = v1, *p2 = v2; int diff; if((diff = type_order(p1->type) - type_order(p2->type))) return diff; @@ -95,16 +95,16 @@ static char *cleanup(char *str) { } // Width of memory a symbol covers -static int symbol_width(Disasm_symbol *s) { +static int symbol_width(Dis_symbol *s) { return s->count * (s->subtype == TYPE_WORD? 2: 1); } -static Disasm_symbol *find_symbol(int type, int address) { - Disasm_symbol key, *s = cx->dis_symbols, *found; +static Dis_symbol *find_symbol(int type, int address) { + Dis_symbol key, *s = cx->dis_symbols, *found; key.type = type; key.address = address; - if(!(found = bsearch(&key, s, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_sort))) + if(!(found = bsearch(&key, s, cx->dis_symbolN, sizeof(Dis_symbol), symbol_sort))) return NULL; // Determine m as first matching symbol that has smallest width @@ -120,18 +120,18 @@ static Disasm_symbol *find_symbol(int type, int address) { return s+m; } -static void add_symbol(int address, int type, int subtype, int count, const char *name, const char *comment) { +static void add_symbol(int addr, int type, int sub, int count, const char *name, const char *com) { int N = cx->dis_symbolN++; if(N % 1024 == 0) - cx->dis_symbols = (Disasm_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Disasm_symbol) * (N+1024)); - cx->dis_symbols[N].address = address; + cx->dis_symbols = (Dis_symbol *) mmt_realloc(cx->dis_symbols, sizeof(Dis_symbol)*(N+1024)); + cx->dis_symbols[N].address = addr; cx->dis_symbols[N].type = type; - cx->dis_symbols[N].subtype = subtype; + cx->dis_symbols[N].subtype = sub; cx->dis_symbols[N].count = count; cx->dis_symbols[N].used = 0; cx->dis_symbols[N].printed = 0; cx->dis_symbols[N].name = name? cleanup(str_rtrim(mmt_strdup(str_ltrim(name)))): NULL; - cx->dis_symbols[N].comment = comment? str_rtrim(mmt_strdup(str_ltrim(comment))): NULL; + cx->dis_symbols[N].comment = com? str_rtrim(mmt_strdup(str_ltrim(com))): NULL; } /* @@ -282,7 +282,7 @@ static const char *shortrname(const Register_file *rf, int nr, int i) { static void add_register(int io_off, int addr, const char *name, int suffix) { add_symbol(io_off+addr, 'M', TYPE_BYTE, 1, regname(io_off? "mem.": "", name, suffix), NULL); - if(addr < 0x40 && io_off) // Only keep I/O addresses separate if memory addresses have an offset + if(addr < 0x40 && io_off) // Only keep I/O addresses separate if mem addresses have an offset add_symbol(addr, 'I', TYPE_BYTE, 1, regname(io_off? "io.": "", name, suffix), NULL); } @@ -305,7 +305,7 @@ static void init_regfile(const AVRPART *p) { add_register(io_off, rf[i].addr+k, rname, k); } } - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_stable_qsort); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Dis_symbol), symbol_stable_qsort); } } @@ -333,7 +333,7 @@ int disasm_init_tagfile(const AVRPART *p, const char *fname) { } fclose(inf); - qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Disasm_symbol), symbol_stable_qsort); + qsort(cx->dis_symbols, cx->dis_symbolN, sizeof(Dis_symbol), symbol_stable_qsort); return 0; error: @@ -342,7 +342,7 @@ error: } static const char *resolve_address(int type, int address) { - Disasm_symbol *s = find_symbol(type == 'I' && !cx->dis_io_offset? 'M': type, address); + Dis_symbol *s = find_symbol(type == 'I' && !cx->dis_io_offset? 'M': type, address); if(s && s->name) s->used = 1; @@ -365,7 +365,7 @@ static const char *cycles(int mnemo) { } static const char *get_label_name(int destination, const char **commentp) { - Disasm_symbol *s = find_symbol('L', destination); + Dis_symbol *s = find_symbol('L', destination); if(s && s->name) { if(commentp) *commentp = s->comment; @@ -392,7 +392,7 @@ static int disasm_wrap(int addr) { #define disasm_out(...) do { \ if(cx->dis_pass != 2) \ break; \ - if(cx->dis_para) \ + if(cx->dis_para > 0) \ term_out("\n"); \ cx->dis_para = 0; \ term_out(__VA_ARGS__); \ @@ -401,10 +401,10 @@ static int disasm_wrap(int addr) { #define LINE_N 256 typedef struct { char label[LINE_N], code[LINE_N], comment[LINE_N]; -} Disasm_line; +} Dis_line; -// Comments start in commentcol() + 1 -static int commentcol() { +// Opcode starts in codecol() +static int codecol() { int ret = 0; if(cx->dis_opts.addresses) ret += 3 + cx->dis_addrwidth; @@ -415,7 +415,12 @@ static int commentcol() { if(cx->dis_opts.opcode_bytes) ret += 12; - return (ret? ret+1: 2) + cx->dis_codewidth; + return (ret? ret+1: 2); +} + +// Comments start in commentcol() + 1 +static int commentcol() { + return codecol() + cx->dis_codewidth; } static int is_jumpable(int address) { @@ -426,30 +431,71 @@ static int is_jumpable(int address) { return cx->dis_jumpable[idx/n] & (1<<(idx%n)); } +// Format output for a label list r referenced by mnemonic m +static void output_references(const char *m, char *r) { + disasm_out("; %c%s from ", toupper(*m), m+1); + for(char *s = r; ; ) { + char *c = strchr(s+1, ','); + if(c && c-r > 80 && s > r) { + *s = 0; disasm_out("%s\n; %*s ", r, (int) strlen(m), ""); r = (char *) str_ltrim(s+1); s = r; + } else if(c && c-r > 70) { + *c = 0; disasm_out("%s\n; %*s ", r, (int) strlen(m), ""); r = (char *) str_ltrim(c+1); s = r; + } else if(c) { + s = c; + } else { + disasm_out("%s\n", r); + break; + } + } +} + // Unified printing of a line static void lineout(const char *code, const char *comment, int mnemo, int oplen, const char *buf, int pos, int addr, int showlabel) { - + Dis_jumpcall *jc = cx->dis_jumpcalls; int here = disasm_wrap(pos + addr); if(cx->dis_opts.labels && showlabel) { - int match = 0; + int match = 0, first = -1; const char *comment = NULL, *name; - for(int i = 0; i < cx->dis_jumpcallN; i++) { - if(cx->dis_jumpcalls[i].to == here) { + for(int i = 0; i < cx->dis_jumpcallN; i++) + if(jc[i].to == here) if(!match++) - cx->dis_para = 1; - disasm_out("; %s from L%0*x\n", avr_opcodes[cx->dis_jumpcalls[i].mnemo].opcode, - cx->dis_addrwidth, cx->dis_jumpcalls[i].from); - } - } + first = i; - if(match && (name = get_label_name(here, &comment))) { - if(comment) - disasm_out("%-*s ; %s\n", commentcol(), str_ccprintf("%s:", name), comment); - else - disasm_out("%s:\n", name); + if(cx->dis_pass == 2 && match) { + cx->dis_para++; + char *reflist = mmt_malloc(match*(3+64)), *r = reflist; // Worst case length + int mne = jc[first].mnemo, one_mne = 1, nnmne = 0; + for(int i = first; i < cx->dis_jumpcallN && jc[i].to == here; i++) { + if(mne != jc[i].mnemo) { // More than one mnemonic reference this line + one_mne = 0; + output_references(avr_opcodes[mne].opcode, reflist); + mne = jc[i].mnemo; + r = reflist; *r = 0; + nnmne = 0; + } + strcpy(r, str_ccprintf(", L%0*x" + 2*(r==reflist), cx->dis_addrwidth, jc[i].from)); + r += strlen(r); + nnmne++; + } + name = get_label_name(here, &comment); + if(!comment && strlen(reflist) + commentcol() < 70 && one_mne) { // Refs line with label + const char *mnestr = avr_opcodes[mne].opcode; + disasm_out("%-*s ; %s\n", commentcol(), str_ccprintf("%s:", name), + str_ccprintf("%c%s from %s", toupper(*mnestr), mnestr+1, reflist)); + } else { + output_references(avr_opcodes[mne].opcode, reflist); + if(comment) + disasm_out("%-*s ; %s\n", commentcol(), str_ccprintf("%s:", name), comment); + else + disasm_out("%s:\n", name); + } + cx->dis_para = -1; + mmt_free(reflist); + } else if(match) { + (void) get_label_name(here, &comment); } } @@ -462,13 +508,13 @@ static void lineout(const char *code, const char *comment, if(cx->dis_opts.opcode_bytes) for(int i = 0; i < 4; i++) disasm_out(i < oplen? "%02x ": " ", buf[pos + i] & 0xff); - disasm_out(commentcol() > 2 + cx->dis_codewidth? " ": " "); + disasm_out(codecol() > 2? " ": " "); if(!comment || !*comment || !cx->dis_opts.comments) disasm_out("%s\n", code); else disasm_out("%-*s ; %s\n", cx->dis_codewidth, code, comment); if(mnemo == MNEMO_ret || mnemo == MNEMO_u_ret || mnemo == MNEMO_reti || mnemo == MNEMO_u_reti) - cx->dis_para = 1; + cx->dis_para++; } // Process 1, 2 or 4 byte number @@ -488,6 +534,7 @@ static int process_num(const char *buf, int buflen, int nbytes, int pos, int off } static int process_fill0xff(const char *buf, int buflen, int nbytes, int pos, int offset) { + cx->dis_para++; lineout(str_ccprintf(".fill %d, 2, 0xffff", nbytes/2), NULL, -1, 1, buf, pos, offset, 0); return nbytes/2*2; } @@ -522,12 +569,12 @@ static int process_string(const char *buf, int buflen, int pos, int offset) { // Returns number of bytes of PGM data at this position, printing them in pass 2 static int process_data(const char *buf, int buflen, int pos, int offset) { int ret = 0; - Disasm_symbol *s = find_symbol('P', disasm_wrap(pos + offset)); + Dis_symbol *s = find_symbol('P', disasm_wrap(pos + offset)); if(!s) { if(pos+1 >= buflen) return 0; - if(!(s = find_symbol('P', disasm_wrap(pos + offset + 1)))) { // No PGM label, check for fill block + if(!(s = find_symbol('P', disasm_wrap(pos+offset+1)))) { // No PGM label, check for fill block int k = 0; if((buf[pos] &0xff) == 0xff && (buf[pos+1] & 0xff) == 0xff) for(k=pos+2; kname) { - cx->dis_para = 1; + cx->dis_para++; s->printed = 1; // Will be printed in pass 2 disasm_out("%s:\n", s->name); } @@ -572,7 +619,7 @@ static int process_data(const char *buf, int buflen, int pos, int offset) { } static void emit_used_symbols() { - Disasm_symbol *s = cx->dis_symbols; + Dis_symbol *s = cx->dis_symbols; int len, maxlen = 0; for(int i = 0; i < cx->dis_symbolN; i++) @@ -582,12 +629,12 @@ static void emit_used_symbols() { for(int i = 0; i < cx->dis_symbolN; i++) if(s[i].used && !s[i].printed && s[i].name) { - const char *equ = str_ccprintf(".equ %s,%*s 0x%02x", s[i].name, + const char *equ = str_ccprintf(".equ %s,%*s 0x%02x", s[i].name, (int) (maxlen-strlen(s[i].name)), "", s[i].address); if(s[i].comment) - disasm_out("%-*s ; %s\n", commentcol(), equ, s[i].comment); + disasm_out("%*s%-*s ; %s\n", codecol(), "", cx->dis_codewidth, equ, s[i].comment); else - disasm_out("%s\n", equ); + disasm_out("%*s%s\n", codecol(), "", equ); } } @@ -599,7 +646,7 @@ void disasm_zap_jumpcalls() { static void register_jumpcall(int from, int to, int mnemo, int is_func) { if(cx->dis_opts.labels) { - Disasm_jumpcall *jc = cx->dis_jumpcalls; + Dis_jumpcall *jc = cx->dis_jumpcalls; int N = cx->dis_jumpcallN; // Already entered this jumpcall? @@ -608,7 +655,7 @@ static void register_jumpcall(int from, int to, int mnemo, int is_func) { return; if(N % 1024 == 0) - jc = mmt_realloc(jc, sizeof(Disasm_jumpcall) * (N+1024)); + jc = mmt_realloc(jc, sizeof(Dis_jumpcall) * (N+1024)); jc[N].from = from; jc[N].to = to; jc[N].mnemo = mnemo; @@ -640,7 +687,7 @@ static void correct_is_funct(void) { } static int jumpcall_sort(const void *v1, const void *v2) { - const Disasm_jumpcall *p1 = v1, *p2 = v2; + const Dis_jumpcall *p1 = v1, *p2 = v2; int diff; if((diff = p1->to - p2->to)) return diff; @@ -651,7 +698,7 @@ static int jumpcall_sort(const void *v1, const void *v2) { static void enumerate_labels(void) { if(cx->dis_jumpcallN > 1) { - qsort(cx->dis_jumpcalls, cx->dis_jumpcallN, sizeof(Disasm_jumpcall), jumpcall_sort); + qsort(cx->dis_jumpcalls, cx->dis_jumpcallN, sizeof(Dis_jumpcall), jumpcall_sort); correct_is_funct(); int dest = 987654321, cur_labelno = 0, cur_funcno = 0; @@ -690,7 +737,7 @@ static void enumerate_labels(void) { #define Nb (bits['b']) #define Nq (bits['q']) -static char *add_comment(Disasm_line *line, const char *comment) { +static char *add_comment(Dis_line *line, const char *comment) { int len = strlen(line->comment), rem = LINE_N - len - 1; char *p = line->comment + len; @@ -724,7 +771,7 @@ typedef struct { } Op_context; static const char *get_ldi_name(int op1, int op2, Op_context *oxp) { - Disasm_symbol *s; + Dis_symbol *s; char buf[2]; int ra = ldi_Rd(op1), rb = ldi_Rd(op2); @@ -769,7 +816,7 @@ static const char *get_ldi_context(Op_context *oxp, int opcode) { } static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, - Op_context *oxp, Disasm_line *line) { + Op_context *oxp, Dis_line *line) { memset(line, 0, sizeof*line); if(mnemo < 0) { @@ -817,7 +864,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, if(Ns && Ns != 3) pmsg_warning("unexpected number of s bits in avr_opcodes table for OP_ID(%s)\n", oc->idname); - // cbr r17, 0x06 is marginally easier to read than andi r17, 0xf9 + // Cbr r17, 0x06 is marginally easier to read than andi r17, 0xf9 if(mnemo == MNEMO_andi && bitcount(RK) >= 4) { RK = ~RK & 0xff; mnemo = MNEMO_cbr; @@ -843,7 +890,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, int awd = cx->dis_addrwidth, swd = cx->dis_sramwidth; int target = 0, offset = 0, is_jumpcall = 0, is_relative = 0; - int is_function = !!(oc->type & OTY_EXTERNAL); // call/rcall affects stack memory + int is_function = !!(oc->type & OTY_EXTERNAL); // Call/rcall affects stack memory const char *name, *ksym = NULL, *asym = NULL, *rsym = NA? resolve_address('I', RA): NULL; if(Na) { @@ -934,11 +981,13 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, name = get_label_name(target, NULL); if(name && target != disasm_wrap(addr+2) && cx->dis_opts.labels && is_jumpable(target)) { add_operand(lc, "%s", name); - add_comment(line, str_ccprintf("L%0*x", awd, target)); + if(cx->dis_opts.addresses) + add_comment(line, str_ccprintf("L%0*x", awd, target)); } else { if(is_relative) { add_operand(lc, ".%+d", offset); - add_comment(line, str_ccprintf("L%0*x", awd, target)); + if(cx->dis_opts.addresses) + add_comment(line, str_ccprintf("L%0*x", awd, target)); } else add_operand(lc, "0x%0*x", awd, target); } @@ -951,7 +1000,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, break; case 'b': add_operand(lc, "%d", Rb); - add_comment(line, str_ccprintf("bit %d = 0x%02x", Rb, 1 << Rb)); + add_comment(line, str_ccprintf("Bit %d = 0x%02x", Rb, 1 << Rb)); break; case 's': add_operand(lc, "%d", Rs); @@ -968,7 +1017,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, else { if(op16_is_mnemo(opcode, MNEMO_ldi) && (name = get_ldi_context(oxp, opcode))) { add_operand(lc, "%s", name); - add_comment(line, str_ccprintf("0x%02x", RK)); + add_comment(line, str_ccprintf("0x%02x = %d", RK, RK)); } else { add_operand(lc, "0x%02x", RK); add_comment(line, str_ccprintf("%d", RK)); @@ -993,7 +1042,7 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, // Is there a label called main and it is used as a destination by disasm()? static int have_own_main() { int mainaddr = -1; - Disasm_symbol *s = cx->dis_symbols; + Dis_symbol *s = cx->dis_symbols; for(int i = 0; i < cx->dis_symbolN; i++) if(s[i].type == 'L' && s[i].name && str_eq(s[i].name, "main")) mainaddr = s[i].address; @@ -1004,17 +1053,19 @@ static int have_own_main() { return 0; } -static void set_context(Op_context *oxp, const char *buf, int pos, int buflen, int addr, int leadin, int leadout) { +static void set_context(Op_context *oxp, const char *buf, int pos, int buflen, int addr, + int leadin, int leadout) { + // Compute initial context structure: the opcode before and the following one oxp->from = disasm_wrap(pos+addr); - oxp->is_func = 0; // the next Z-opcode ahead is an icall/eicall - oxp->is_lpm = 0; // the next Z-opcode ahead is a lpm/elpm + oxp->is_func = 0; // Next Z-opcode ahead is an icall/eicall + oxp->is_lpm = 0; // Next Z-opcode ahead is a lpm/elpm oxp->preop = pos+leadin > 1? buf2op16(pos-2): -1; oxp->postop = -1; - oxp->zwd = 0; // 2: the next Z-opcode ahead uses Z as word addr, 1: as byte addr + oxp->zwd = 0; // 2: next Z-opcode ahead uses Z as word addr, 1: as byte addr int k = 0, op16, i = pos + op_width(buf2op16(pos)); if(i < buflen+leadout-1) { - AVR_mnemo zm = 0; + AVR_mnemo z = 0; oxp->postop = op16 = buf2op16(i); // Check whether there is an opcode ahead that uses the Z register @@ -1022,12 +1073,12 @@ static void set_context(Op_context *oxp, const char *buf, int pos, int buflen, i if(op16_is_mnemo(op16, MNEMO_rjmp) || op16_is_mnemo(op16, MNEMO_jmp) || op16_is_mnemo(op16, MNEMO_ret) || op16_is_mnemo(op16, MNEMO_reti) || op16_is_mnemo(op16, MNEMO_u_ret) || op16_is_mnemo(op16, MNEMO_u_reti) || - (oxp->zwd = z_width((op16 = buf2op16(i)), &zm))) + (oxp->zwd = z_width((op16 = buf2op16(i)), &z))) break; if(oxp->zwd == 2) - oxp->is_func = zm == MNEMO_icall || zm == MNEMO_eicall || zm == MNEMO_u_icall || zm == MNEMO_u_eicall; + oxp->is_func = z==MNEMO_icall || z==MNEMO_eicall || z==MNEMO_u_icall || z==MNEMO_u_eicall; else - oxp->is_lpm = zm >= MNEMO_lpm_0 && zm <= MNEMO_elpm_zp; + oxp->is_lpm = z >= MNEMO_lpm_0 && z <= MNEMO_elpm_zp; } } @@ -1040,7 +1091,7 @@ static void set_context(Op_context *oxp, const char *buf, int pos, int buflen, i */ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { int pos, opcode, mnemo, oplen; - Disasm_line line = {0}; + Dis_line line = {0}; Op_context ox = {0}; for(int i = 0; i < cx->dis_symbolN; i++) // Clear used/printed state of symbols @@ -1057,18 +1108,19 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { if(cx->dis_opts.avrgcc_style) emit_used_symbols(); if(cx->dis_opts.gcc_source) { - cx->dis_para=1; - disasm_out(".text\n%s", have_own_main()? "": "main:\n"); + cx->dis_para++; + disasm_out("%*s.text\n%s", codecol(), "", have_own_main()? "": "main:\n"); + cx->dis_para = -1; } } for(pos = 0; pos < buflen; pos += oplen) { // Check if this is actually code or maybe only data from tagfile if((oplen = process_data(buf, buflen, pos, addr))) { - cx->dis_para = 1; + cx->dis_para++; continue; } - if(pos & 1) { // Last of PGM data items left off at odd address + if(pos & 1) { // Last of PGM data items left off at odd address oplen = process_num(buf, buflen, 1, pos, addr); continue; } @@ -1081,7 +1133,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) { set_context(&ox, buf, pos, buflen, addr, leadin, leadout); disassemble(buf + pos, disasm_wrap(pos + addr), opcode, mnemo, &ox, &line); lineout(line.code, line.comment, mnemo, oplen, buf, pos, addr, 1); - if(cx->dis_pass == 1) { // Mark this position as potential jump/call destination + if(cx->dis_pass == 1) { // Mark this position as potential jump/call destination int n = sizeof(int)*8, idx = pos/2; cx->dis_jumpable[idx/n] |= (1<<(idx%n)); } @@ -1103,11 +1155,11 @@ int disasm_init(const AVRPART *p) { return -1; } - cx->dis_flashsz = 0; // Flash size - cx->dis_flashsz2 = 0; // Flash size rounded up to next power of two - cx->dis_addrwidth = 4; // Number of hex digits needed for flash addresses - cx->dis_sramwidth = 4; // Number of hex digits needed for sram addresses - cx->dis_codewidth = 27; // Width of the code column (ldi r17, 0x32) + cx->dis_flashsz = 0; // Flash size + cx->dis_flashsz2 = 0; // Flash size rounded up to next power of two + cx->dis_addrwidth = 4; // Number of hex digits needed for flash addresses + cx->dis_sramwidth = 4; // Number of hex digits needed for sram addresses + cx->dis_codewidth = 27; // Width of the code column (ldi r17, 0x32) if((mem = avr_locate_flash(p)) && mem->size > 1) { int nbits = intlog2(mem->size - 1) + 1; diff --git a/src/libavrdude.h b/src/libavrdude.h index 7f085136..50ce767e 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1461,11 +1461,11 @@ typedef struct { int op_names, op_explanations, avrgcc_style, labels; int avrlevel; // Eg, PART_AVR_XM or PART_AVR_51 (describes opcodes for the part) char *tagfile; // Maps addresses to labels, PGM data, memory and I/O variables -} Disasm_options; +} Dis_options; typedef struct { int from, to, mnemo, labelno, is_func; -} Disasm_jumpcall; +} Dis_jumpcall; typedef struct { char *name, *comment; @@ -1475,7 +1475,7 @@ typedef struct { int count; // array length for tag file variables int used; // Whether symbol was referenced by disassembly process int printed; // Whether this L/P label will be printed in pass 2 -} Disasm_symbol; +} Dis_symbol; // Order of enums must align with avr_opcodes[] table order typedef enum { @@ -1825,10 +1825,10 @@ typedef struct { // Static variables from disasm.c int dis_initopts, dis_flashsz, dis_flashsz2, dis_addrwidth, dis_sramwidth; int dis_pass, dis_para, dis_cycle_index, dis_io_offset, dis_codewidth; - Disasm_options dis_opts; + Dis_options dis_opts; int dis_jumpcallN, dis_symbolN, *dis_jumpable, dis_start, dis_end; - Disasm_jumpcall *dis_jumpcalls; - Disasm_symbol *dis_symbols; + Dis_jumpcall *dis_jumpcalls; + Dis_symbol *dis_symbols; // Static variables from usb_libusb.c #include "usbdevs.h" From 9d2af7323c572e3031223f4336cc4960ae7d23d5 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 28 Jul 2024 00:09:47 +0100 Subject: [PATCH 370/422] Extend ldi symbolic names to ser --- src/disasm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/disasm.c b/src/disasm.c index d9eafbfa..5f58798c 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -51,6 +51,7 @@ #define buf2op16(i) ((buf[i] & 0xff) | (buf[(i)+1] & 0xff)<<8) + static void zap_symbols() { if(cx->dis_symbols) { for(int i = 0; i < cx->dis_symbolN; i++) { @@ -826,6 +827,12 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, } const AVR_opcode *oc = avr_opcodes+mnemo; + const char *lsym = NULL; + if(op16_is_mnemo(opcode, MNEMO_ldi) && (lsym = get_ldi_context(oxp, opcode))) { + mnemo = MNEMO_ldi; // Could have been ser + oc = avr_opcodes+mnemo; + } + int regs[128] = {0}, bits[128] = {0}; unsigned bmask = 0x8000; for(const char *p = oc->bits; *p && bmask; p++) { @@ -1015,8 +1022,8 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_mnemo mnemo, if(NK == 4) add_operand(lc, "%d", RK); else { - if(op16_is_mnemo(opcode, MNEMO_ldi) && (name = get_ldi_context(oxp, opcode))) { - add_operand(lc, "%s", name); + if(mnemo == MNEMO_ldi && lsym) { + add_operand(lc, "%s", lsym); add_comment(line, str_ccprintf("0x%02x = %d", RK, RK)); } else { add_operand(lc, "0x%02x", RK); From c51d50ce0952c1a9a1a820511978a0248fb2f70b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 28 Jul 2024 00:24:39 +0100 Subject: [PATCH 371/422] Add sram.start and sram.end to known symbols --- src/disasm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/disasm.c b/src/disasm.c index 5f58798c..fe0d76f7 100644 --- a/src/disasm.c +++ b/src/disasm.c @@ -289,9 +289,14 @@ static void add_register(int io_off, int addr, const char *name, int suffix) { // Initialise cx->dis_symbols from part register file static void init_regfile(const AVRPART *p) { + AVRMEM *mem; int nr = 0, io_off = cx->dis_io_offset; const Register_file *rf = avr_locate_register_file(p, &nr); + if((mem = avr_locate_sram(p)) && mem->size > 1 && mem->offset <= 0x200) { + add_symbol(mem->offset, 'M', TYPE_BYTE, mem->size, "sram.start", NULL); + add_symbol(mem->offset+mem->size-1, 'M', TYPE_BYTE, 1, "sram.end", NULL); + } if(rf) { for(int i = 0; i < nr; i++) { const char *rname = io_off? shortrname(rf, nr, i): rf[i].reg; @@ -1166,7 +1171,7 @@ int disasm_init(const AVRPART *p) { cx->dis_flashsz2 = 0; // Flash size rounded up to next power of two cx->dis_addrwidth = 4; // Number of hex digits needed for flash addresses cx->dis_sramwidth = 4; // Number of hex digits needed for sram addresses - cx->dis_codewidth = 27; // Width of the code column (ldi r17, 0x32) + cx->dis_codewidth = 28; // Width of the code column (eg, ldi r17, 0x32) if((mem = avr_locate_flash(p)) && mem->size > 1) { int nbits = intlog2(mem->size - 1) + 1; From c3d97e923e3d14af78a4027f1a99f3e094095a9b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sun, 28 Jul 2024 17:57:51 +0100 Subject: [PATCH 372/422] Add -xnoautoreset for the -c urclock programmer --- src/urclock.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/urclock.c b/src/urclock.c index 3c6bd7ea..d99346a0 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -319,6 +319,7 @@ typedef struct { nodate, // Don't store application filename and no date either nostore, // Don't store metadata except a flag saying so nometadata, // Don't support metadata at all + noautoreset, // Don't reset the board after opening the serial port delay, // Additional delay [ms] after resetting the board, can be negative strict; // Use strict synchronisation protocol @@ -2247,16 +2248,18 @@ static int urclock_open(PROGRAMMER *pgm, const char *port) { if(serial_open(port, pinfo, &pgm->fd) == -1) return -1; - // This code assumes a negative-logic USB to TTL serial adapter - // Set RTS/DTR high to discharge the series-capacitor, if present - serial_set_dtr_rts(&pgm->fd, 0); - usleep(20*1000); - // Pull the RTS/DTR line low to reset AVR - serial_set_dtr_rts(&pgm->fd, 1); - // Max 100 us: charging a cap longer creates a high reset spike above Vcc - usleep(100); - // Set the RTS/DTR line back to high, so direct connection to reset works - serial_set_dtr_rts(&pgm->fd, 0); + if(!ur.noautoreset) { + // This code assumes a negative-logic USB to TTL serial adapter + // Set RTS/DTR high to discharge the series-capacitor, if present + serial_set_dtr_rts(&pgm->fd, 0); + usleep(20*1000); + // Pull the RTS/DTR line low to reset AVR + serial_set_dtr_rts(&pgm->fd, 1); + // Max 100 us: charging a cap longer creates a high reset spike above Vcc + usleep(100); + // Set the RTS/DTR line back to high, so direct connection to reset works + serial_set_dtr_rts(&pgm->fd, 0); + } if((120+ur.delay) > 0) usleep((120+ur.delay)*1000); // Wait until board comes out of reset @@ -2477,6 +2480,7 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) { {"nodate", &ur.nodate, NA, "Do not store application filename and no date either"}, {"nostore", &ur.nostore, NA, "Do not store metadata except a flag saying so"}, {"nometadata", &ur.nometadata, NA, "Do not support metadata at all"}, + {"noautoreset", &ur.nometadata, NA, "Do not reset the board after opening the serial port"}, {"delay", &ur.delay, ARG, "Add delay [ms] after reset, can be negative"}, {"strict", &ur.strict, NA, "Use strict synchronisation protocol"}, {"help", &help, NA, "Show this help menu and exit"}, From 94e968af916c82a828cd86b79b52d91e1bdafe0b Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 28 Jul 2024 20:07:57 +0200 Subject: [PATCH 373/422] Use %i instead of %2d --- src/arduino.c | 2 +- src/stk500.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index 73a0bd70..ae75be09 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -45,7 +45,7 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); - if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) { + if (sscanf(extended_param, "attempts=%i", &attempts) == 1) { PDATA(pgm)->retry_attempts = attempts; pmsg_info("setting number of retry attempts to %d\n", attempts); continue; diff --git a/src/stk500.c b/src/stk500.c index a7c5657e..47418ec4 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -650,7 +650,7 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) for (ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); - if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) { + if (sscanf(extended_param, "attempts=%i", &attempts) == 1) { PDATA(pgm)->retry_attempts = attempts; pmsg_info("setting number of retry attempts to %d\n", attempts); continue; From 12c41f2d0ef38a169eb7be2f2a140c3ec1efeda0 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 28 Jul 2024 20:24:31 +0200 Subject: [PATCH 374/422] Small tweaks based on feedback from @stefanrueger --- src/arduino.c | 18 ++++++------------ src/butterfly.c | 9 ++------- src/stk500.c | 2 +- src/wiring.c | 17 ++++++----------- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index ae75be09..3cfc0550 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -51,25 +51,20 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { continue; } - if(str_starts(extended_param, "no_autoreset")) { - if(!str_eq(extended_param, "no_autoreset")) { - pmsg_error("invalid -xno_autoreset value %s. Use -xno_autoreset\n", extended_param); - rv = -1; - break; - } + if(str_eq(extended_param, "noautoreset")) { PDATA(pgm)->autoreset = false; continue; } if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xattempts= Specify no. connection retry attempts\n"); - msg_error(" -xno_autoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -xattempts= Specify the number of connection retry attempts\n"); + msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); + msg_error(" -xhelp Show this help menu and exit\n"); return LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter %s\n", extended_param); rv = -1; } @@ -154,8 +149,7 @@ static int arduino_open(PROGRAMMER *pgm, const char *port) { return 0; } -static void arduino_close(PROGRAMMER *pgm) -{ +static void arduino_close(PROGRAMMER *pgm) { serial_close(&pgm->fd); pgm->fd.ifd = -1; } diff --git a/src/butterfly.c b/src/butterfly.c index a6d5fdc8..a84d4935 100644 --- a/src/butterfly.c +++ b/src/butterfly.c @@ -701,12 +701,7 @@ static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); - if(str_starts(extended_param, "autoreset")) { - if(!str_eq(extended_param, "autoreset")) { - pmsg_error("invalid -xautoreset value %s. Use -xautoreset\n", extended_param); - rv = -1; - break; - } + if(str_eq(extended_param, "autoreset")) { PDATA(pgm)->autoreset = true; continue; } @@ -718,7 +713,7 @@ static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) exit(0); } - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter %s\n", extended_param); rv = -1; } diff --git a/src/stk500.c b/src/stk500.c index 47418ec4..0531f60a 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -784,7 +784,7 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) else if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xattempts= Specify no. connection retry attempts\n"); + msg_error(" -xattempts= Specify the number of connection retry attempts\n"); if (pgm->extra_features & HAS_VTARG_READ) { msg_error(" -xvtarg Read target supply voltage\n"); } diff --git a/src/wiring.c b/src/wiring.c index e5b8c06f..dc77bf71 100644 --- a/src/wiring.c +++ b/src/wiring.c @@ -108,25 +108,20 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { WIRINGPDATA(pgm)->delay = val; continue; } - else if(str_starts(extended_param, "no_autoreset")) { - if(!str_eq(extended_param, "no_autoreset")) { - pmsg_error("invalid -xno_autoreset value %s. Use -xno_autoreset\n", extended_param); - rv = -1; - break; - } + else if(str_eq(extended_param, "noautoreset")) { WIRINGPDATA(pgm)->autoreset = false; continue; } else if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xsnooze= Wait snooze [ms] before protocol sync after port open\n"); - msg_error(" -xdelay= Add delay [ms] after reset, can be negative\n"); - msg_error(" -xno_autoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -xsnooze= Wait snooze ms before protocol sync after port open\n"); + msg_error(" -xdelay= Add delay [n] ms after reset, can be negative\n"); + msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); + msg_error(" -xhelp Show this help menu and exit\n"); return LIBAVRDUDE_EXIT;; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter %s\n", extended_param); rv = -1; } From cda52a3a06a7f90310ee965a001d2a7c954aaecc Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 28 Jul 2024 21:56:49 +0200 Subject: [PATCH 375/422] Fix autoreset flag for -c arduino plus a few other minor things --- src/arduino.c | 3 --- src/stk500.c | 12 +++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index 3cfc0550..06dbff5b 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -162,10 +162,7 @@ void arduino_initpgm(PROGRAMMER *pgm) { and the DTR signal is set when opening the serial port for the Auto-Reset feature */ stk500_initpgm(pgm); - strcpy(pgm->type, "Arduino"); - PDATA(&pgm)->autoreset = true; // Auto-reset enabled by default - pgm->read_sig_bytes = arduino_read_sig_bytes; pgm->open = arduino_open; pgm->close = arduino_close; diff --git a/src/stk500.c b/src/stk500.c index 0531f60a..85835096 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -116,7 +116,7 @@ int stk500_getsync(const PROGRAMMER *pgm) { for (attempt = 0; attempt < max_sync_attempts; attempt++) { // Restart Arduino bootloader for every sync attempt - if (PDATA(pgm)->autoreset && attempt > 0) { + if(str_eq(pgm->type, "Arduino") && PDATA(pgm)->autoreset && attempt > 0) { // This code assumes a negative-logic USB to TTL serial adapter // Pull the RTS/DTR line low to reset AVR: it is still high from open()/last attempt serial_set_dtr_rts(&pgm->fd, 1); @@ -894,8 +894,7 @@ static int stk500_open(PROGRAMMER *pgm, const char *port) { } -static void stk500_close(PROGRAMMER * pgm) -{ +static void stk500_close(PROGRAMMER *pgm) { // MIB510 close if (str_eq(pgmid, "mib510")) (void)mib510_isp(pgm, 0); @@ -1569,7 +1568,7 @@ static void stk500_print_parms(const PROGRAMMER *pgm, FILE *fp) { stk500_print_parms1(pgm, "", fp); } -static void stk500_setup(PROGRAMMER * pgm) { +static void stk500_setup(PROGRAMMER *pgm) { pgm->cookie = mmt_malloc(sizeof(struct pdata)); PDATA(pgm)->ext_addr_byte = 0xff; PDATA(pgm)->xbeeResetPin = XBEE_DEFAULT_RESET_PIN; @@ -1578,9 +1577,12 @@ static void stk500_setup(PROGRAMMER * pgm) { PDATA(pgm)->xtal = 16000000U; else PDATA(pgm)->xtal = STK500_XTAL; + // The -c arduino programmer has auto-reset enabled be default + if (str_eq(pgmid, "arduino")) + PDATA(pgm)->autoreset = true; } -static void stk500_teardown(PROGRAMMER * pgm) { +static void stk500_teardown(PROGRAMMER *pgm) { mmt_free(pgm->cookie); pgm->cookie = NULL; } From c1a037822945ccdd2ed41c8625a08dc5e6cbb61c Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 06:31:50 +0200 Subject: [PATCH 376/422] Print -x help text when invalid extended option is passed --- src/arduino.c | 21 +++++++++------- src/butterfly.c | 18 +++++++------ src/stk500.c | 67 ++++++++++++++++++++++++++----------------------- src/wiring.c | 22 +++++++++------- 4 files changed, 71 insertions(+), 57 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index 06dbff5b..b4bed6c5 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -40,7 +40,7 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { const char *extended_param; int attempts; - int rv = 0; + int rv = 0, help = 0; for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); @@ -57,17 +57,20 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xattempts= Specify the number of connection retry attempts\n"); - msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT; + help = 1; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter %s\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xattempts= Specify the number of connection retry attempts\n"); + msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } - return rv; } diff --git a/src/butterfly.c b/src/butterfly.c index a84d4935..3d6e3e18 100644 --- a/src/butterfly.c +++ b/src/butterfly.c @@ -696,7 +696,7 @@ static int butterfly_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, con static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { const char *extended_param; - int rv = 0; + int rv = 0, help = 0; for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); @@ -707,14 +707,18 @@ static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xautoreset Toggle RTS/DTR lines on port open to issue a hardware reset\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - exit(0); + help = 1; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter %s\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xautoreset Toggle RTS/DTR lines on port open to issue a hardware reset\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } return rv; diff --git a/src/stk500.c b/src/stk500.c index 85835096..0ef79b30 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -640,15 +640,14 @@ static int stk500_initialize(const PROGRAMMER *pgm, const AVRPART *p) { return pgm->program_enable(pgm, p); } -static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) - { - LNODEID ln; - const char *extended_param; - int attempts; - int rv = 0; +static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { + LNODEID ln; + const char *extended_param; + int attempts; + int rv = 0, help = 0; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); if (sscanf(extended_param, "attempts=%i", &attempts) == 1) { PDATA(pgm)->retry_attempts = attempts; @@ -783,33 +782,37 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } else if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xattempts= Specify the number of connection retry attempts\n"); - if (pgm->extra_features & HAS_VTARG_READ) { - msg_error(" -xvtarg Read target supply voltage\n"); - } - if (pgm->extra_features & HAS_VTARG_ADJ) { - msg_error(" -xvtarg= Set target supply voltage\n"); - } - if (pgm->extra_features & HAS_VAREF_ADJ) { - msg_error(" -xvaref Read analog reference voltage\n"); - msg_error(" -xvaref= Set analog reference voltage\n"); - } - if (pgm->extra_features & HAS_FOSC_ADJ) { - msg_error(" -xfosc Read oscillator clock frequency\n"); - msg_error(" -xfosc=[M|k]|off Set oscillator clock frequency\n"); - } - msg_error(" -xxtal=[M|k] Set programmer xtal frequency\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = 1; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter %s\n", extended_param); - rv = -1; - } + if (!help) { + pmsg_error("invalid extended parameter %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xattempts= Specify the number of connection retry attempts\n"); + if (pgm->extra_features & HAS_VTARG_READ) { + msg_error(" -xvtarg Read target supply voltage\n"); + } + if (pgm->extra_features & HAS_VTARG_ADJ) { + msg_error(" -xvtarg= Set target supply voltage\n"); + } + if (pgm->extra_features & HAS_VAREF_ADJ) { + msg_error(" -xvaref Read analog reference voltage\n"); + msg_error(" -xvaref= Set analog reference voltage\n"); + } + if (pgm->extra_features & HAS_FOSC_ADJ) { + msg_error(" -xfosc Read oscillator clock frequency\n"); + msg_error(" -xfosc=[M|k]|off Set oscillator clock frequency\n"); + } + msg_error(" -xxtal=[M|k] Set programmer xtal frequency\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; + } - return rv; - } + return rv; +} static void stk500_disable(const PROGRAMMER *pgm) { unsigned char buf[16]; diff --git a/src/wiring.c b/src/wiring.c index dc77bf71..9d0046d8 100644 --- a/src/wiring.c +++ b/src/wiring.c @@ -83,7 +83,7 @@ static void wiring_teardown(PROGRAMMER *pgm) { static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { LNODEID ln; const char *extended_param, *errstr; - int rv = 0; + int rv = 0, help = 0; for (ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); @@ -113,16 +113,20 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { continue; } else if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xsnooze= Wait snooze ms before protocol sync after port open\n"); - msg_error(" -xdelay= Add delay [n] ms after reset, can be negative\n"); - msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = 1; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter %s\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xsnooze= Wait snooze ms before protocol sync after port open\n"); + msg_error(" -xdelay= Add delay [n] ms after reset, can be negative\n"); + msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } return rv; From 568bb8e575046e8fdd07f0fef91492ada512de82 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 09:19:50 +0200 Subject: [PATCH 377/422] Use bool instead of int for help flag --- src/arduino.c | 5 +++-- src/butterfly.c | 5 +++-- src/stk500.c | 5 +++-- src/wiring.c | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index b4bed6c5..b0613971 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -40,7 +40,8 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { const char *extended_param; int attempts; - int rv = 0, help = 0; + int rv = 0; + bool help = 0; for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); @@ -57,7 +58,7 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if (str_eq(extended_param, "help")) { - help = 1; + help = true; rv = LIBAVRDUDE_EXIT; } diff --git a/src/butterfly.c b/src/butterfly.c index 3d6e3e18..6d7bc95e 100644 --- a/src/butterfly.c +++ b/src/butterfly.c @@ -696,7 +696,8 @@ static int butterfly_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, con static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { const char *extended_param; - int rv = 0, help = 0; + int rv = 0; + bool help = 0; for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); @@ -707,7 +708,7 @@ static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } if (str_eq(extended_param, "help")) { - help = 1; + help = true; rv = LIBAVRDUDE_EXIT; } diff --git a/src/stk500.c b/src/stk500.c index 0ef79b30..c8f27c40 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -644,7 +644,8 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { LNODEID ln; const char *extended_param; int attempts; - int rv = 0, help = 0; + int rv = 0; + bool help = false; for (ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); @@ -782,7 +783,7 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } else if (str_eq(extended_param, "help")) { - help = 1; + help = true; rv = LIBAVRDUDE_EXIT; } diff --git a/src/wiring.c b/src/wiring.c index 9d0046d8..2d6aaa3d 100644 --- a/src/wiring.c +++ b/src/wiring.c @@ -83,7 +83,8 @@ static void wiring_teardown(PROGRAMMER *pgm) { static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { LNODEID ln; const char *extended_param, *errstr; - int rv = 0, help = 0; + int rv = 0; + bool help = 0; for (ln = lfirst(extparms); ln; ln = lnext(ln)) { extended_param = ldata(ln); @@ -113,7 +114,7 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { continue; } else if (str_eq(extended_param, "help")) { - help = 1; + help = true; rv = LIBAVRDUDE_EXIT; } From 313c8b4d1ad800128f17f508f3eaca84982b26c4 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 10:31:56 +0200 Subject: [PATCH 378/422] Print helptext for all programmers that supports extended params when incorrect param is specified --- src/arduino.c | 3 +-- src/avr910.c | 25 ++++++++++-------- src/buspirate.c | 66 +++++++++++++++++++++++++++------------------- src/dryrun.c | 45 +++++++++++++++++++------------ src/jtag3.c | 57 ++++++++++++++++++++------------------- src/jtagmkII.c | 30 +++++++++++---------- src/linuxspi.c | 24 ++++++++++------- src/micronucleus.c | 39 ++++++++++++++++----------- src/pickit2.c | 32 ++++++++++++---------- src/serialupdi.c | 27 +++++++++++-------- src/stk500.c | 6 ++--- src/stk500v2.c | 49 ++++++++++++++++++---------------- src/teensy.c | 39 ++++++++++++++++----------- src/wiring.c | 10 +++---- src/xbee.c | 24 ++++++++++------- 15 files changed, 271 insertions(+), 205 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index b0613971..7d83275a 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -38,13 +38,12 @@ #include "arduino.h" static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - const char *extended_param; int attempts; int rv = 0; bool help = 0; for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + const char *extended_param = ldata(ln); if (sscanf(extended_param, "attempts=%i", &attempts) == 1) { PDATA(pgm)->retry_attempts = attempts; diff --git a/src/avr910.c b/src/avr910.c index 2770a04a..cc498dee 100644 --- a/src/avr910.c +++ b/src/avr910.c @@ -308,12 +308,11 @@ static int avr910_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, static int avr910_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rv = 0; + bool help = false; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (str_starts(extended_param, "devcode=")) { int devcode; @@ -335,15 +334,19 @@ static int avr910_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { continue; } if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xdevcode= Override device code\n"); - msg_error(" -xno_blockmode Disable default checking for block transfer capability\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT; + help = true; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xdevcode= Override device code\n"); + msg_error(" -xno_blockmode Disable default checking for block transfer capability\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } return rv; diff --git a/src/buspirate.c b/src/buspirate.c index 8a741570..c6028f37 100644 --- a/src/buspirate.c +++ b/src/buspirate.c @@ -288,17 +288,18 @@ static void buspirate_dummy_6(const PROGRAMMER *pgm, const char *p) { /* ====== Config / parameters handling functions ====== */ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; + int rv = 0; char reset[10]; char *preset = reset; /* for strtok() */ unsigned int spifreq; unsigned int rawfreq; unsigned int cpufreq; int serial_recv_timeout; + bool help = false; + + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); if (str_eq(extended_param, "ascii")) { PDATA(pgm)->flag |= BP_FLAG_XPARM_FORCE_ASCII; continue; @@ -318,11 +319,13 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) if (spifreq & (~0x07)) { pmsg_error("spifreq must be between 0 and 7\n"); imsg_error("see BusPirate manual for details\n"); - return -1; + rv = -1; + break; } if (PDATA(pgm)->flag & BP_FLAG_XPARM_RAWFREQ) { pmsg_error("set either spifreq or rawfreq\n"); - return -1; + rv = -1; + break; } PDATA(pgm)->flag |= BP_FLAG_XPARM_SPIFREQ; PDATA(pgm)->spifreq = spifreq; @@ -332,11 +335,13 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) if (sscanf(extended_param, "rawfreq=%u", &rawfreq) == 1) { if (rawfreq >= 4) { pmsg_error("rawfreq must be between 0 and 3\n"); - return -1; + rv = -1; + break; } if (PDATA(pgm)->flag & BP_FLAG_XPARM_SPIFREQ) { pmsg_error("set either spifreq or rawfreq\n"); - return -1; + rv = -1; + break; } PDATA(pgm)->flag |= BP_FLAG_XPARM_RAWFREQ; PDATA(pgm)->spifreq = rawfreq; @@ -348,7 +353,8 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) if (cpufreq < 125 || cpufreq > 4000) { pmsg_error("cpufreq must be between 125 and 4000 kHz\n"); imsg_error("see BusPirate manual for details\n"); - return -1; + rv = -1; + break; } PDATA(pgm)->cpufreq = cpufreq; PDATA(pgm)->flag |= BP_FLAG_XPARM_CPUFREQ; @@ -367,7 +373,8 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) PDATA(pgm)->reset |= BP_RESET_AUX2; else { pmsg_error("reset must be either CS or AUX\n"); - return -1; + rv = -1; + break; } } PDATA(pgm)->flag |= BP_FLAG_XPARM_RESET; @@ -387,33 +394,38 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) if (sscanf(extended_param, "serial_recv_timeout=%d", &serial_recv_timeout) == 1) { if (serial_recv_timeout < 1) { pmsg_error("serial_recv_timeout must be greater 0\n"); - return -1; + rv = -1; + break; } PDATA(pgm)->serial_recv_timeout = serial_recv_timeout; continue; } if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xreset=cs,aux,aux2 Override default reset pin\n"); - msg_error(" -xspifreq=<0..7> Set binary SPI mode speed\n"); - msg_error(" -xrawfreq=<0..3> Set \"raw-wire\" SPI mode speed\n"); - msg_error(" -xascii Use ASCII protocol between BP and Avrdude\n"); - msg_error(" -xnopagedwrite Disable page write functionality\n"); - msg_error(" -xnopagedread Disable page read functionality\n"); - msg_error(" -xcpufreq=<125..4000> Set the AUX pin to output a frequency to n [kHz]\n"); - msg_error(" -xserial_recv_timeout= Set serial receive timeout to [ms]\n"); - msg_error(" -xpullups Enable internal pull-ups\n"); - msg_error(" -xhiz SPI HiZ mode (open collector)\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = true; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("do not understand extended param '%s'\n", extended_param); - return -1; + if (!help) { + pmsg_error("invalid extended parameter %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xreset=cs,aux,aux2 Override default reset pin\n"); + msg_error(" -xspifreq=<0..7> Set binary SPI mode speed\n"); + msg_error(" -xrawfreq=<0..3> Set \"raw-wire\" SPI mode speed\n"); + msg_error(" -xascii Use ASCII protocol between BP and Avrdude\n"); + msg_error(" -xnopagedwrite Disable page write functionality\n"); + msg_error(" -xnopagedread Disable page read functionality\n"); + msg_error(" -xcpufreq=<125..4000> Set the AUX pin to output a frequency to n [kHz]\n"); + msg_error(" -xserial_recv_timeout= Set serial receive timeout to [ms]\n"); + msg_error(" -xpullups Enable internal pull-ups\n"); + msg_error(" -xhiz SPI HiZ mode (open collector)\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } - return 0; + return rv; } static int buspirate_verifyconfig(const PROGRAMMER *pgm) { diff --git a/src/dryrun.c b/src/dryrun.c index 8e125bfd..b33bd0dc 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -1036,42 +1036,53 @@ static void dryrun_teardown(PROGRAMMER *pgm) { static int dryrun_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { + int rc = 0; + bool help = false; + for(LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { const char *xpara = ldata(ln); if(str_starts(xpara, "init")) { dry.init = 1; continue; - } else if(str_starts(xpara, "random")) { + } + if(str_starts(xpara, "random")) { dry.random = 1; continue; - } else if(str_starts(xpara, "seed=")) { + } + if(str_starts(xpara, "seed=")) { const char *errptr; int seed = str_int(strchr(xpara, '=')+1, STR_INT32, &errptr); if(errptr) { pmsg_error("cannot parse %s seed value: %s\n", xpara, errptr); - return -1; + rc = -1; + break; } dry.seed = seed; continue; - } else if(str_eq(xpara, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xinit Initialise memories with human-readable patterns (1, 2, 3)\n"); - msg_error(" -xrandom Initialise memories with random code/values (1, 3)\n"); - msg_error(" -xseed= Seed random number generator with , default time(NULL)\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - msg_error("Notes:\n"); - msg_error(" (1) -xinit and -xrandom randomly configure flash wrt boot/data/code length\n"); - msg_error(" (2) Patterns can best be seen with fixed-width font on -U flash:r:-:I\n"); - msg_error(" (3) Choose, eg, -xseed=1 for reproducible flash configuration and output\n"); - return LIBAVRDUDE_EXIT; + } + if(str_eq(xpara, "help")) { + help = true; + rc = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", xpara); - return -1; + if(!help) { + pmsg_error("invalid extended parameter '%s'\n", xpara); + rc = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xinit Initialise memories with human-readable patterns (1, 2, 3)\n"); + msg_error(" -xrandom Initialise memories with random code/values (1, 3)\n"); + msg_error(" -xseed= Seed random number generator with , default time(NULL)\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + msg_error("Notes:\n"); + msg_error(" (1) -xinit and -xrandom randomly configure flash wrt boot/data/code length\n"); + msg_error(" (2) Patterns can best be seen with fixed-width font on -U flash:r:-:I\n"); + msg_error(" (3) Choose, eg, -xseed=1 for reproducible flash configuration and output\n"); + return rc; } - return 0; + return rc; } const char dryrun_desc[] = "Dryrun programmer for testing avrdude"; diff --git a/src/jtag3.c b/src/jtag3.c index 43ae6d5c..2b9574a7 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -1456,12 +1456,11 @@ static void jtag3_enable(PROGRAMMER *pgm, const AVRPART *p) { } static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rv = 0; + bool help = false; - for(ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for(LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if(str_starts(extended_param, "jtagchain=") && (pgm->prog_modes & (PM_JTAG | PM_XMEGAJTAG | PM_AVR32JTAG))) { unsigned int ub, ua, bb, ba; @@ -1602,31 +1601,35 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if(str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - if(str_eq(pgm->type, "JTAGICE3")) - msg_error(" -xjtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); - if(lsize(pgm->hvupdi_support) > 1) - msg_error(" -xhvupdi Enable high-voltage UPDI initialization\n"); - if(pgm->extra_features & HAS_SUFFER) { - msg_error(" -xsuffer Read SUFFER register value\n"); - msg_error(" -xsuffer= Set SUFFER register value\n"); - } - if(pgm->extra_features & HAS_VTARG_SWITCH) { - msg_error(" -xvtarg_switch Read on-board target voltage switch state\n"); - msg_error(" -xvtarg_switch=<0..1> Set on-board target voltage switch state\n"); - } - if(pgm->extra_features & HAS_VTARG_ADJ) { - msg_error(" -xvtarg Read on-board target supply voltage\n"); - msg_error(" -xvtarg= Set on-board target supply voltage\n"); - } - if(str_starts(pgmid, "pickit4") || str_starts(pgmid, "snap")) - msg_error(" -xmode=avr|pic Set programmer to AVR or PIC mode, then exit\n"); - msg_error (" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = true; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter %s\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + if(str_eq(pgm->type, "JTAGICE3")) + msg_error(" -xjtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); + if(lsize(pgm->hvupdi_support) > 1) + msg_error(" -xhvupdi Enable high-voltage UPDI initialization\n"); + if(pgm->extra_features & HAS_SUFFER) { + msg_error(" -xsuffer Read SUFFER register value\n"); + msg_error(" -xsuffer= Set SUFFER register value\n"); + } + if(pgm->extra_features & HAS_VTARG_SWITCH) { + msg_error(" -xvtarg_switch Read on-board target voltage switch state\n"); + msg_error(" -xvtarg_switch=<0..1> Set on-board target voltage switch state\n"); + } + if(pgm->extra_features & HAS_VTARG_ADJ) { + msg_error(" -xvtarg Read on-board target supply voltage\n"); + msg_error(" -xvtarg= Set on-board target supply voltage\n"); + } + if(str_starts(pgmid, "pickit4") || str_starts(pgmid, "snap")) + msg_error(" -xmode=avr|pic Set programmer to AVR or PIC mode, then exit\n"); + msg_error (" -xhelp Show this help menu and exit\n"); + return rv; } return rv; diff --git a/src/jtagmkII.c b/src/jtagmkII.c index be97b147..2dacfad1 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -1334,12 +1334,11 @@ static void jtagmkII_enable(PROGRAMMER *pgm, const AVRPART *p) { } static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rv = 0; + bool help = false; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (pgm->flag & PGM_FL_IS_JTAG) { if (str_eq(extended_param, "jtagchain=")) { @@ -1356,7 +1355,6 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) PDATA(pgm)->jtagchain[1] = ua; PDATA(pgm)->jtagchain[2] = bb; PDATA(pgm)->jtagchain[3] = ba; - continue; } } @@ -1370,7 +1368,8 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) PDATA(pgm)->rts_mode = RTS_MODE_HIGH; } else { pmsg_error("RTS/DTR mode must be LOW or HIGH\n"); - return -1; + rv = -1; + break; } continue; } @@ -1378,16 +1377,19 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - if (pgm->flag & PGM_FL_IS_JTAG) - msg_error(" -xjtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); - if (pgm->flag & PGM_FL_IS_PDI) - msg_error(" -xrtsdtr=low,high Force RTS/DTR lines low or high state during programming\n"); - msg_error( " -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; + } + if (pgm->flag & PGM_FL_IS_JTAG) + msg_error(" -xjtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); + if (pgm->flag & PGM_FL_IS_PDI) + msg_error(" -xrtsdtr=low,high Force RTS/DTR lines low or high state during programming\n"); + msg_error( " -xhelp Show this help menu and exit\n"); + return rv; } return rv; diff --git a/src/linuxspi.c b/src/linuxspi.c index 169c1a22..8cd2d59f 100644 --- a/src/linuxspi.c +++ b/src/linuxspi.c @@ -402,26 +402,30 @@ static int linuxspi_parseexitspecs(PROGRAMMER *pgm, const char *sp) { } static int linuxspi_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rc = 0; + bool help = false; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (str_eq(extended_param, "disable_no_cs")) { my.disable_no_cs = 1; continue; } + if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xdisable_no_cs Do not use the SPI_NO_CS bit for the SPI driver\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT; + help = true; + rc = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); - rc = -1; + if (!help) { + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rc = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xdisable_no_cs Do not use the SPI_NO_CS bit for the SPI driver\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rc; } return rc; diff --git a/src/micronucleus.c b/src/micronucleus.c index c5459772..411c2796 100644 --- a/src/micronucleus.c +++ b/src/micronucleus.c @@ -869,39 +869,48 @@ static int micronucleus_paged_write(const PROGRAMMER *pgm, const AVRPART *p, con } static int micronucleus_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) { + int rv = 0; + bool help = false; pmsg_debug("micronucleus_parseextparams()\n"); struct pdata *pdata = PDATA(pgm); - for (LNODEID node = lfirst(xparams); node != NULL; node = lnext(node)) + for (LNODEID node = lfirst(xparams); node; node = lnext(node)) { - const char* param = ldata(node); + const char* extended_param = ldata(node); - if (str_eq(param, "wait")) + if (str_eq(extended_param, "wait")) { pdata->wait_until_device_present = true; pdata->wait_timout = -1; + continue; } - else if (str_starts(param, "wait=")) + + if (str_starts(extended_param, "wait=")) { pdata->wait_until_device_present = true; - pdata->wait_timout = atoi(param + 5); + pdata->wait_timout = atoi(extended_param + 5); + continue; } - else if (str_eq(param, "help")) + + if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xwait Wait for the device to be plugged in if not connected\n"); - msg_error(" -xwait= Wait [s] for the device to be plugged in if not connected\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT; + help = true; + rv = LIBAVRDUDE_EXIT; } - else + + if (!help) { - pmsg_error("invalid extended parameter '%s'\n", param); - return -1; + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xwait Wait for the device to be plugged in if not connected\n"); + msg_error(" -xwait= Wait [s] for the device to be plugged in if not connected\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } - return 0; + return rv; } void micronucleus_initpgm(PROGRAMMER *pgm) { diff --git a/src/pickit2.c b/src/pickit2.c index f17d5a09..ffd298b3 100644 --- a/src/pickit2.c +++ b/src/pickit2.c @@ -1144,13 +1144,12 @@ static int pickit2_read_report(const PROGRAMMER *pgm, unsigned char report[65]) #endif // WIN32 static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rv = 0; + bool help = true; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + const char *extended_param = ldata(ln); if (str_starts(extended_param, "clockrate=")) { @@ -1167,7 +1166,6 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) pmsg_notice2("pickit2_parseextparms(): clockrate set to 0x%02x\n", clock_rate); PDATA(pgm)->clock_period = clock_period; - continue; } @@ -1183,19 +1181,25 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) pmsg_notice2("pickit2_parseextparms(): usb timeout set to 0x%02x\n", timeout); PDATA(pgm)->transaction_timeout = timeout; - continue; } - if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xclockrate= Set the SPI clocking rate in [Hz]\n"); - msg_error(" -xtimeout= Set the timeout for USB read/write to [ms]\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + + if (str_eq(extended_param, "help")) + { + help = true; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); - rv = -1; + if (!help) + { + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xclockrate= Set the SPI clocking rate in [Hz]\n"); + msg_error(" -xtimeout= Set the timeout for USB read/write to [ms]\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } return rv; diff --git a/src/serialupdi.c b/src/serialupdi.c index 6c46007d..14f2ab4a 100644 --- a/src/serialupdi.c +++ b/src/serialupdi.c @@ -1014,13 +1014,12 @@ static int serialupdi_read_sib(const PROGRAMMER *pgm, const AVRPART *p, char *si } static int serialupdi_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; char rts_mode[5]; int rv = 0; + bool help = false; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (sscanf(extended_param, "rtsdtr=%4s", rts_mode) == 1) { if (str_caseeq(rts_mode, "low")) { @@ -1029,19 +1028,25 @@ static int serialupdi_parseextparms(const PROGRAMMER *pgm, const LISTID extparms updi_set_rts_mode(pgm, RTS_MODE_HIGH); } else { pmsg_error("RTS/DTR mode must be LOW or HIGH\n"); - return -1; + rv = -1; + break; } continue; } + if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xrtsdtr=low,high Force RTS/DTR lines low or high state during programming\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = true; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xrtsdtr=low,high Force RTS/DTR lines low or high state during programming\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } return rv; diff --git a/src/stk500.c b/src/stk500.c index c8f27c40..1758db96 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -641,14 +641,12 @@ static int stk500_initialize(const PROGRAMMER *pgm, const AVRPART *p) { } static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int attempts; int rv = 0; bool help = false; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (sscanf(extended_param, "attempts=%i", &attempts) == 1) { PDATA(pgm)->retry_attempts = attempts; diff --git a/src/stk500v2.c b/src/stk500v2.c index 35054740..159115f8 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -1928,12 +1928,11 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rv = 0; + bool help = false; - for(ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for(LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); // SUFFER bits // Bit 7 ARDUINO: Adds control of extra LEDs when set to 0 @@ -2037,27 +2036,31 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp } if(str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - if(pgm->extra_features & HAS_SUFFER) { - msg_error(" -xsuffer Read SUFFER register value\n"); - msg_error(" -xsuffer= Set SUFFER register value\n"); - } - if(pgm->extra_features & HAS_VTARG_SWITCH) { - msg_error(" -xvtarg_switch Read on-board target voltage switch state\n"); - msg_error(" -xvtarg_switch=<0..1> Set on-board target voltage switch state\n"); - } - if(pgm->extra_features & HAS_VTARG_ADJ) { - msg_error(" -xvtarg Read on-board target supply voltage\n"); - msg_error(" -xvtarg= Set on-board target supply voltage\n"); - } - if(str_starts(pgmid, "pickit4") || str_starts(pgmid, "snap")) - msg_error(" -xmode=avr|pic Set programmer to AVR or PIC mode, then exit\n"); - msg_error (" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = true; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter %s\n", extended_param); - rv = -1; + if(!help) { + pmsg_error("invalid extended parameter %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + if(pgm->extra_features & HAS_SUFFER) { + msg_error(" -xsuffer Read SUFFER register value\n"); + msg_error(" -xsuffer= Set SUFFER register value\n"); + } + if(pgm->extra_features & HAS_VTARG_SWITCH) { + msg_error(" -xvtarg_switch Read on-board target voltage switch state\n"); + msg_error(" -xvtarg_switch=<0..1> Set on-board target voltage switch state\n"); + } + if(pgm->extra_features & HAS_VTARG_ADJ) { + msg_error(" -xvtarg Read on-board target supply voltage\n"); + msg_error(" -xvtarg= Set on-board target supply voltage\n"); + } + if(str_starts(pgmid, "pickit4") || str_starts(pgmid, "snap")) + msg_error(" -xmode=avr|pic Set programmer to AVR or PIC mode, then exit\n"); + msg_error (" -xhelp Show this help menu and exit\n"); + return rv; } return rv; } diff --git a/src/teensy.c b/src/teensy.c index dd5c58d3..77595315 100644 --- a/src/teensy.c +++ b/src/teensy.c @@ -530,39 +530,48 @@ static int teensy_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR } static int teensy_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) { + int rv = 0; + bool help = false; pmsg_debug("teensy_parseextparams()\n"); struct pdata *pdata = PDATA(pgm); - for (LNODEID node = lfirst(xparams); node != NULL; node = lnext(node)) + for (LNODEID node = lfirst(xparams); node; node = lnext(node)) { - const char* param = ldata(node); + const char* extended_param = ldata(node); - if (str_eq(param, "wait")) + if (str_eq(extended_param, "wait")) { pdata->wait_until_device_present = true; pdata->wait_timout = -1; + continue; } - else if (str_starts(param, "wait=")) + + if (str_starts(extended_param, "wait=")) { pdata->wait_until_device_present = true; - pdata->wait_timout = atoi(param + 5); + pdata->wait_timout = atoi(extended_param + 5); + continue; } - else if (str_eq(param, "help")) + + if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xwait Wait for the device to be plugged in if not connected\n"); - msg_error(" -xwait= Wait [s] for the device to be plugged in if not connected\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = true; + rv = LIBAVRDUDE_EXIT; } - else + + if (!help) { - pmsg_error("invalid extended parameter '%s'\n", param); - return -1; + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rv = -1; } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xwait Wait for the device to be plugged in if not connected\n"); + msg_error(" -xwait= Wait [s] for the device to be plugged in if not connected\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rv; } - return 0; + return rv; } void teensy_initpgm(PROGRAMMER *pgm) { diff --git a/src/wiring.c b/src/wiring.c index 2d6aaa3d..47746209 100644 --- a/src/wiring.c +++ b/src/wiring.c @@ -81,13 +81,12 @@ static void wiring_teardown(PROGRAMMER *pgm) { } static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param, *errstr; + const char *errstr; int rv = 0; bool help = 0; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (str_starts(extended_param, "snooze=")) { int val = str_int(extended_param+7, STR_INT32, &errstr); @@ -103,7 +102,8 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { int val = str_int(extended_param+6, STR_INT32, &errstr); if(errstr) { pmsg_error("-x%s: %s\n", extended_param, errstr); - return -1; + rv = -1; + break; } pmsg_notice2("%s(): delay set to %d ms\n", __func__, val); WIRINGPDATA(pgm)->delay = val; diff --git a/src/xbee.c b/src/xbee.c index 378cfc9d..31e2b702 100644 --- a/src/xbee.c +++ b/src/xbee.c @@ -1622,12 +1622,11 @@ static void xbee_close(PROGRAMMER *pgm) } static int xbee_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rc = 0; + bool help = false; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (str_starts(extended_param, "xbeeresetpin=")) { int resetpin; @@ -1641,15 +1640,20 @@ static int xbee_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { PDATA(pgm)->xbeeResetPin = resetpin; continue; } + if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xxbeeresetpin=<1..7> Set XBee pin DIO<1..7> as reset pin\n"); - msg_error(" -xhelp Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = true; + rc = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); - rc = -1; + if (!help) { + pmsg_error("invalid extended parameter '%s'\n", extended_param); + rc = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -xxbeeresetpin=<1..7> Set XBee pin DIO<1..7> as reset pin\n"); + msg_error(" -xhelp Show this help menu and exit\n"); + return rc; } return rc; From f37e5930dfea558d889493ee8d26f1c46bf83113 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 29 Jul 2024 16:14:53 +0100 Subject: [PATCH 379/422] Clarify invalid value messages for valid -x parameters ... ... and generally massage messaging around -x parameters --- src/arduino.c | 8 ++--- src/avr910.c | 12 ++++---- src/avrdude.1 | 40 ++++++++++++------------ src/avrftdi.c | 2 +- src/buspirate.c | 36 +++++++++++----------- src/butterfly.c | 6 ++-- src/doc/avrdude.texi | 8 ++--- src/dryrun.c | 14 ++++----- src/ft245r.c | 4 +-- src/jtag3.c | 47 ++++++++++++++-------------- src/jtagmkII.c | 12 ++++---- src/linuxspi.c | 6 ++-- src/main.c | 8 ++--- src/micronucleus.c | 8 ++--- src/pickit2.c | 20 ++++++------ src/serialupdi.c | 8 ++--- src/serprog.c | 9 +++--- src/stk500.c | 40 ++++++++++++------------ src/stk500v2.c | 73 ++++++++++++++++++++++---------------------- src/teensy.c | 10 +++--- src/urclock.c | 62 +++++++++++++++++++------------------ src/usbasp.c | 6 ++-- src/usbtiny.c | 2 +- src/wiring.c | 28 +++++++++-------- src/xbee.c | 10 +++--- 25 files changed, 244 insertions(+), 235 deletions(-) diff --git a/src/arduino.c b/src/arduino.c index 7d83275a..695248c1 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -62,13 +62,13 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if (!help) { - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xattempts= Specify the number of connection retry attempts\n"); - msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x attempts= Specify the number of connection retry attempts\n"); + msg_error(" -x noautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } return rv; diff --git a/src/avr910.c b/src/avr910.c index cc498dee..ee166c72 100644 --- a/src/avr910.c +++ b/src/avr910.c @@ -318,9 +318,9 @@ static int avr910_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { int devcode; if (sscanf(extended_param, "devcode=%i", &devcode) != 1 || devcode <= 0 || devcode > 255) { - pmsg_error("invalid devcode '%s'\n", extended_param); + pmsg_error("invalid device code in -x %s\n", extended_param); rv = -1; - continue; + break; } pmsg_notice2("avr910_parseextparms(): devcode overwritten as 0x%02x\n", devcode); PDATA(pgm)->devcode = devcode; @@ -339,13 +339,13 @@ static int avr910_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if (!help) { - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xdevcode= Override device code\n"); - msg_error(" -xno_blockmode Disable default checking for block transfer capability\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x devcode= Set device code to (0x.. hex, 0... oct or dec)\n"); + msg_error(" -x no_blockmode Disable default checking for block transfer capability\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } diff --git a/src/avrdude.1 b/src/avrdude.1 index 2f43e8af..72a61e28 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -1652,14 +1652,14 @@ Other JTAG units might require a different bit shift count. .sp 0.5 High-voltage UPDI programming is used to enable a UPDI pin that has previously been set to RESET or GPIO mode. Use -.Ar -xhvupdi +.Ar -x hvupdi to enable high-voltage UPDI initialization for targets that supports this. .It Ar vtarg=VALUE, vtarg .Nm Power Debugger only .sp 0.5 The voltage generator can be enabled by setting a target voltage. The current set-voltage can be read by -.Ar -xvtarg +.Ar -x vtarg alone. .It Ar help Show help menu and exit. @@ -1672,9 +1672,9 @@ Switch programmer to AVR or PIC mode, then exit: the PICkit 4 and MPLAB SNAP programmer can only be utilised by .Nm when in AVR mode. Use -.Ar -xmode=avr +.Ar -x mode=avr for switching to AVR mode, or -.Ar -xmode=pic +.Ar -x mode=pic for switching to PIC mode. .It Ar help Show help menu and exit. @@ -1684,7 +1684,7 @@ Show help menu and exit. .It Ar suffer=VALUE, suffer The SUFFER register allows the user to modify the behavior of the on-board mEDBG. The current state can be read by -.Ar -xsuffer +.Ar -x suffer alone. .Bl -tag -offset indent -width indent .It Bit 7 ARDUINO: @@ -1704,7 +1704,7 @@ Fuses are safe-masked when bit sent to 1. Fuses are unprotected when set to 0 .It Ar vtarg_switch=VALUE, vtarg_switch The on-board target voltage switch can be turned on or off by writing a 1 or a 0. The current state can be read by -.Ar -xvtarg_switch +.Ar -x vtarg_switch alone. Note that the target power switch will always be on after a power cycle. Also note that the smaller Xplained Nano boards does not have a target power switch. @@ -1716,7 +1716,7 @@ Show help menu and exit. .It Ar vtarg=VALUE, vtarg The generated on-board target voltage can be changed by specifying a new voltage. The current set-voltage can be read by -.Ar -xvtarg +.Ar -x vtarg alone. .It Ar help Show help menu and exit. @@ -1727,16 +1727,16 @@ Show help menu and exit. .It Ar vtarg=VALUE, vtarg The generated on-board target voltage can be changed by specifying a new voltage. The current set-voltage can be read by -.Ar -xvtarg +.Ar -x vtarg alone. .It Ar fosc=VALUE[MHz|M|kHz|k|Hz|H], fosc Set the programmable oscillator frequency. The current frequency can be read by -.Ar -xfosc +.Ar -x fosc alone. .It Ar varef=VALUE, varef The generated on-board analog reference voltage can be changed by specifying a new reference voltage. The current reference voltage can be read by -.Ar -xvaref +.Ar -x varef alone. .It Ar varef[0,1]=VALUE, varef[0,1] .Nm STK600 only @@ -1744,9 +1744,9 @@ alone. The generated on-board analog reference voltage for channel 0 or channel 1 can be changed by specifying a new reference voltage. The current reference voltage can be read by -.Ar -xvaref0 +.Ar -x varef0 or -.Ar -xvaref1 +.Ar -x varef1 alone. .It Ar attemps[=<1..99>] .Nm STK500V1 only @@ -1797,7 +1797,7 @@ Show help menu and exit. .It Ar Urclock .Bl -tag -offset indent -width indent .It Ar showall -Show all info for the connected part, then exit. The -xshow... options +Show all info for the connected part, then exit. The -x show... options below can be used to assemble a bespoke response consisting of a subset (or only one item) of all available relevant information about the connected part and bootloader. @@ -1806,7 +1806,7 @@ Show a unique Urclock ID stored in either flash or EEPROM of the MCU, then exit. .It Ar id=.. Historically, the Urclock ID was a six-byte unique little-endian number stored in Urclock boards at EEPROM address 257. The location of this -number can be set by the -xid=.. extended parameter. E +number can be set by the -x id=.. extended parameter. E stands for EEPROM and F stands for flash. A negative address addr counts from the end of EEPROM and flash, respectively. The length len of the Urclock ID can be between 1 and 8 bytes. @@ -1847,7 +1847,7 @@ i.e., typically top of flash, so the urclock programmer can look up the bootloader size itself. In backward-compatibility mode, when programming via other bootloaders, this option can be used to tell the programmer the size, and therefore the location, of the bootloader. -.It Ar vectornum= +.It Ar vectornum= Manual override for vector number. Urboot bootloaders put the vector number used by a vector bootloader into a table at the top of flash, so this option is normally not needed for urboot bootloaders. However, it is @@ -1872,7 +1872,7 @@ Upload unchanged flash input files and trim below the bootloader if needed. This is most useful when one has a backup of the full flash and wants to play that back onto the device. No metadata are written in this case and no vector patching happens either if it is a vector bootloader. -However, for vector bootloaders, even under the option -xrestore an +However, for vector bootloaders, even under the option -x restore an input file will not be uploaded for which the reset vector does not point to the vector bootloader. This is to avoid writing an input file to the device that would render the vector bootloader not functional as it would @@ -1897,12 +1897,12 @@ indicate there are no further metadata available. In absence of -xnometadata, the default for the urclock programmer is to write as much metadata (filename, data and store information) as the size of the uploaded application and the other extended options allow. The subtle -difference between -xnometadata and -xnostore is that the latter always +difference between -x nometadata and -x nostore is that the latter always explicitly stores in flash that no further metadata are available, so that a such prepared flash can always be queried with .Nm --xshowall. In contrast to this, it cannot be guaranteed that a -xshowall -query on flash prepared with -xnometadata yields useful results. +-xshowall. In contrast to this, it cannot be guaranteed that a -x showall +query on flash prepared with -x nometadata yields useful results. .It Ar delay= Add a ms delay after reset. This can be useful if a board takes a particularly long time to exit from external reset. can be negative, @@ -1911,7 +1911,7 @@ shortened accordingly. .It Ar strict Urclock has a faster, but slightly different strategy than -c arduino to synchronise with the bootloader; some stk500v1 bootloaders cannot cope -with this, and they need the -xstrict option. +with this, and they need the -x strict option. .It Ar help Show help menu and exit. .El diff --git a/src/avrftdi.c b/src/avrftdi.c index 1a00bf12..76683509 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -689,7 +689,7 @@ static int avrftdi_open(PROGRAMMER *pgm, const char *port) { else if (pgm->usbdev[0] == 'b' || pgm->usbdev[0] == 'B') interface = INTERFACE_B; else { - pmsg_warning("invalid interface '%s'. Setting to Interface A\n", pgm->usbdev); + pmsg_warning("invalid interface %s; setting to Interface A\n", pgm->usbdev); interface = INTERFACE_A; } diff --git a/src/buspirate.c b/src/buspirate.c index c6028f37..55482f76 100644 --- a/src/buspirate.c +++ b/src/buspirate.c @@ -372,9 +372,9 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) else if (str_caseeq(resetpin, "aux2")) PDATA(pgm)->reset |= BP_RESET_AUX2; else { - pmsg_error("reset must be either CS or AUX\n"); + pmsg_error("-xreset= value must be either CS, AUX or AUX2\n"); rv = -1; - break; + break; } } PDATA(pgm)->flag |= BP_FLAG_XPARM_RESET; @@ -407,21 +407,21 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } if (!help) { - pmsg_error("invalid extended parameter %s\n", extended_param); - rv = -1; + pmsg_error("invalid extended parameter -x %s\n", extended_param); + rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xreset=cs,aux,aux2 Override default reset pin\n"); - msg_error(" -xspifreq=<0..7> Set binary SPI mode speed\n"); - msg_error(" -xrawfreq=<0..3> Set \"raw-wire\" SPI mode speed\n"); - msg_error(" -xascii Use ASCII protocol between BP and Avrdude\n"); - msg_error(" -xnopagedwrite Disable page write functionality\n"); - msg_error(" -xnopagedread Disable page read functionality\n"); - msg_error(" -xcpufreq=<125..4000> Set the AUX pin to output a frequency to n [kHz]\n"); - msg_error(" -xserial_recv_timeout= Set serial receive timeout to [ms]\n"); - msg_error(" -xpullups Enable internal pull-ups\n"); - msg_error(" -xhiz SPI HiZ mode (open collector)\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x reset=[cs|aux|aux2] Override default reset pin\n"); + msg_error(" -x spifreq=<0..7> Set binary SPI mode speed\n"); + msg_error(" -x rawfreq=<0..3> Set \"raw-wire\" SPI mode speed\n"); + msg_error(" -x ascii Use ASCII protocol between BP and Avrdude\n"); + msg_error(" -x nopagedwrite Disable page write functionality\n"); + msg_error(" -x nopagedread Disable page read functionality\n"); + msg_error(" -x cpufreq=<125..4000> Set the AUX pin to output a frequency to kHz\n"); + msg_error(" -x serial_recv_timeout= Set serial receive timeout to ms\n"); + msg_error(" -x pullups Enable internal pull-ups\n"); + msg_error(" -x hiz SPI HiZ mode (open collector)\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } @@ -560,7 +560,7 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm) memset(buf, 0, sizeof(buf)); buspirate_recv_bin(pgm, buf, 5); if (sscanf((const char*)buf, "BBIO%1d", &PDATA(pgm)->binmode_version) != 1) { - pmsg_error("binary mode not confirmed: '%s'\n", buf); + pmsg_error("binary mode not confirmed: %s\n", buf); buspirate_reset_from_binmode(pgm); return -1; } @@ -598,7 +598,7 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm) memset(buf, 0, sizeof(buf)); buspirate_recv_bin(pgm, buf, 4); if (sscanf((const char*)buf, submode.entered_format, &PDATA(pgm)->submode_version) != 1) { - pmsg_error("%s mode not confirmed: '%s'\n", submode.name, buf); + pmsg_error("%s mode not confirmed: %s\n", submode.name, buf); buspirate_reset_from_binmode(pgm); return -1; } @@ -1193,7 +1193,7 @@ static void buspirate_bb_enable(PROGRAMMER *pgm, const AVRPART *p) { memset(buf, 0, sizeof(buf)); buspirate_recv_bin(pgm, buf, 5); if (sscanf((char*)buf, "BBIO%1d", &PDATA(pgm)->binmode_version) != 1) { - pmsg_error("binary mode not confirmed: '%s'\n", buf); + pmsg_error("binary mode not confirmed: %s\n", buf); buspirate_reset_from_binmode(pgm); return; } diff --git a/src/butterfly.c b/src/butterfly.c index 6d7bc95e..97c0627e 100644 --- a/src/butterfly.c +++ b/src/butterfly.c @@ -713,12 +713,12 @@ static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } if (!help) { - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xautoreset Toggle RTS/DTR lines on port open to issue a hardware reset\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x autoreset Toggle RTS/DTR lines on port open to issue a hardware reset\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 3613631e..3b12762a 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -1424,7 +1424,7 @@ i.e., typically top of flash, so the urclock programmer can look up the bootloader size itself. In backward-compatibility mode, when programming via other bootloaders, this option can be used to tell the programmer the size, and therefore the location, of the bootloader. -@item @samp{vectornum=} +@item @samp{vectornum=} Manual override for vector number. Urboot bootloaders put the vector number used by a vector bootloader into a table at the top of flash, so this option is normally not needed for urboot bootloaders. However, it is @@ -1477,8 +1477,8 @@ size of the uploaded application and the other extended options allow. The subtle difference between @code{-xnometadata} and @code{-xnostore} is that the latter always explicitly stores in flash that no further metadata are available, so that a such prepared flash can always be queried with -@code{avrdude -xshowall}. In contrast to this, it cannot be guaranteed -that a @code{-xshowall} query on flash prepared with @code{-xnometadata} +@code{avrdude -x showall}. In contrast to this, it cannot be guaranteed +that a @code{-x showall} query on flash prepared with @code{-xnometadata} yields useful results. @item @samp{delay=} Add a ms delay after reset. This can be useful if a board takes a @@ -2165,7 +2165,7 @@ Valid programmers for part AVR32EA32 are: @smallexample @cartouche -$avrdude -qq -curclock -P/dev/ttyUSB0 -pattiny13 -xshowdate -xshowfilename +$avrdude -qq -curclock -P/dev/ttyUSB0 -pattiny13 -x showdate -x showfilename 2023-05-19 11.13 blink.hex diff --git a/src/dryrun.c b/src/dryrun.c index b33bd0dc..401c1881 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -1067,18 +1067,18 @@ static int dryrun_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { } if(!help) { - pmsg_error("invalid extended parameter '%s'\n", xpara); + pmsg_error("invalid extended parameter -x %s\n", xpara); rc = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xinit Initialise memories with human-readable patterns (1, 2, 3)\n"); - msg_error(" -xrandom Initialise memories with random code/values (1, 3)\n"); - msg_error(" -xseed= Seed random number generator with , default time(NULL)\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x init Initialise memories with human-readable patterns (1, 2, 3)\n"); + msg_error(" -x random Initialise memories with random code/values (1, 3)\n"); + msg_error(" -x seed= Seed random number generator with , n>0, default time(NULL)\n"); + msg_error(" -x help Show this help menu and exit\n"); msg_error("Notes:\n"); - msg_error(" (1) -xinit and -xrandom randomly configure flash wrt boot/data/code length\n"); + msg_error(" (1) -x init and -x random randomly configure flash wrt boot/data/code length\n"); msg_error(" (2) Patterns can best be seen with fixed-width font on -U flash:r:-:I\n"); - msg_error(" (3) Choose, eg, -xseed=1 for reproducible flash configuration and output\n"); + msg_error(" (3) Choose, eg, -x seed=1 for reproducible flash configuration and output\n"); return rc; } diff --git a/src/ft245r.c b/src/ft245r.c index 7cb93fe7..4d927731 100644 --- a/src/ft245r.c +++ b/src/ft245r.c @@ -378,7 +378,7 @@ static int ft245r_set_bitclock(const PROGRAMMER *pgm) { r = ftdi_set_baudrate(my.handle, ftdi_rate); if (r) { - msg_error("set baudrate %d failed with error '%s'\n", rate, ftdi_get_error_string (my.handle)); + msg_error("setting baudrate %d failed with error %s\n", rate, ftdi_get_error_string (my.handle)); return -1; } return 0; @@ -854,7 +854,7 @@ static int ft245r_open(PROGRAMMER *pgm, const char *port) { // if something went wrong before abort with helpful message if (devnum < 0) { - pmsg_error("invalid portname '%s': use^ 'ft[0-9]+' or serial number\n", port); + pmsg_error("invalid port name %s: use ft[0-9]+ or serial number\n", port); return -1; } diff --git a/src/jtag3.c b/src/jtag3.c index 2b9574a7..deb9a6e2 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -1465,7 +1465,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { if(str_starts(extended_param, "jtagchain=") && (pgm->prog_modes & (PM_JTAG | PM_XMEGAJTAG | PM_AVR32JTAG))) { unsigned int ub, ua, bb, ba; if(sscanf(extended_param, "jtagchain=%u,%u,%u,%u", &ub, &ua, &bb, &ba) != 4) { - pmsg_error("invalid JTAG chain %s\n", extended_param); + pmsg_error("invalid JTAG chain in -x %s\n", extended_param); rv = -1; break; } @@ -1491,7 +1491,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { break; } if(!str_eq(extended_param, "hvupdi")) { - pmsg_error("invalid -xhvupdi value %s. Use -xhvupdi\n", extended_param); + pmsg_error("invalid assignment in -x %s; use -x hvupdi\n", extended_param); rv = -1; break; } @@ -1510,13 +1510,13 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { // Set SUFFER value if(str_starts(extended_param, "suffer=")) { if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) { - pmsg_error("invalid -xsuffer= %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } if((PDATA(pgm)->suffer_data[1] & 0x78) != 0x78) { PDATA(pgm)->suffer_data[1] |= 0x78; - pmsg_info("setting -xsuffer=0x%02x so that reserved bits 3..6 are set\n", + pmsg_info("setting -x suffer=0x%02x so that reserved bits 3..6 are set\n", PDATA(pgm)->suffer_data[1]); } PDATA(pgm)->suffer_set = true; @@ -1527,7 +1527,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { PDATA(pgm)->suffer_get = true; continue; } - pmsg_error("invalid suffer setting %s. Use -xsuffer or -xsuffer=\n", extended_param); + pmsg_error("invalid setting in -x %s; use -x suffer or -x suffer=\n", extended_param); rv = -1; break; } @@ -1539,7 +1539,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { if(str_starts(extended_param, "vtarg_switch=")) { int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1); if(sscanf_success < 1 || PDATA(pgm)->vtarg_switch_data[1] > 1) { - pmsg_error("invalid vtarg_switch value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } @@ -1551,7 +1551,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { PDATA(pgm)->vtarg_switch_get = true; continue; } - pmsg_error("invalid vtarg_switch setting %s. Use -xvtarg_switch or -xvtarg_switch=<0..1>\n", extended_param); + pmsg_error("invalid setting in -x %s; use -x vtarg_switch or -x vtarg_switch=<0..1>\n", extended_param); rv = -1; break; } @@ -1565,7 +1565,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { int sscanf_success = sscanf(extended_param, "vtarg=%lf", &vtarg_set_val); PDATA(pgm)->vtarg_data = (double)((int)(vtarg_set_val * 100 + .5)) / 100; if(sscanf_success < 1 || vtarg_set_val < 0) { - pmsg_error("invalid vtarg value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } @@ -1577,7 +1577,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { PDATA(pgm)->vtarg_get = true; continue; } - pmsg_error("invalid vtarg setting %s. Use -xvtarg or -xvtarg=\n", extended_param); + pmsg_error("invalid setting in -x %s; use -x vtarg or -x vtarg=\n", extended_param); rv = -1; break; } @@ -1595,7 +1595,7 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { PDATA(pgm)->pk4_snap_mode = PK4_SNAP_MODE_PIC; continue; } - pmsg_error("invalid mode setting %s. Use -xmode=avr or -xmode=pic\n", extended_param); + pmsg_error("invalid setting in -x %s; use -x mode=avr or -x mode=pic\n", extended_param); rv = -1; break; } @@ -1606,29 +1606,30 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if (!help) { - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); if(str_eq(pgm->type, "JTAGICE3")) - msg_error(" -xjtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); + msg_error(" -x jtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); + msg_error(" UB/UA = units before/after, BB/BA = bits before/after\n"); if(lsize(pgm->hvupdi_support) > 1) - msg_error(" -xhvupdi Enable high-voltage UPDI initialization\n"); + msg_error(" -x hvupdi Enable high-voltage UPDI initialization\n"); if(pgm->extra_features & HAS_SUFFER) { - msg_error(" -xsuffer Read SUFFER register value\n"); - msg_error(" -xsuffer= Set SUFFER register value\n"); + msg_error(" -x suffer Read SUFFER register value\n"); + msg_error(" -x suffer= Set SUFFER register to (0x.. hex, 0.. oct or dec)\n"); } if(pgm->extra_features & HAS_VTARG_SWITCH) { - msg_error(" -xvtarg_switch Read on-board target voltage switch state\n"); - msg_error(" -xvtarg_switch=<0..1> Set on-board target voltage switch state\n"); + msg_error(" -x vtarg_switch Read on-board target voltage switch state\n"); + msg_error(" -x vtarg_switch=<0..1> Set on-board target voltage switch state\n"); } if(pgm->extra_features & HAS_VTARG_ADJ) { - msg_error(" -xvtarg Read on-board target supply voltage\n"); - msg_error(" -xvtarg= Set on-board target supply voltage\n"); + msg_error(" -x vtarg Read on-board target supply voltage\n"); + msg_error(" -x vtarg= Set on-board target supply voltage to V\n"); } if(str_starts(pgmid, "pickit4") || str_starts(pgmid, "snap")) - msg_error(" -xmode=avr|pic Set programmer to AVR or PIC mode, then exit\n"); - msg_error (" -xhelp Show this help menu and exit\n"); + msg_error(" -x mode=avr|pic Set programmer to AVR or PIC mode, then exit\n"); + msg_error (" -x help Show this help menu and exit\n"); return rv; } @@ -1725,7 +1726,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port, int mode_switch) { imsg_error("please run Avrdude again to continue the session\n\n"); } else { imsg_error("to switch into AVR mode try\n"); - imsg_error("avrdude -c%s -p%s -P%s -xmode=avr\n", pgmid, partdesc, port); + imsg_error("avrdude -c%s -p%s -P%s -x mode=avr\n", pgmid, partdesc, port); } serial_close(&pgm->fd); return LIBAVRDUDE_EXIT;; @@ -1751,7 +1752,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port, int mode_switch) { } if (mode_switch == PK4_SNAP_MODE_AVR) - pmsg_warning("programmer is already in AVR mode. Ignoring -xmode"); + pmsg_warning("programmer is already in AVR mode, ignoring -x mode"); // The event EP has been deleted by usb_open(), so we are // running on a CMSIS-DAP device, using EDBG protocol diff --git a/src/jtagmkII.c b/src/jtagmkII.c index 2dacfad1..19f0fae2 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -1341,10 +1341,10 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) const char *extended_param = ldata(ln); if (pgm->flag & PGM_FL_IS_JTAG) { - if (str_eq(extended_param, "jtagchain=")) { + if (str_starts(extended_param, "jtagchain=")) { unsigned int ub, ua, bb, ba; if (sscanf(extended_param, "jtagchain=%u,%u,%u,%u", &ub, &ua, &bb, &ba) != 4) { - pmsg_error("invalid JTAG chain '%s'\n", extended_param); + pmsg_error("invalid JTAG chain in -x %s\n", extended_param); rv = -1; continue; } @@ -1381,14 +1381,14 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } if (!help) { - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } if (pgm->flag & PGM_FL_IS_JTAG) - msg_error(" -xjtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); + msg_error(" -x jtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); if (pgm->flag & PGM_FL_IS_PDI) - msg_error(" -xrtsdtr=low,high Force RTS/DTR lines low or high state during programming\n"); - msg_error( " -xhelp Show this help menu and exit\n"); + msg_error(" -x rtsdtr=low,high Force RTS/DTR lines low or high state during programming\n"); + msg_error( " -x help Show this help menu and exit\n"); return rv; } diff --git a/src/linuxspi.c b/src/linuxspi.c index 8cd2d59f..8ca1f9fa 100644 --- a/src/linuxspi.c +++ b/src/linuxspi.c @@ -419,12 +419,12 @@ static int linuxspi_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) } if (!help) { - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rc = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xdisable_no_cs Do not use the SPI_NO_CS bit for the SPI driver\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x disable_no_cs Do not use the SPI_NO_CS bit for the SPI driver\n"); + msg_error(" -x help Show this help menu and exit\n"); return rc; } diff --git a/src/main.c b/src/main.c index 4555d342..1f9b3d6e 100644 --- a/src/main.c +++ b/src/main.c @@ -252,7 +252,7 @@ static void usage(void) " -n Do not write to the device whilst processing -U\n" " -V Do not automatically verify during -U\n" " -E [,] List programmer exit specifications\n" - " -x Pass to programmer, see -xhelp\n" + " -x Pass to programmer, see -x help\n" " -v Verbose output; -v -v for more\n" " -q Quell progress output; -q -q for less\n" " -l logfile Use logfile rather than stderr for diagnostics\n" @@ -900,7 +900,7 @@ int main(int argc, char * argv []) case 'U': upd = parse_op(optarg); if (upd == NULL) { - pmsg_error("unable to parse update operation '%s'\n", optarg); + pmsg_error("unable to parse update operation %s\n", optarg); exit(1); } ladd(updates, upd); @@ -1248,7 +1248,7 @@ int main(int argc, char * argv []) const char *extended_param = ldata(ln); if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x help Show this help menu and exit\n"); exit(0); } else @@ -1259,7 +1259,7 @@ int main(int argc, char * argv []) if(rc == LIBAVRDUDE_EXIT) exit(0); if(rc < 0) { - pmsg_error("unable to parse extended parameter list\n"); + pmsg_error("unable to parse list of -x parameters\n"); exit(1); } } diff --git a/src/micronucleus.c b/src/micronucleus.c index 411c2796..f8f2deec 100644 --- a/src/micronucleus.c +++ b/src/micronucleus.c @@ -900,13 +900,13 @@ static int micronucleus_parseextparams(const PROGRAMMER *pgm, const LISTID xpara if (!help) { - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xwait Wait for the device to be plugged in if not connected\n"); - msg_error(" -xwait= Wait [s] for the device to be plugged in if not connected\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x wait Wait for the device to be plugged in if not connected\n"); + msg_error(" -x wait= Wait s for the device to be plugged in if not connected\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } diff --git a/src/pickit2.c b/src/pickit2.c index ffd298b3..5a13c2ad 100644 --- a/src/pickit2.c +++ b/src/pickit2.c @@ -1156,15 +1156,15 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) int clock_rate; if (sscanf(extended_param, "clockrate=%i", &clock_rate) != 1 || clock_rate <= 0) { - pmsg_error("invalid clockrate '%s'\n", extended_param); + pmsg_error("invalid clock rate in -x %s\n", extended_param); rv = -1; - continue; + break; } int clock_period = MIN(1000000 / clock_rate, 255); // max period is 255 clock_rate = (int)(1000000 / (clock_period + 5e-7)); // assume highest speed is 2MHz - should probably check this - pmsg_notice2("pickit2_parseextparms(): clockrate set to 0x%02x\n", clock_rate); + pmsg_notice2("%s(): effective clock rate set to 0x%02x\n", __func__, clock_rate); PDATA(pgm)->clock_period = clock_period; continue; } @@ -1174,12 +1174,12 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) int timeout; if (sscanf(extended_param, "timeout=%i", &timeout) != 1 || timeout <= 0) { - pmsg_error("invalid timeout '%s'\n", extended_param); + pmsg_error("invalid timeout in -x %s\n", extended_param); rv = -1; - continue; + break; } - pmsg_notice2("pickit2_parseextparms(): usb timeout set to 0x%02x\n", timeout); + pmsg_notice2("%s(): usb timeout set to 0x%02x\n", __func__, timeout); PDATA(pgm)->transaction_timeout = timeout; continue; } @@ -1192,13 +1192,13 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) if (!help) { - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xclockrate= Set the SPI clocking rate in [Hz]\n"); - msg_error(" -xtimeout= Set the timeout for USB read/write to [ms]\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x clockrate= Set the SPI clock rate to Hz\n"); + msg_error(" -x timeout= Set the timeout for USB read/write to ms\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } diff --git a/src/serialupdi.c b/src/serialupdi.c index 14f2ab4a..1d1eb22a 100644 --- a/src/serialupdi.c +++ b/src/serialupdi.c @@ -1027,7 +1027,7 @@ static int serialupdi_parseextparms(const PROGRAMMER *pgm, const LISTID extparms } else if (str_caseeq(rts_mode, "high")) { updi_set_rts_mode(pgm, RTS_MODE_HIGH); } else { - pmsg_error("RTS/DTR mode must be LOW or HIGH\n"); + pmsg_error("-xrtsdtr=: RTS/DTR mode must be LOW or HIGH\n"); rv = -1; break; } @@ -1040,12 +1040,12 @@ static int serialupdi_parseextparms(const PROGRAMMER *pgm, const LISTID extparms } if (!help) { - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xrtsdtr=low,high Force RTS/DTR lines low or high state during programming\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x rtsdtr=[low|high] Set RTS/DTR lines low/high during programming\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } diff --git a/src/serprog.c b/src/serprog.c index 739790b2..73965b9f 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -473,8 +473,9 @@ static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) unsigned int cs; if(sscanf(extended_param, "cs=%u", &cs) != 1) { - pmsg_error("invalid chip select '%s'\n", extended_param); + pmsg_error("invalid chip select in -x %s\n", extended_param); rv = -1; + break; } my.cs = cs; continue; @@ -482,12 +483,12 @@ static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) if(str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xcs=cs_num Sets the chip select (CS) to use on supported programmers\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x cs= Sets the chip select line to CS for supported programmers\n"); + msg_error(" -x help Show this help menu and exit\n"); return LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } diff --git a/src/stk500.c b/src/stk500.c index 1758db96..7f9e13b6 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -654,14 +654,14 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { continue; } - else if (str_starts(extended_param, "vtarg")) { + if (str_starts(extended_param, "vtarg")) { if ((pgm->extra_features & HAS_VTARG_ADJ) && (str_starts(extended_param, "vtarg="))) { // Set target voltage double vtarg_set_val = -1; // default = invlid value int sscanf_success = sscanf(extended_param, "vtarg=%lf", &vtarg_set_val); PDATA(pgm)->vtarg_data = (double)((int)(vtarg_set_val * 100 + .5)) / 100; if (sscanf_success < 1 || vtarg_set_val < 0) { - pmsg_error("invalid vtarg value %s\n", extended_param); + pmsg_error("invalid target voltage in -x %s\n", extended_param); rv = -1; break; } @@ -697,7 +697,7 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { if (PDATA(pgm)->varef_set) { PDATA(pgm)->varef_data = (double)((int)(varef_set_val * 100 + .5)) / 100; if (sscanf_success < 1 || varef_set_val < 0) { - pmsg_error("invalid varef value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); PDATA(pgm)->varef_set = false; rv = -1; break; @@ -715,7 +715,7 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { // allow spaces in fosc_str int sscanf_success = sscanf(extended_param, "fosc=%15[0-9.eE MmKkHhZzof]", fosc_str); if (sscanf_success < 1) { - pmsg_error("invalid fosc value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } @@ -724,13 +724,12 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { if (endp == fosc_str){ // no number while ( *endp == ' ' ) // remove leading spaces ++endp; - if (str_starts(endp, "off")) - PDATA(pgm)->fosc_data = 0.0; - else { - pmsg_error("invalid fosc value %s\n", fosc_str); + if (!str_eq(endp, "off")) { + pmsg_error("invalid -x fosc=%s value\n", fosc_str); rv = -1; break; } + PDATA(pgm)->fosc_data = 0.0; } while ( *endp == ' ' ) // remove leading spaces before unit ++endp; @@ -757,14 +756,14 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { char xtal_str[16] = {0}; int sscanf_success = sscanf(extended_param, "xtal=%15[0-9.eE MmKkHhZz]", xtal_str); if (sscanf_success < 1) { - pmsg_error("invalid xtal value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } char *endp; double v = strtod(xtal_str, &endp); if (endp == xtal_str){ - pmsg_error("invalid xtal value %s\n", xtal_str); + pmsg_error("invalid -x xtal=%s value\n", xtal_str); rv = -1; break; } @@ -786,27 +785,28 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if (!help) { - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xattempts= Specify the number of connection retry attempts\n"); + msg_error(" -x attempts= Specify the number of connection retry attempts\n"); if (pgm->extra_features & HAS_VTARG_READ) { - msg_error(" -xvtarg Read target supply voltage\n"); + msg_error(" -x vtarg Read target supply voltage\n"); } if (pgm->extra_features & HAS_VTARG_ADJ) { - msg_error(" -xvtarg= Set target supply voltage\n"); + msg_error(" -x vtarg= Set target supply voltage to V\n"); } if (pgm->extra_features & HAS_VAREF_ADJ) { - msg_error(" -xvaref Read analog reference voltage\n"); - msg_error(" -xvaref= Set analog reference voltage\n"); + msg_error(" -x varef Read analog reference voltage\n"); + msg_error(" -x varef= Set analog reference voltage to V\n"); } if (pgm->extra_features & HAS_FOSC_ADJ) { - msg_error(" -xfosc Read oscillator clock frequency\n"); - msg_error(" -xfosc=[M|k]|off Set oscillator clock frequency\n"); + msg_error(" -x fosc Read oscillator clock frequency\n"); + msg_error(" -x fosc=[unit] Set oscillator clock frequency to Hz (or kHz/MHz)\n"); + msg_error(" -x fosc=off Switch the oscillator clock off\n"); } - msg_error(" -xxtal=[M|k] Set programmer xtal frequency\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x xtal=[unit] Set programmer xtal frequency to Hz (or kHz/MHz)\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } diff --git a/src/stk500v2.c b/src/stk500v2.c index 159115f8..6d5decbb 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -1757,7 +1757,7 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) int sscanf_success = sscanf(extended_param, "vtarg=%lf", &vtarg_set_val); PDATA(pgm)->vtarg_data = (double)((int)(vtarg_set_val * 100 + .5)) / 100; if (sscanf_success < 1 || vtarg_set_val < 0) { - pmsg_error("invalid vtarg value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } @@ -1810,7 +1810,7 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) if (PDATA(pgm)->varef_set) { PDATA(pgm)->varef_data = (double)((int)(varef_set_val * 100 + .5)) / 100; if (sscanf_success < 1 || varef_set_val < 0) { - pmsg_error("invalid varef value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); PDATA(pgm)->varef_set = false; rv = -1; break; @@ -1827,7 +1827,7 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) char fosc_str[16] = {0}; int sscanf_success = sscanf(extended_param, "fosc=%15[0-9.eE MmKkHhZzof]", fosc_str); if (sscanf_success < 1) { - pmsg_error("invalid fosc value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } @@ -1869,7 +1869,7 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) char xtal_str[16] = {0}; int sscanf_success = sscanf(extended_param, "xtal=%15[0-9.eE MmKkHhZz]", xtal_str); if (sscanf_success < 1) { - pmsg_error("invalid xtal value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } @@ -1895,33 +1895,34 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) else if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); if (pgm->extra_features & HAS_VTARG_ADJ) { - msg_error(" -xvtarg Read target supply voltage\n"); - msg_error(" -xvtarg= Set target supply voltage\n"); + msg_error(" -x vtarg Read target supply voltage\n"); + msg_error(" -x vtarg= Set target supply voltage to V\n"); } if (pgm->extra_features & HAS_VAREF_ADJ) { if (str_contains(pgm->type, "STK500")) { - msg_error(" -xvaref Read analog reference voltage\n"); - msg_error(" -xvaref= Set analog reference voltage\n"); + msg_error(" -x varef Read analog reference voltage\n"); + msg_error(" -x varef= Set analog reference voltage to V\n"); } else if (str_contains(pgm->type, "STK600")) { - msg_error(" -xvaref Read channel 0 analog reference voltage\n"); - msg_error(" -xvaref0 Alias for -xvaref\n"); - msg_error(" -xvaref1 Read channel 1 analog reference voltage\n"); - msg_error(" -xvaref= Set channel 0 analog reference voltage\n"); - msg_error(" -xvaref0= Alias for -xvaref=\n"); - msg_error(" -xvaref1= Set channel 1 analog reference voltage\n"); + msg_error(" -x varef Read channel 0 analog reference voltage\n"); + msg_error(" -x varef0 Alias for -xvaref\n"); + msg_error(" -x varef1 Read channel 1 analog reference voltage\n"); + msg_error(" -x varef= Set channel 0 analog reference voltage to V\n"); + msg_error(" -x varef0= Alias for -xvaref=\n"); + msg_error(" -x varef1= Set channel 1 analog reference voltage to V\n"); } } if (pgm->extra_features & HAS_FOSC_ADJ) { - msg_error(" -xfosc Read oscillator clock frequency\n"); - msg_error(" -xfosc=[M|k]|off Set oscillator clock frequency\n"); + msg_error(" -x fosc Read oscillator clock frequency\n"); + msg_error(" -x fosc=[unit] Set oscillator clock frequency to Hz (or kHz/MHz)\n"); + msg_error(" -x fosc=off Switch the oscillator clock off\n"); } - msg_error(" -xxtal=[M|k] Set programmer xtal frequency\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x xtal=[unit] Set programmer xtal frequency to Hz (or kHz/MHz)\n"); + msg_error(" -x help Show this help menu and exit\n"); return LIBAVRDUDE_EXIT;; } - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } return rv; @@ -1945,13 +1946,13 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp // Set SUFFER value if(str_starts(extended_param, "suffer=")) { if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) { - pmsg_error("invalid -xsuffer= %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } if((PDATA(pgm)->suffer_data[1] & 0x78) != 0x78) { PDATA(pgm)->suffer_data[1] |= 0x78; - pmsg_info("setting -xsuffer=0x%02x so that reserved bits 3..6 are set\n", + pmsg_info("setting -x suffer=0x%02x so that reserved bits 3..6 are set\n", PDATA(pgm)->suffer_data[1]); } PDATA(pgm)->suffer_set = true; @@ -1962,7 +1963,7 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp PDATA(pgm)->suffer_get = true; continue; } - pmsg_error("invalid suffer setting %s. Use -xsuffer or -xsuffer=\n", extended_param); + pmsg_error("invalid setting in -x %s; use -x suffer or -x suffer=\n", extended_param); rv = -1; break; } @@ -1974,7 +1975,7 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp if(str_starts(extended_param, "vtarg_switch=")) { int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1); if(sscanf_success < 1 || PDATA(pgm)->vtarg_switch_data[1] > 1) { - pmsg_error("invalid vtarg_switch value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } @@ -1986,7 +1987,7 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp PDATA(pgm)->vtarg_switch_get = true; continue; } - pmsg_error("invalid vtarg_switch setting %s. Use -xvtarg_switch or -xvtarg_switch=<0..1>\n", extended_param); + pmsg_error("invalid setting in -x %s; use -x vtarg_switch or -x vtarg_switch=<0..1>\n", extended_param); rv = -1; break; } @@ -2000,7 +2001,7 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp int sscanf_success = sscanf(extended_param, "vtarg=%lf", &vtarg_set_val); PDATA(pgm)->vtarg_data = (double)((int)(vtarg_set_val * 100 + .5)) / 100; if(sscanf_success < 1 || vtarg_set_val < 0) { - pmsg_error("invalid vtarg value %s\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rv = -1; break; } @@ -2012,7 +2013,7 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp PDATA(pgm)->vtarg_get = true; continue; } - pmsg_error("invalid vtarg setting %s. Use -xvtarg or -xvtarg=\n", extended_param); + pmsg_error("invalid setting in -x %s; use -x vtarg or -x vtarg=\n", extended_param); rv = -1; break; } @@ -2030,7 +2031,7 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp PDATA(pgm)->pk4_snap_mode = PK4_SNAP_MODE_PIC; continue; } - pmsg_error("invalid mode setting %s. Use -xmode=avr or -xmode=pic\n", extended_param); + pmsg_error("invalid setting in -x %s; use -x mode=avr or -x mode=pic\n", extended_param); rv = -1; break; } @@ -2041,25 +2042,25 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp } if(!help) { - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); if(pgm->extra_features & HAS_SUFFER) { - msg_error(" -xsuffer Read SUFFER register value\n"); - msg_error(" -xsuffer= Set SUFFER register value\n"); + msg_error(" -x suffer Read SUFFER register value\n"); + msg_error(" -x suffer= Set SUFFER register value to =0x.., 0... or decimal\n"); } if(pgm->extra_features & HAS_VTARG_SWITCH) { - msg_error(" -xvtarg_switch Read on-board target voltage switch state\n"); - msg_error(" -xvtarg_switch=<0..1> Set on-board target voltage switch state\n"); + msg_error(" -x vtarg_switch Read on-board target voltage switch state\n"); + msg_error(" -x vtarg_switch=<0..1> Set on-board target voltage switch state\n"); } if(pgm->extra_features & HAS_VTARG_ADJ) { - msg_error(" -xvtarg Read on-board target supply voltage\n"); - msg_error(" -xvtarg= Set on-board target supply voltage\n"); + msg_error(" -x vtarg Read on-board target supply voltage\n"); + msg_error(" -x vtarg= Set on-board target supply voltage to V\n"); } if(str_starts(pgmid, "pickit4") || str_starts(pgmid, "snap")) - msg_error(" -xmode=avr|pic Set programmer to AVR or PIC mode, then exit\n"); - msg_error (" -xhelp Show this help menu and exit\n"); + msg_error(" -x mode=avr|pic Set programmer to AVR or PIC mode, then exit\n"); + msg_error (" -x help Show this help menu and exit\n"); return rv; } return rv; diff --git a/src/teensy.c b/src/teensy.c index 77595315..0cbd62eb 100644 --- a/src/teensy.c +++ b/src/teensy.c @@ -343,7 +343,7 @@ static int teensy_open(PROGRAMMER *pgm, const char *port) { if (port != NULL && dev_name == NULL) { - pmsg_error("invalid -P value: '%s'\n", port); + pmsg_error("invalid -P value: %s\n", port); imsg_error("Use -P usb:bus:device\n"); return -1; } @@ -561,13 +561,13 @@ static int teensy_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) { if (!help) { - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xwait Wait for the device to be plugged in if not connected\n"); - msg_error(" -xwait= Wait [s] for the device to be plugged in if not connected\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x wait Wait for the device to be plugged in if not connected\n"); + msg_error(" -x wait= Wait s for the device to be plugged in if not connected\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } diff --git a/src/urclock.c b/src/urclock.c index d99346a0..60f20036 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -586,7 +586,7 @@ static int urclock_flash_readhook(const PROGRAMMER *pgm, const AVRPART *p, const // Check size of uploded application and protect bootloader from being overwritten if((ur.boothigh && size > maxsize) || (!ur.boothigh && firstbeg <= ur.blend)) - Return("input [0x%04x, 0x%04x] overlaps bootloader [0x%04x, 0x%04x]; consider -xrestore", + Return("input [0x%04x, 0x%04x] overlaps b/loader [0x%04x, 0x%04x]; consider -x restore", firstbeg, size-1, ur.blstart, ur.blend); if(size > maxsize) @@ -595,11 +595,11 @@ static int urclock_flash_readhook(const PROGRAMMER *pgm, const AVRPART *p, const if(!ur.nometadata) { if(size == maxsize) - Return("input [0x%04x, 0x%04x] overlaps metadata code byte at 0x%04x, consider -xnometadata", + Return("input [0x%04x, 0x%04x] overlaps metadata byte at 0x%04x, consider -x nometadata", firstbeg, size-1, ur.pfend); if(nmdata >= nmeta(0, ur.uP.flashsize) && size > maxsize - nmeta(0, ur.uP.flashsize)) { - pmsg_warning("input [0x%04x, 0x%04x] overlaps metadata [0x%04x, 0x%04x], selecting -xnostore\n", + pmsg_warning("input [0x%04x, 0x%04x] overlaps metadata [0x%04x, 0x%04x], selecting -x nostore\n", firstbeg, size-1, maxsize-nmdata, ur.pfend); ur.mcode = 0xff; ur.nostore = 1; @@ -607,7 +607,7 @@ static int urclock_flash_readhook(const PROGRAMMER *pgm, const AVRPART *p, const } if(nmdata >= nmeta(1, ur.uP.flashsize) && size > maxsize - nmeta(1, ur.uP.flashsize)) { - pmsg_warning("input [0x%04x, 0x%04x] overlaps metadata [0x%04x, 0x%04x], selecting -xnodate\n", + pmsg_warning("input [0x%04x, 0x%04x] overlaps metadata [0x%04x, 0x%04x], selecting -x nodate\n", firstbeg, size-1, maxsize-nmdata, ur.pfend); ur.mcode = 0; ur.nodate = 1; @@ -615,7 +615,7 @@ static int urclock_flash_readhook(const PROGRAMMER *pgm, const AVRPART *p, const } if(size > maxsize - nmdata) { - pmsg_warning("input [0x%04x, 0x%04x] overlaps metadata [0x%04x, 0x%04x], selecting -xnofilename\n", + pmsg_warning("input [0x%04x, 0x%04x] overlaps metadata [0x%04x, 0x%04x], selecting -x nofilename\n", firstbeg, size-1, maxsize-nmdata, ur.pfend); ur.mcode = 1; ur.nofilename = 1; @@ -1314,7 +1314,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { Return("-xbootsize=%d size not a multiple of flash page size %d", ur.xbootsize, ur.uP.pagesize); if(ur.xbootsize < 64 || ur.xbootsize > urmin(8192, ur.uP.flashsize/4)) - Return("implausible -xbootsize=%d, should be in [64, %d]", + Return("implausible -x bootsize=%d, should be in [64, %d]", ur.xbootsize, urmin(8192, ur.uP.flashsize/4)); if(ur.boothigh) { ur.blstart = flm->size - ur.xbootsize; @@ -1342,7 +1342,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { if(ur.urprotocol && !(ur.urfeatures & UB_READ_FLASH)) // Bootloader that cannot read flash? if(ur.blend <= ur.blstart) - Return("please specify -xbootsize= and, if needed, %s-xeepromrw", + Return("please specify -x bootsize= and, if needed, %s-xeepromrw", ur.boothigh? "-xvectornum= or ": ""); uint16_t v16 = 0xffff, rjmpwp = ret_opcode; @@ -1377,7 +1377,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { if(rjmpwp == ret_opcode || (dfromend >= -blsize && dfromend < -6)) { // Due diligence if(ur.xbootsize) { if(flm->size - blsize != ur.blstart) { - pmsg_warning("urboot bootloader size %d explicitly overwritten by -xbootsize=%d\n", + pmsg_warning("urboot bootloader size %d explicitly overwritten by -x bootsize=%d\n", blsize, ur.xbootsize); if(!ovsigck && vectnum) { imsg_warning("this can lead to bricking the vector bootloader\n"); @@ -1392,7 +1392,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { if(ur.xvectornum != -1) { if(ur.vblvectornum != vectnum) { - pmsg_warning("urboot vector number %d overwritten by -xvectornum=%d\n", + pmsg_warning("urboot vector number %d overwritten by -x vectornum=%d\n", vectnum, ur.xvectornum); imsg_warning("the application might not start correctly\n"); } @@ -1499,9 +1499,9 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { // Still no bootloader start address? if(ur.blend <= ur.blstart) { if(ur. bloptiversion) - Return("bootloader might be optiboot %d.%d? Please use -xbootsize=\n", + Return("bootloader might be optiboot %d.%d? Please use -x bootsize=\n", ur.bloptiversion>>8, ur.bloptiversion & 255); - Return("unknown bootloader ... please specify -xbootsize=\n"); + Return("unknown bootloader ... please specify -x bootsize=\n"); } } else if(!ur.boothigh) { // @@@ Fixme: guess bootloader size from low flash } @@ -1794,7 +1794,7 @@ static int ur_readEF(const PROGRAMMER *pgm, const AVRPART *p, uint8_t *buf, uint if(mchr == 'E' && !ur.bleepromrw && !ur.xeepromrw) Return("bootloader %s not have EEPROM access%s", ur.blurversion? "does": "might", - ur.blurversion? " capability": "; try -xeepromrw if it has"); + ur.blurversion? " capability": "; try -x eepromrw if it has"); if(len < 1 || len > urmax(ur.uP.pagesize, 256)) Return("len %d exceeds range [1, %d]", len, urmax(ur.uP.pagesize, 256)); @@ -1816,7 +1816,7 @@ static int ur_readEF(const PROGRAMMER *pgm, const AVRPART *p, uint8_t *buf, uint static int parseUrclockID(const PROGRAMMER *pgm) { - if(*ur.iddesc) { // User override of ID, eg, -xid=F.-4.2 for penultimate flash word + if(*ur.iddesc) { // User override of ID, eg, -x id=F.-4.2 for penultimate flash word char *idstr = mmt_strdup(ur.iddesc), *idlenp; const char *errstr; int ad, lg; @@ -1835,19 +1835,19 @@ static int parseUrclockID(const PROGRAMMER *pgm) { *idlenp++ = 0; ad = str_int(idstr+2, STR_INT32, &errstr); if(errstr) { - pmsg_warning("address %s of -xid=%s: %s\n", idstr+2, ur.iddesc, errstr); + pmsg_warning("address %s of -x id=%s: %s\n", idstr+2, ur.iddesc, errstr); mmt_free(idstr); return -1; } lg = str_int(idlenp, STR_INT32, &errstr); if(errstr) { - pmsg_warning("length %s of -xid=%s string: %s\n", idlenp, ur.iddesc, errstr); + pmsg_warning("length %s of -x id=%s string: %s\n", idlenp, ur.iddesc, errstr); mmt_free(idstr); return -1; } if(!lg || lg > 8) { - pmsg_warning("length %s of -xid=%s string must be between 1 and 8\n", idlenp, ur.iddesc); + pmsg_warning("length %s of -x id=%s string must be between 1 and 8\n", idlenp, ur.iddesc); mmt_free(idstr); return -1; } @@ -1874,7 +1874,7 @@ static int readUrclockID(const PROGRAMMER *pgm, const AVRPART *p, uint64_t *urcl *urclockIDp = 0; - // Sanity for small boards in absence of user -xid=... option + // Sanity for small boards in absence of user -x id=... option if(!ur.idlen && (addr >= ur.uP.eepromsize || addr+len > ur.uP.eepromsize)) { addr = 0; if(ur.uP.eepromsize < 8) @@ -1890,11 +1890,11 @@ static int readUrclockID(const PROGRAMMER *pgm, const AVRPART *p, uint64_t *urcl addr += size; if(addr < 0 || addr >= size) - Return("effective address %d of -xids=%s string out of %s range [0, 0x%04x]\n", + Return("effective address %d of -x ids=%s string out of %s range [0, 0x%04x]\n", addr, ur.iddesc, memstr, size-1); if(addr+len > size) - Return("memory range [0x%04x, 0x%04x] of -xid=%s out of %s range [0, 0x%04x]\n", + Return("memory range [0x%04x, 0x%04x] of -x id=%s out of %s range [0, 0x%04x]\n", addr, addr+len-1, ur.iddesc, memstr, size-1); } @@ -1926,7 +1926,7 @@ static int urclock_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t len) { if(rv < 0) { if(ur.sync_silence < 2) pmsg_warning("programmer is not responding%s\n", - ur.sync_silence? "; try -xstrict and/or vary -xdelay=100": ""); + ur.sync_silence? "; try -x strict and/or vary -x delay=100": ""); return -1; } @@ -1982,7 +1982,7 @@ static int urclock_getsync(const PROGRAMMER *pgm) { * of step through a missing byte. If AVRDUDE then sends the next request starting with a * Cmnd_STK_GET_SYNC command then optiboot v4.4 will bail as ist's not Sync_CRC_EOP. Hence, the * strategy here is to send Sync_CRC_EOP/Sync_CRC_EOP for getting a sync. For those bootloaders - * that are strict about the protocol, eg, picoboot, the presence of -xstrict implies that + * that are strict about the protocol, eg, picoboot, the presence of -x strict implies that * comms should use Cmnd_STK_GET_SYNC for getting in sync. */ iob[0] = attempt == 0? autobaud_sync: ur.strict? Cmnd_STK_GET_SYNC: Sync_CRC_EOP; @@ -2295,7 +2295,7 @@ static int urclock_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV if(mchr == 'E' && !ur.bleepromrw && !ur.xeepromrw) Return("bootloader %s not have paged EEPROM write%s", ur.blurversion? "does": "might", - ur.blurversion? " capability": ", try -xeepromrw if it has"); + ur.blurversion? " capability": ", try -x eepromrw if it has"); n = addr + n_bytes; @@ -2330,7 +2330,7 @@ static int urclock_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR if(mchr == 'E' && !ur.bleepromrw && !ur.xeepromrw) Return("bootloader %s not have paged EEPROM read%s", ur.blurversion? "does": "might", - ur.blurversion? " capability": "; try -xeepromrw if it has"); + ur.blurversion? " capability": "; try -x eepromrw if it has"); n = addr + n_bytes; for(; addr < n; addr += chunk) { @@ -2470,7 +2470,7 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) { {"id", NULL, sizeof ur.iddesc, ur.iddesc, 1, "Location of Urclock ID, eg, F.12345.6"}, {"title", NULL, sizeof ur.title, ur.title, 1, "Title stored and shown in lieu of a filename"}, {"bootsize", &ur.xbootsize, ARG, "Override/set bootloader size"}, - {"vectornum", &ur.xvectornum, ARG, "Treat bootloader as vector b/loader using this vector"}, + {"vectornum", &ur.xvectornum, ARG, "Treat bootloader as vector b/loader using vector "}, {"eepromrw", &ur.xeepromrw, NA, "Assert bootloader EEPROM read/write capability"}, {"emulate_ce", &ur.xemulate_ce, NA, "Emulate chip erase"}, {"restore", &ur.restore, NA, "Restore a flash backup and trim the bootloader"}, @@ -2481,7 +2481,7 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) { {"nostore", &ur.nostore, NA, "Do not store metadata except a flag saying so"}, {"nometadata", &ur.nometadata, NA, "Do not support metadata at all"}, {"noautoreset", &ur.nometadata, NA, "Do not reset the board after opening the serial port"}, - {"delay", &ur.delay, ARG, "Add delay [ms] after reset, can be negative"}, + {"delay", &ur.delay, ARG, "Additional ms delay after reset, can be negative"}, {"strict", &ur.strict, NA, "Use strict synchronisation protocol"}, {"help", &help, NA, "Show this help menu and exit"}, }; @@ -2508,8 +2508,9 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) { const char *errstr; int val = str_int(arg, STR_INT32, &errstr); if(errstr) { - pmsg_error("-x%s: %s\n", extended_param, errstr); - return -1; + pmsg_error("-x %s: %s\n", extended_param, + str_eq(errstr, "no data to convert")? "missing argument": errstr); + return -1; } *options[i].optionp = val; pmsg_notice2("%s=%d set\n", options[i].name, (int) val); @@ -2517,7 +2518,7 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) { } } else if(options[i].nstrbuf > 0) { if(plen <= olen || extended_param[olen] != '=') { - pmsg_error("missing argument for option %s=...\n", extended_param); + pmsg_error("missing argument for -x %s=...\n", extended_param); rc = -1; } else { if(options[i].strbuf) { @@ -2530,7 +2531,7 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) { } } if(i >= sizeof options/sizeof*options) { - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rc = -1; } } @@ -2538,7 +2539,8 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) { if(help || rc < 0) { msg_error("%s -c %s extended options:\n", progname, pgmid); for(size_t i=0; i": "", + msg_error(" -x %s%s%*s%s\n", options[i].name, + options[i].assign && options[i].strbuf? "=": options[i].assign? "= ": "", urmax(0, 16-(int) strlen(options[i].name)-(options[i].assign? 6: 0)), "", options[i].help); } if(rc == 0) diff --git a/src/usbasp.c b/src/usbasp.c index 86957420..68333b05 100644 --- a/src/usbasp.c +++ b/src/usbasp.c @@ -296,12 +296,12 @@ static int usbasp_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if (str_eq(extended_param, "help")) { msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xsection_config Erase configuration section only with -e (TPI only)\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x section_config Erase configuration section only with -e (TPI only)\n"); + msg_error(" -x help Show this help menu and exit\n"); return LIBAVRDUDE_EXIT;; } - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } diff --git a/src/usbtiny.c b/src/usbtiny.c index 10b00f54..bee28a07 100644 --- a/src/usbtiny.c +++ b/src/usbtiny.c @@ -357,7 +357,7 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *name) { } if(NULL != name && NULL == dev_name) { - pmsg_error("invalid -P value: '%s'\n", name); + pmsg_error("invalid -P value: %s\n", name); imsg_error("use -P usb:bus:device\n"); return -1; } diff --git a/src/wiring.c b/src/wiring.c index 47746209..c6008f59 100644 --- a/src/wiring.c +++ b/src/wiring.c @@ -91,17 +91,19 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { if (str_starts(extended_param, "snooze=")) { int val = str_int(extended_param+7, STR_INT32, &errstr); if(errstr || val < 0) { - pmsg_error("-x%s: %s\n", extended_param, errstr? errstr: "snooze time cannot be negative"); + pmsg_error("-x %s: %s\n", extended_param, errstr? errstr: "snooze time cannot be negative"); rv = -1; - continue; + break; } pmsg_notice2("%s(): snooze time set to %d ms\n", __func__, val); WIRINGPDATA(pgm)->snoozetime = val; continue; - } else if (str_starts(extended_param, "delay=")) { + } + + if (str_starts(extended_param, "delay=")) { int val = str_int(extended_param+6, STR_INT32, &errstr); if(errstr) { - pmsg_error("-x%s: %s\n", extended_param, errstr); + pmsg_error("-x %s: %s\n", extended_param, errstr); rv = -1; break; } @@ -109,24 +111,26 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { WIRINGPDATA(pgm)->delay = val; continue; } - else if(str_eq(extended_param, "noautoreset")) { + + if(str_eq(extended_param, "noautoreset")) { WIRINGPDATA(pgm)->autoreset = false; continue; } - else if (str_eq(extended_param, "help")) { + + if (str_eq(extended_param, "help")) { help = true; rv = LIBAVRDUDE_EXIT; } if (!help) { - pmsg_error("invalid extended parameter %s\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xsnooze= Wait snooze ms before protocol sync after port open\n"); - msg_error(" -xdelay= Add delay [n] ms after reset, can be negative\n"); - msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x snooze= Wait snooze ms before protocol sync after port open\n"); + msg_error(" -x delay= Add delay [n] ms after reset, can be negative\n"); + msg_error(" -x noautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); + msg_error(" -x help Show this help menu and exit\n"); return rv; } @@ -175,7 +179,7 @@ static int wiring_open(PROGRAMMER *pgm, const char *port) { stk500v2_drain(pgm, 0); if (stk500v2_getsync(pgm) < 0) { - pmsg_error("stk500v2_getsync() failed; try -xdelay=n with some n in [-80, 100]\n"); + pmsg_error("stk500v2_getsync() failed; try -x delay=n with some n in [-80, 100]\n"); return -1; } diff --git a/src/xbee.c b/src/xbee.c index 31e2b702..7052aeb4 100644 --- a/src/xbee.c +++ b/src/xbee.c @@ -1632,9 +1632,9 @@ static int xbee_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { int resetpin; if (sscanf(extended_param, "xbeeresetpin=%i", &resetpin) != 1 || resetpin <= 0 || resetpin > 7) { - pmsg_error("invalid xbeeresetpin '%s'\n", extended_param); + pmsg_error("invalid value in -x %s\n", extended_param); rc = -1; - continue; + break; } PDATA(pgm)->xbeeResetPin = resetpin; @@ -1647,12 +1647,12 @@ static int xbee_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if (!help) { - pmsg_error("invalid extended parameter '%s'\n", extended_param); + pmsg_error("invalid extended parameter -x %s\n", extended_param); rc = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -xxbeeresetpin=<1..7> Set XBee pin DIO<1..7> as reset pin\n"); - msg_error(" -xhelp Show this help menu and exit\n"); + msg_error(" -x xbeeresetpin=<1..7> Set XBee pin DIO<1..7> as reset pin\n"); + msg_error(" -x help Show this help menu and exit\n"); return rc; } From df5d1feb8903a9ed0bc2675c68bc28cb9f112f52 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 29 Jul 2024 16:24:40 +0100 Subject: [PATCH 380/422] Add remaining spaces after -x in messages --- src/avrdude.1 | 6 +++--- src/buspirate.c | 2 +- src/doc/avrdude.texi | 38 +++++++++++++++++++------------------- src/serialupdi.c | 2 +- src/stk500v2.c | 4 ++-- src/urclock.c | 10 +++++----- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index 72a61e28..5bf5a43e 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -1815,7 +1815,7 @@ Show the last-modified date of the input file for the flash application, then exit. If the input file was stdin, the date will be that of the programming. Date and filename are part of the metadata that the urclock programmer stores by default in high flash just under the bootloader; see also --xnometadata. +-x nometadata. .It Ar showfilename Show the input filename (or title) of the last flash writing session, then exit. .It Ar title= @@ -1894,14 +1894,14 @@ Do not support any metadata. The full flash besides the bootloader is available for the application. If the application is smaller than the available space then a metadata code byte 0xff is stored nevertheless to indicate there are no further metadata available. In absence of --xnometadata, the default for the urclock programmer is to write as much +-x nometadata, the default for the urclock programmer is to write as much metadata (filename, data and store information) as the size of the uploaded application and the other extended options allow. The subtle difference between -x nometadata and -x nostore is that the latter always explicitly stores in flash that no further metadata are available, so that a such prepared flash can always be queried with .Nm --xshowall. In contrast to this, it cannot be guaranteed that a -x showall +-x showall. In contrast to this, it cannot be guaranteed that a -x showall query on flash prepared with -x nometadata yields useful results. .It Ar delay= Add a ms delay after reset. This can be useful if a board takes a diff --git a/src/buspirate.c b/src/buspirate.c index 55482f76..1c6d4fa0 100644 --- a/src/buspirate.c +++ b/src/buspirate.c @@ -372,7 +372,7 @@ static int buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) else if (str_caseeq(resetpin, "aux2")) PDATA(pgm)->reset |= BP_RESET_AUX2; else { - pmsg_error("-xreset= value must be either CS, AUX or AUX2\n"); + pmsg_error("-x reset= value must be either CS, AUX or AUX2\n"); rv = -1; break; } diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 3b12762a..b3df4b29 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -1222,14 +1222,14 @@ Other JTAG units might require a different bit shift count. @var{Power Debugger and Pickit 4 only} @* High-voltage UPDI programming is used to enable a UPDI pin that has previously -been set to RESET or GPIO mode. Use @samp{-xhvupdi} to enable high-voltage UPDI +been set to RESET or GPIO mode. Use @samp{-x hvupdi} to enable high-voltage UPDI initialization for supported targets. @item @samp{vtarg=VALUE, vtarg} @var{Power Debugger only} @* The voltage generator can be enabled by setting a target voltage. -The current set-voltage can be read by @samp{-xvtarg} alone. +The current set-voltage can be read by @samp{-x vtarg} alone. @item @samp{help} Show help menu and exit. @@ -1245,7 +1245,7 @@ The PICkit 4 and MPLAB SNAP programmers accept the following extended parameters @item @samp{mode=avr,pic} Switch programmer to AVR or PIC mode, then exit: the PICkit 4 and MPLAB SNAP programmer can only be utilised by Avrdude when in AVR mode. -Use @samp{-xmode=avr} for switching to AVR mode, or @samp{-xmode=pic} +Use @samp{-x mode=avr} for switching to AVR mode, or @samp{-x mode=pic} for switching to PIC mode. @item @samp{help} Show help menu and exit. @@ -1260,7 +1260,7 @@ following extended parameters: @table @code @item @samp{suffer=VALUE}, @samp{suffer} The SUFFER register allows the user to modify the behavior of the on-board mEDBG. -The current state can be read by @samp{-xsuffer} alone. +The current state can be read by @samp{-x suffer} alone. @table @code @item Bit 7 ARDUINO: Adds control of extra LEDs when set to 0 @@ -1278,7 +1278,7 @@ Fuses are safe-masked when bit sent to 1. Fuses are unprotected when set to 0 @table @code @item @samp{vtarg_switch=VALUE}, @samp{vtarg_switch} The on-board target voltage switch can be turned on or off by writing a 1 or -a 0. The current state can be read by @samp{-xvtarg_switch} alone. +a 0. The current state can be read by @samp{-x vtarg_switch} alone. Note that the target power switch will always be on after a power cycle. Also note that the smaller Xplained Nano boards does not have a target power switch. @@ -1293,7 +1293,7 @@ The Curiosity Nano board accepts the following extended parameter: @table @code @item @samp{vtarg=VALUE, vtarg} The generated on-board target voltage can be changed by specifying a new voltage. -The current set-voltage can be read by @samp{-xvtarg} alone. +The current set-voltage can be read by @samp{-x vtarg} alone. @item @samp{help} Show help menu and exit. @end table @@ -1307,21 +1307,21 @@ The STK500 and STK600 boards accept the following extended parameters: @table @code @item @samp{vtarg=VALUE, vtarg} The generated on-board target voltage can be changed by specifying a new voltage. -The current set-voltage can be read by @samp{-xvtarg} alone. +The current set-voltage can be read by @samp{-x vtarg} alone. @item @samp{fosc=VALUE[MHz|M|kHz|k|Hz|H], fosc} Set the programmable oscillator frequency in MHz, kHz or Hz. -The current frequency can be read by @samp{-xfosc} alone. +The current frequency can be read by @samp{-x fosc} alone. @item @samp{varef=VALUE, varef} The generated on-board analog reference voltage can be changed by specifying a new reference voltage. The current reference voltage can be read by -@samp{-xvaref} alone. +@samp{-x varef} alone. @item @samp{varef[0,1]=VALUE, varef[0,1]} @var{STK600 only} @* The generated on-board analog reference voltage for channel 0 or channel 1 can be changed by specifying a new reference voltage. -The current reference voltage can be read by @samp{-xvaref0} or -@samp{-xvaref1} alone. +The current reference voltage can be read by @samp{-x varef0} or +@samp{-x varef1} alone. @item @samp{attemps[=<1..99>]} @var{STK500V1 only} @* @@ -1374,7 +1374,7 @@ Show help menu and exit. The urclock programmer type accepts the following extended parameters: @table @code @item @samp{showall} -Show all info for the connected part, then exit. The @code{-xshow...} options +Show all info for the connected part, then exit. The @code{-x show...} options below can be used to assemble a bespoke response consisting of a subset (or only one item) of all available relevant information about the connected part and bootloader. @@ -1383,7 +1383,7 @@ Show a unique Urclock ID stored in either flash or EEPROM of the MCU, then exit. @item @samp{id=..} Historically, the Urclock ID was a six-byte unique little-endian number stored in Urclock boards at EEPROM address 257. The location of this -number can be set by the @code{-xid=..} extended parameter. @code{E} +number can be set by the @code{-x id=..} extended parameter. @code{E} stands for EEPROM and @code{F} stands for flash. A negative address addr counts from the end of EEPROM and flash, respectively. The length len of the Urclock ID can be between 1 and 8 bytes. @@ -1392,7 +1392,7 @@ Show the last-modified date of the input file for the flash application, then exit. If the input file was stdin, the date will be that of the programming. Date and filename are part of the metadata that the urclock programmer stores by default in high flash just under the bootloader; see also -@code{-xnometadata}. +@code{-x nometadata}. @item @samp{showfilename} Show the input filename (or title) of the last flash writing session, then exit. @item @samp{title=} @@ -1449,7 +1449,7 @@ Upload unchanged flash input files and trim below the bootloader if needed. This is most useful when one has a backup of the full flash and wants to play that back onto the device. No metadata are written in this case and no vector patching happens either if it is a vector bootloader. -However, for vector bootloaders, even under the option @code{-xrestore} an +However, for vector bootloaders, even under the option @code{-x restore} an input file will not be uploaded for which the reset vector does not point to the vector bootloader. This is to avoid writing an input file to the device that would render the vector bootloader not functional as it would @@ -1471,14 +1471,14 @@ Do not support any metadata. The full flash besides the bootloader is available for the application. If the application is smaller than the available space then a metadata code byte @code{0xff} is stored nevertheless to indicate there are no further metadata available. In -absence of @code{-xnometadata}, the default for the urclock programmer is +absence of @code{-x nometadata}, the default for the urclock programmer is to write as much metadata (filename, data and store information) as the size of the uploaded application and the other extended options allow. The -subtle difference between @code{-xnometadata} and @code{-xnostore} is that +subtle difference between @code{-x nometadata} and @code{-x nostore} is that the latter always explicitly stores in flash that no further metadata are available, so that a such prepared flash can always be queried with @code{avrdude -x showall}. In contrast to this, it cannot be guaranteed -that a @code{-x showall} query on flash prepared with @code{-xnometadata} +that a @code{-x showall} query on flash prepared with @code{-x nometadata} yields useful results. @item @samp{delay=} Add a ms delay after reset. This can be useful if a board takes a @@ -1488,7 +1488,7 @@ shortened accordingly. @item @samp{strict} Urclock has a faster, but slightly different strategy than -c arduino to synchronise with the bootloader; some stk500v1 bootloaders cannot cope -with this, and they need the @code{-xstrict} option. +with this, and they need the @code{-x strict} option. @item @samp{help} Show help menu and exit. @end table diff --git a/src/serialupdi.c b/src/serialupdi.c index 1d1eb22a..1cd998af 100644 --- a/src/serialupdi.c +++ b/src/serialupdi.c @@ -1027,7 +1027,7 @@ static int serialupdi_parseextparms(const PROGRAMMER *pgm, const LISTID extparms } else if (str_caseeq(rts_mode, "high")) { updi_set_rts_mode(pgm, RTS_MODE_HIGH); } else { - pmsg_error("-xrtsdtr=: RTS/DTR mode must be LOW or HIGH\n"); + pmsg_error("-x rtsdtr=: RTS/DTR mode must be LOW or HIGH\n"); rv = -1; break; } diff --git a/src/stk500v2.c b/src/stk500v2.c index 6d5decbb..a92c8a0e 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -1905,10 +1905,10 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } else if (str_contains(pgm->type, "STK600")) { msg_error(" -x varef Read channel 0 analog reference voltage\n"); - msg_error(" -x varef0 Alias for -xvaref\n"); + msg_error(" -x varef0 Alias for -x varef\n"); msg_error(" -x varef1 Read channel 1 analog reference voltage\n"); msg_error(" -x varef= Set channel 0 analog reference voltage to V\n"); - msg_error(" -x varef0= Alias for -xvaref=\n"); + msg_error(" -x varef0= Alias for -x varef=\n"); msg_error(" -x varef1= Set channel 1 analog reference voltage to V\n"); } } diff --git a/src/urclock.c b/src/urclock.c index 60f20036..c4626ea6 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -1311,7 +1311,7 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { // Manual provision of above bootloader parameters if(ur.xbootsize) { if(ur.boothigh && ur.xbootsize % ur.uP.pagesize) - Return("-xbootsize=%d size not a multiple of flash page size %d", + Return("-x bootsize=%d size not a multiple of flash page size %d", ur.xbootsize, ur.uP.pagesize); if(ur.xbootsize < 64 || ur.xbootsize > urmin(8192, ur.uP.flashsize/4)) Return("implausible -x bootsize=%d, should be in [64, %d]", @@ -1342,8 +1342,8 @@ static int ur_initstruct(const PROGRAMMER *pgm, const AVRPART *p) { if(ur.urprotocol && !(ur.urfeatures & UB_READ_FLASH)) // Bootloader that cannot read flash? if(ur.blend <= ur.blstart) - Return("please specify -x bootsize= and, if needed, %s-xeepromrw", - ur.boothigh? "-xvectornum= or ": ""); + Return("please specify -x bootsize= and, if needed, %s-x eepromrw", + ur.boothigh? "-x vectornum= or ": ""); uint16_t v16 = 0xffff, rjmpwp = ret_opcode; @@ -1822,13 +1822,13 @@ static int parseUrclockID(const PROGRAMMER *pgm) { int ad, lg; if(!(strchr("EF", *idstr) && idstr[1] == '.')) { - pmsg_warning("-xid=%s string must start with E. or F.\n", ur.iddesc); + pmsg_warning("-x id=%s string must start with E. or F.\n", ur.iddesc); mmt_free(idstr); return -1; } if(!(idlenp = strchr(idstr+2, '.'))) { - pmsg_warning("-xid=%s string must look like [E|F]..\n", ur.iddesc); + pmsg_warning("-x id=%s string must look like [E|F]..\n", ur.iddesc); mmt_free(idstr); return -1; } From 41e7d815440fbd27ad1103ac7bb7e2db6fc9f46e Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 17:43:07 +0200 Subject: [PATCH 381/422] Fix issue where help flag wasn't set when it should --- src/jtagmkII.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jtagmkII.c b/src/jtagmkII.c index 19f0fae2..22407373 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -1376,7 +1376,7 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); + help = true; rv = LIBAVRDUDE_EXIT; } @@ -1384,6 +1384,7 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) pmsg_error("invalid extended parameter -x %s\n", extended_param); rv = -1; } + msg_error("%s -c %s extended options:\n", progname, pgmid); if (pgm->flag & PGM_FL_IS_JTAG) msg_error(" -x jtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); if (pgm->flag & PGM_FL_IS_PDI) From 9658908e7ff991b062606bc935453ad94323e035 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 17:45:16 +0200 Subject: [PATCH 382/422] check if pgm->type is Arduino instead of pgmid --- src/stk500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stk500.c b/src/stk500.c index 7f9e13b6..651c678f 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -1580,7 +1580,7 @@ static void stk500_setup(PROGRAMMER *pgm) { else PDATA(pgm)->xtal = STK500_XTAL; // The -c arduino programmer has auto-reset enabled be default - if (str_eq(pgmid, "arduino")) + if (str_eq(pgm->type, "Arduino")) PDATA(pgm)->autoreset = true; } From 95b4e7804a3235ec10b523b2fd57ae5caeee662b Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 18:04:34 +0200 Subject: [PATCH 383/422] Improve -x help for the remaining programmers --- src/serprog.c | 21 ++++++++------ src/stk500v2.c | 77 ++++++++++++++++++++++++++------------------------ src/usbasp.c | 24 +++++++++------- 3 files changed, 66 insertions(+), 56 deletions(-) diff --git a/src/serprog.c b/src/serprog.c index 73965b9f..84d9b029 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -462,12 +462,11 @@ static int serprog_get_sck_period(const PROGRAMMER *pgm, double *v) { } static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rv = 0; + bool help = true; - for(ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for(LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if(str_starts(extended_param, "cs=")) { unsigned int cs; @@ -482,14 +481,18 @@ static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) } if(str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -x cs= Sets the chip select line to CS for supported programmers\n"); - msg_error(" -x help Show this help menu and exit\n"); + help = true; return LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter -x %s\n", extended_param); - rv = -1; + if(!help) { + pmsg_error("invalid extended parameter -x %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -x cs= Sets the chip select line to CS for supported programmers\n"); + msg_error(" -x help Show this help menu and exit\n"); + return rv; } return rv; diff --git a/src/stk500v2.c b/src/stk500v2.c index a92c8a0e..c1b1559b 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -1742,12 +1742,11 @@ static void stk500v2_enable(PROGRAMMER *pgm, const AVRPART *p) { } static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rv = 0; + bool help = false; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (str_starts(extended_param, "vtarg")) { if (pgm->extra_features & HAS_VTARG_ADJ) { @@ -1772,7 +1771,7 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } } - else if (str_starts(extended_param, "varef")) { + if (str_starts(extended_param, "varef")) { if (pgm->extra_features & HAS_VAREF_ADJ) { int sscanf_success = 0; double varef_set_val = -1; @@ -1820,7 +1819,7 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } } - else if (str_starts(extended_param, "fosc")) { + if (str_starts(extended_param, "fosc")) { if (pgm->extra_features & HAS_FOSC_ADJ) { // Set clock generator frequency if (str_starts(extended_param, "fosc=")) { @@ -1863,7 +1862,7 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } } - else if (str_starts(extended_param, "xtal")) { + if (str_starts(extended_param, "xtal")) { // Set clock generator frequency if (str_starts(extended_param, "xtal=")) { char xtal_str[16] = {0}; @@ -1892,38 +1891,42 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) } } - else if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - if (pgm->extra_features & HAS_VTARG_ADJ) { - msg_error(" -x vtarg Read target supply voltage\n"); - msg_error(" -x vtarg= Set target supply voltage to V\n"); - } - if (pgm->extra_features & HAS_VAREF_ADJ) { - if (str_contains(pgm->type, "STK500")) { - msg_error(" -x varef Read analog reference voltage\n"); - msg_error(" -x varef= Set analog reference voltage to V\n"); - } - else if (str_contains(pgm->type, "STK600")) { - msg_error(" -x varef Read channel 0 analog reference voltage\n"); - msg_error(" -x varef0 Alias for -x varef\n"); - msg_error(" -x varef1 Read channel 1 analog reference voltage\n"); - msg_error(" -x varef= Set channel 0 analog reference voltage to V\n"); - msg_error(" -x varef0= Alias for -x varef=\n"); - msg_error(" -x varef1= Set channel 1 analog reference voltage to V\n"); - } - } - if (pgm->extra_features & HAS_FOSC_ADJ) { - msg_error(" -x fosc Read oscillator clock frequency\n"); - msg_error(" -x fosc=[unit] Set oscillator clock frequency to Hz (or kHz/MHz)\n"); - msg_error(" -x fosc=off Switch the oscillator clock off\n"); - } - msg_error(" -x xtal=[unit] Set programmer xtal frequency to Hz (or kHz/MHz)\n"); - msg_error(" -x help Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + if (str_eq(extended_param, "help")) { + help = true; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter -x %s\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter -x %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + if (pgm->extra_features & HAS_VTARG_ADJ) { + msg_error(" -x vtarg Read target supply voltage\n"); + msg_error(" -x vtarg= Set target supply voltage to V\n"); + } + if (pgm->extra_features & HAS_VAREF_ADJ) { + if (str_contains(pgm->type, "STK500")) { + msg_error(" -x varef Read analog reference voltage\n"); + msg_error(" -x varef= Set analog reference voltage to V\n"); + } + else if (str_contains(pgm->type, "STK600")) { + msg_error(" -x varef Read channel 0 analog reference voltage\n"); + msg_error(" -x varef0 Alias for -x varef\n"); + msg_error(" -x varef1 Read channel 1 analog reference voltage\n"); + msg_error(" -x varef= Set channel 0 analog reference voltage to V\n"); + msg_error(" -x varef0= Alias for -x varef=\n"); + msg_error(" -x varef1= Set channel 1 analog reference voltage to V\n"); + } + } + if (pgm->extra_features & HAS_FOSC_ADJ) { + msg_error(" -x fosc Read oscillator clock frequency\n"); + msg_error(" -x fosc=[unit] Set oscillator clock frequency to Hz (or kHz/MHz)\n"); + msg_error(" -x fosc=off Switch the oscillator clock off\n"); + } + msg_error(" -x xtal=[unit] Set programmer xtal frequency to Hz (or kHz/MHz)\n"); + msg_error(" -x help Show this help menu and exit\n"); + return rv; } return rv; } diff --git a/src/usbasp.c b/src/usbasp.c index 68333b05..abdb24a6 100644 --- a/src/usbasp.c +++ b/src/usbasp.c @@ -282,27 +282,31 @@ static void usbasp_teardown(PROGRAMMER *pgm) { } static int usbasp_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { - LNODEID ln; - const char *extended_param; int rv = 0; + bool help = false; - for (ln = lfirst(extparms); ln; ln = lnext(ln)) { - extended_param = ldata(ln); + for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { + const char *extended_param = ldata(ln); if (str_eq(extended_param, "section_config")) { pmsg_notice2("usbasp_parseextparms(): set section_e to 1 (config section)\n"); PDATA(pgm)->section_e = 1; continue; } + if (str_eq(extended_param, "help")) { - msg_error("%s -c %s extended options:\n", progname, pgmid); - msg_error(" -x section_config Erase configuration section only with -e (TPI only)\n"); - msg_error(" -x help Show this help menu and exit\n"); - return LIBAVRDUDE_EXIT;; + help = true; + rv = LIBAVRDUDE_EXIT; } - pmsg_error("invalid extended parameter -x %s\n", extended_param); - rv = -1; + if (!help) { + pmsg_error("invalid extended parameter -x %s\n", extended_param); + rv = -1; + } + msg_error("%s -c %s extended options:\n", progname, pgmid); + msg_error(" -x section_config Erase configuration section only with -e (TPI only)\n"); + msg_error(" -x help Show this help menu and exit\n"); + return rv; } return rv; From 3c679b10c6153916bae025a86bb5f479f0363101 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 19:44:37 +0200 Subject: [PATCH 384/422] Add help text for -E exitspec --- src/flip2.c | 19 ++++++++++++-- src/linuxspi.c | 19 ++++++++++++-- src/main.c | 13 ++++++---- src/par.c | 67 +++++++++++++++++++++++++++++++++----------------- 4 files changed, 87 insertions(+), 31 deletions(-) diff --git a/src/flip2.c b/src/flip2.c index 50bb486f..b29f074a 100644 --- a/src/flip2.c +++ b/src/flip2.c @@ -494,6 +494,8 @@ static int flip2_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const A // Parse the -E option flag static int flip2_parseexitspecs(PROGRAMMER *pgm, const char *sp) { char *cp, *s, *str = mmt_strdup(sp); + int rv = 0; + bool help = false; s = str; while ((cp = strtok(s, ","))) { @@ -506,12 +508,25 @@ static int flip2_parseexitspecs(PROGRAMMER *pgm, const char *sp) { pgm->exit_reset = EXIT_RESET_DISABLED; continue; } + if (str_eq(cp, "help")) { + help = true; + rv = LIBAVRDUDE_EXIT; + } + + if (!help) { + pmsg_error("invalid exitspec parameter -E %s\n", cp); + rv = -1; + } + msg_error("%s -c %s exitspec parameter options:\n", progname, pgmid); + msg_error(" -E reset Application will not start automatically after programming session\n"); + msg_error(" -E noreset Application will start automatically after programming session\n"); + msg_error(" -E help Show this help menu and exit\n"); mmt_free(str); - return -1; + return rv; } mmt_free(str); - return 0; + return rv; } static int flip2_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *mem) { diff --git a/src/linuxspi.c b/src/linuxspi.c index 8ca1f9fa..678aa222 100644 --- a/src/linuxspi.c +++ b/src/linuxspi.c @@ -381,6 +381,8 @@ static int linuxspi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { static int linuxspi_parseexitspecs(PROGRAMMER *pgm, const char *sp) { char *cp, *s, *str = mmt_strdup(sp); + int rv = 0; + bool help = false; s = str; while ((cp = strtok(s, ","))) { @@ -393,12 +395,25 @@ static int linuxspi_parseexitspecs(PROGRAMMER *pgm, const char *sp) { pgm->exit_reset = EXIT_RESET_DISABLED; continue; } + if (str_eq(cp, "help")) { + help = true; + rv = LIBAVRDUDE_EXIT; + } + + if (!help) { + pmsg_error("invalid exitspec parameter -E %s\n", cp); + rv = -1; + } + msg_error("%s -c %s exitspec parameter options:\n", progname, pgmid); + msg_error(" -E reset Programmer will keep the reset line low after programming session\n"); + msg_error(" -E noreset Programmer will not keep the reset line low after programming session\n"); + msg_error(" -E help Show this help menu and exit\n"); mmt_free(str); - return -1; + return rv; } mmt_free(str); - return 0; + return rv; } static int linuxspi_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { diff --git a/src/main.c b/src/main.c index 1f9b3d6e..02787da7 100644 --- a/src/main.c +++ b/src/main.c @@ -1440,11 +1440,14 @@ skipopen: if (pgm->parseexitspecs == NULL) { pmsg_warning("-E option not supported by this programmer type\n"); exitspecs = NULL; - } - else if (pgm->parseexitspecs(pgm, exitspecs) < 0) { - usage(); - exitrc = 1; - goto main_exit; + } else { + int rc = pgm->parseexitspecs(pgm, exitspecs); + if(rc == LIBAVRDUDE_EXIT) + exit(0); + if(rc < 0) { + pmsg_error("unable to parse list of -E parameters\n"); + exit(1); + } } } diff --git a/src/par.c b/src/par.c index 490068e9..ef4ac33d 100644 --- a/src/par.c +++ b/src/par.c @@ -335,36 +335,59 @@ static void par_close(PROGRAMMER *pgm) { */ static int par_parseexitspecs(PROGRAMMER *pgm, const char *sp) { char *cp, *s, *str = mmt_strdup(sp); + int rv = 0; + bool help = false; s = str; while((cp = strtok(s, ","))) { - if(str_eq(cp, "reset")) + s = NULL; + if(str_eq(cp, "reset")) { pgm->exit_reset = EXIT_RESET_ENABLED; - - else if(str_eq(cp, "noreset")) - pgm->exit_reset = EXIT_RESET_DISABLED; - - else if(str_eq(cp, "vcc")) - pgm->exit_vcc = EXIT_VCC_ENABLED; - - else if(str_eq(cp, "novcc")) - pgm->exit_vcc = EXIT_VCC_DISABLED; - - else if(str_eq(cp, "d_high")) - pgm->exit_datahigh = EXIT_DATAHIGH_ENABLED; - - else if(str_eq(cp, "d_low")) - pgm->exit_datahigh = EXIT_DATAHIGH_DISABLED; - - else { - mmt_free(str); - return -1; + continue; } - s = NULL; // Only call strtok() once with the actual string + if(str_eq(cp, "noreset")) { + pgm->exit_reset = EXIT_RESET_DISABLED; + continue; + } + if(str_eq(cp, "vcc")) { + pgm->exit_vcc = EXIT_VCC_ENABLED; + continue; + } + if(str_eq(cp, "novcc")) { + pgm->exit_vcc = EXIT_VCC_DISABLED; + continue; + } + if(str_eq(cp, "d_high")) { + pgm->exit_datahigh = EXIT_DATAHIGH_ENABLED; + continue; + } + if(str_eq(cp, "d_low")) { + pgm->exit_datahigh = EXIT_DATAHIGH_DISABLED; + continue; + } + if (str_eq(cp, "help")) { + help = true; + rv = LIBAVRDUDE_EXIT; + } + + if (!help) { + pmsg_error("invalid exitspec parameter -E %s\n", cp); + rv = -1; + } + msg_error("%s -c %s exitspec parameter options:\n", progname, pgmid); + msg_error(" -E reset Programmer will keep the reset line low after programming session\n"); + msg_error(" -E noreset Programmer will not keep the reset line low after programming session\n"); + msg_error(" -E vcc Programmer VCC pin(s) remain active after programming session\n"); + msg_error(" -E novcc Programmer VCC pin(s) turned off after programming session\n"); + msg_error(" -E d_high Set all 8 programmer data pins high after programming session\n"); + msg_error(" -E d_low Set all 8 programmer data pins low after programming session\n"); + msg_error(" -E help Show this help menu and exit\n"); + mmt_free(str); + return rv; } mmt_free(str); - return 0; + return rv; } void par_initpgm(PROGRAMMER *pgm) { From 297d256c0732aee5b2d3c53256f8bd6d9b8c59bf Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 20:20:27 +0200 Subject: [PATCH 385/422] Fix incorrect noautoreset implementation for the Wiring programmer option --- src/wiring.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wiring.c b/src/wiring.c index c6008f59..f1c5ad77 100644 --- a/src/wiring.c +++ b/src/wiring.c @@ -56,7 +56,7 @@ */ struct wiringpdata { int snoozetime, delay; - bool autoreset; + bool noautoreset; }; @@ -113,7 +113,7 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { } if(str_eq(extended_param, "noautoreset")) { - WIRINGPDATA(pgm)->autoreset = false; + WIRINGPDATA(pgm)->noautoreset = true; continue; } @@ -154,7 +154,7 @@ static int wiring_open(PROGRAMMER *pgm, const char *port) { while (timetosnooze--) usleep(1000); pmsg_notice2("%s(): done snoozing\n", __func__); - } else if (WIRINGPDATA(pgm)->autoreset) { + } else if (WIRINGPDATA(pgm)->noautoreset == false) { // This code assumes a negative-logic USB to TTL serial adapter // Set RTS/DTR high to discharge the series-capacitor, if present pmsg_notice2("%s(): releasing DTR/RTS\n", __func__); @@ -199,7 +199,6 @@ void wiring_initpgm(PROGRAMMER *pgm) { stk500v2_initpgm(pgm); strcpy(pgm->type, "Wiring"); - WIRINGPDATA(&pgm)->autoreset = true; // Auto-reset enabled by default pgm->open = wiring_open; pgm->close = wiring_close; From 38da0709212ce72481adb56ec770b8453e5537cb Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 20:42:58 +0200 Subject: [PATCH 386/422] Fix bug in the serprog ext parameters parsing --- src/serprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serprog.c b/src/serprog.c index 84d9b029..70445d84 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -482,7 +482,7 @@ static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) if(str_eq(extended_param, "help")) { help = true; - return LIBAVRDUDE_EXIT; + rv = LIBAVRDUDE_EXIT; } if(!help) { From 77db93b5d02bc3ee5e8a145e7e9a4dbe0e0f9db7 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 21:17:33 +0200 Subject: [PATCH 387/422] Fix formatting and missing brackets --- src/jtag3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/jtag3.c b/src/jtag3.c index deb9a6e2..8fe04dfb 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -1610,9 +1610,10 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { rv = -1; } msg_error("%s -c %s extended options:\n", progname, pgmid); - if(str_eq(pgm->type, "JTAGICE3")) + if(str_eq(pgm->type, "JTAGICE3")) { msg_error(" -x jtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n"); - msg_error(" UB/UA = units before/after, BB/BA = bits before/after\n"); + msg_error(" UB/UA = units before/after, BB/BA = bits before/after\n"); + } if(lsize(pgm->hvupdi_support) > 1) msg_error(" -x hvupdi Enable high-voltage UPDI initialization\n"); if(pgm->extra_features & HAS_SUFFER) { From a874b521e41a0e906ce49b840b660ad8c33ac135 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 21:27:59 +0200 Subject: [PATCH 388/422] help flag should be false by default --- src/pickit2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pickit2.c b/src/pickit2.c index 5a13c2ad..f2721dcc 100644 --- a/src/pickit2.c +++ b/src/pickit2.c @@ -1145,7 +1145,7 @@ static int pickit2_read_report(const PROGRAMMER *pgm, unsigned char report[65]) static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { int rv = 0; - bool help = true; + bool help = false; for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { From 92a272932e5373436ef3a5b37fc3e06aaaeca3ed Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 29 Jul 2024 21:35:31 +0200 Subject: [PATCH 389/422] help flag should be false by default, again --- src/serprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serprog.c b/src/serprog.c index 70445d84..a3767b5d 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -463,7 +463,7 @@ static int serprog_get_sck_period(const PROGRAMMER *pgm, double *v) { static int serprog_parseextparams(const PROGRAMMER *pgm, const LISTID extparms) { int rv = 0; - bool help = true; + bool help = false; for(LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { const char *extended_param = ldata(ln); From d97d05790b792cb391c5b18928217c332e82982a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 30 Jul 2024 00:38:06 +0100 Subject: [PATCH 390/422] Document terminal disasm command --- src/avrdude.1 | 101 ++++++++++++++- src/doc/avrdude.texi | 286 +++++++++++++++++++++++++++++++++++++++---- src/term.c | 22 ++-- 3 files changed, 371 insertions(+), 38 deletions(-) diff --git a/src/avrdude.1 b/src/avrdude.1 index 2f43e8af..882a3044 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -1137,10 +1137,10 @@ The .Ar addr and .Ar len -parameters of the dump, read, write, save and erase commands can be +parameters of the dump, read, disasm, write, save and erase commands can be negative with the same syntax as substring computations in perl or python. The table below details their meaning with respect to an example memory of size -sz=0x800. +sz=0x800 (2048 bytes). .Pp .nf addr len Memory interval Comment @@ -1187,6 +1187,103 @@ and display them (deprecated: use dump memory addr -1). Read all bytes from the specified memory, and display them (deprecated: use dump memory 0 -1). .It Ar read Can be used as an alias for dump. +.It Ar disasm [opts] [arguments] +Like dump, the disasm command displays a part of the specified memory, +albeit by interpreting the memory contents as AVR opcodes and showing it +as assembler source code. Unlike dump, the disasm command has options; +these control how disasm displays its result (see below). Other than that, +the syntax of specifying the memory and its to be processed interval is +virtually the same as that of dump: the default disasm length is 32 bytes, +though, and sometimes the length can be slightly shorter or longer than +requested, so that the memory section for disasm aligns with opcodes. +Disasm options, once set, stay in force until switched off, typically by +changing the case of the option. This way, a simple disasm without further +options can be used to step through memory keeping the appearance. Disasm +knows the following options: +.Bl -tag -offset indent -width indent +.It -g +Generate avr-gcc source: this sets -sOFQ and outputs a .text preamble and +a main symbol unless the disassembly emits one itself; -G (the default) +switches off -g and stops outputting a preamble +.It -A +Do not show addresses; -a (the default) shows addresses +.It -O +Do not show opcode bytes; -o (the default) show opcode bytes +.It -C +Do not show comments; -c (the default) show comments +.It -f +Show affected flags in SREG, eg, ---SVNZC for the sbiw opcode; -F (the +default) do not show SREG flags +.It -q +Show the number of machine cycles that an opcode takes; -Q (the default) +do not show the cycles +.It -n +Put the opcode full name into comment, eg, subtract immediate from word +for the sbiw opcode; -N (the default) do not show the full opcode names +.It -e +Put a technical explanation of the opcode into the comment, eg, Rd+1:Rd +<-- Rd+1:Rd - K for the sbiw opcode; -E (the default) do not show +technical explanations +.It -S +Use AVR instruction set style: this means that register pairs are shown +as, eg, in r31:30 instead of r30; -s (the default) use avr-gcc code style +.It -L +Do not preprocess labels; -l (the default) preprocess jump/call labels +.It -d +Decode all opcodes including those that are undocumented; -D (the default) +decode only opcodes that are valid for the part +.It -z +Zap the list of jumps and calls before disassembly +.It -t= +Delete symbols from a previously read tagfile, if any, and read the tagfile + for assigning addresses to symbol names +.El +The tagfile is an ASCII file where each line describes a symbol for code +label addresses (L), variable addresses in flash (P) and variables +addresses in memory or I/O space (M). Hashmarks start a tagfile comment +that extends to the end of the line and is ignored by disasm. Here is a +defining example of how a tagfile looks like +.nf +--------------------------------------------------------------- +0x7f54 L putch Outputs a char # L are code labels +0x7ffe P W 1 version16 A word integer # P are PGM data +0x7f80 P A 4 headings Column headers # Auto-aligned strings +0x0100 M B 2048 sram 2 kB SRAM # Memory address +--------------------------------------------------------------- +.fi +Code labels L can be, eg, function names in program space or goto labels. +They use up to four columns separated by white space: the address, the +letter L, the symbolic name of the label and an optional comment column +for the symbol, which is copied by disasm into the disassembly comment +column, should this label be referenced or used by the code. Variable +symbols have a P or M in the second column; they can be bytes or words as +determined by the letter B or W in the third column and either single +variables or arrays as specified by the multiplicity count in the forth +column. P symbols, but not M symbols, can also be the base location of +nul-terminated strings as encoded by A or S in the third column. Out of +necessity, the space occupied by A/S strings varies. The difference +between A and S symbols is that the array of A strings might have an +additional nul character to auto-align the space occupied by them to an +even address. The fifth column is the symbolic name for the P or M address +that can be used by disasm to output relevant addresses symbolically. P +areas described in the tagfile also tell disasm that the corresponding +area is not code and should not be disassembled as such; instead the +.byte, .word, .asciz and sometimes at the end of the memory section .ascii +directives are used for disassembly of that area. As with L labels, P and +M variables may have an optional final comment column pertaining to the +symbol that may be output in the disassembly column as and when the +corresponding variables are used. +.Pp +Tagfiles are useful for disassembly to make the output of disasm more +readable. They can be built manually and incrementally as one's +understanding of the code grows. Alternatively, the bash shell script +tools/elf2tag that resides in the AVRDUDE repository can automatically +generate a tag file from the .elf file that produced the flash contents: +.Pp +$ tools/elftag file.elf >file.tag +.Pp +elf2tag uses the avr-objdump -d disassembly to create L labels and avr-nm +to generate M symbols. .It Ar write memory addr data[,] {data[,]} Manually program the respective memory cells, starting at address .Ar addr , diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 1bf00c72..e457faee 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -2269,10 +2269,10 @@ abbreviated to the shortest unambiguous form. Terminal mode provides a command history using readline(3), so previously entered command lines can be recalled and edited. -The @var{addr} and @var{len} parameters of the dump, read, write, save and erase -commands can be negative with the same syntax as substring computations in -perl or python. The table below details their meaning with respect to an -example memory of size @code{sz=0x800}. +The @var{addr} and @var{len} parameters of the dump, read, disasm, write, +save and erase commands can be negative with the same syntax as substring +computations in perl or python. The table below details their meaning with +respect to an example memory of size @code{sz=0x800} (2048 bytes). @multitable {0/negativ}{negativ}{@code{[addr, addr+len-1]}}{End is @code{|len|} bytes below memory size @code{sz}} @headitem @code{addr} @@ -2348,27 +2348,169 @@ The following commands are implemented for all programmers: @table @code @item dump @var{memory} @var{addr} @var{len} -Read from the specified memory interval (see above), and display in the usual hexadecimal and -ASCII form. +@cindex @code{dump} @var{[memory [addr [len]]]} +Read from the specified memory interval (see above), and display in the +usual hexadecimal and ASCII form. @item dump @var{memory} @var{addr} -Read from memory addr as many bytes as the most recent dump memory addr len command with this -very memory had specified (default 256 bytes), and display them. +@cindex @code{dump} @var{[memory [addr [len]]]} +Read from memory addr as many bytes as the most recent dump memory addr +len command with this very memory had specified (default 256 bytes), and +display them. @item dump @var{memory} -Continue dumping from the memory and location where the most recent dump command left off; if no -previous dump command has addressed a memory an error message will be shown. +@cindex @code{dump} @var{[memory [addr [len]]]} +Continue dumping from the memory and location where the most recent dump +command left off; if no previous dump command has addressed a memory an +error message will be shown. + +@item dump +@cindex @code{dump} @var{[memory [addr [len]]]} +Continue dumping from the memory and location where the most recent dump +command left off; if no previous dump command has addressed a memory an +error message will be shown. @item dump @var{memory} @var{addr} @dots{} -Start reading from @var{addr}, all the way to the last memory address (deprecated: use @code{dump @var{memory} @var{addr} -1}). +@cindex @code{dump} @var{memory} @var{[addr]} @dots{} @w{ } @w{ } @w{ } +Start reading from @var{addr}, all the way to the last memory address +(deprecated: use @code{dump @var{memory} @var{addr} -1}). @item dump @var{memory} @dots{} -Read all bytes from the specified memory, and display them (deprecated: use @code{dump @var{memory} 0 -1}). +@cindex @code{dump} @var{memory} @var{[addr]} @dots{} @w{ } @w{ } @w{ } +Read all bytes from the specified memory, and display them (deprecated: +use @code{dump @var{memory} 0 -1}). @item read +@cindex @code{read} @var{[memory [addr [len]]]} +@cindex @code{read} @var{memory} @var{[addr]} @dots{} @w{ } @w{ } @w{ } Can be used as an alias for dump. +@item disasm @var{[options]} @var{dump-arguments} +@cindex @code{disasm} @var{[memory [addr [len]]]} +Like dump, the disasm command displays a part of the specified memory, +albeit by interpreting the memory contents as AVR opcodes and showing it +as assembler source code. Unlike dump, the disasm command has options; +these control how disasm displays its result (see below). Other than that, +the syntax of specifying the memory and its to be processed interval is +virtually the same as that of dump: the default disasm length is 32 bytes, +though, and sometimes the length can be slightly shorter or longer than +requested, so that the memory section for disasm aligns with opcodes. +Disasm options, once set, stay in force until switched off, typically by +changing the case of the option. This way, a simple disasm without further +options can be used to step through memory keeping the appearance. Disasm +knows the following options: +@table @code + +@item -g +Generate avr-gcc source: this sets @code{-sOFQ} and outputs a .text preamble and +a main symbol unless the disassembly emits one itself; @code{-G} (default) +switches off @code{-g} and stops outputting a preamble + +@item -A +Do not show addresses; @code{-a} (the default) shows addresses + +@item -O +Do not show opcode bytes; @code{-o} (the default) show opcode bytes + +@item -C +Do not show comments; @code{-c} (the default) show comments + +@item -f +Show affected flags in SREG, eg, @code{---SVNZC} for the @code{sbiw} +opcode; @code{-F} (the default) do not show SREG flags + +@item -q +Show the number of machine cycles that an opcode takes; @code{-Q} +(the default) do not show the cycles + +@item -n +Put the opcode full name into comment (eg, subtract immediate from word); +@code{-N} (the default) do not show the full opcode names + +@item -e +Put a technical explanation of the opcode into the comment, eg, +@code{Rd+1:Rd <-- Rd+1:Rd - K} for the @code{sbiw} opcode; -E (the +default) do not show technical explanations + +@item -S +Use AVR instruction set style: this means that register pairs are shown +as, eg, in r31:30 instead of r30; @code{-s} (the default) use avr-gcc code +style + +@item -L +Do not preprocess labels; @code{-l} (the default) preprocess jump/call +labels + +@item -d +Decode all opcodes including those that are undocumented; @code{-D} (the +default) decode only opcodes that are valid for the part + +@item -z +Zap the list of jumps and calls before disassembly + +@item -t=@var{file} +@cindex tagfile +Delete symbols from a previously read tagfile, if any, and read the +tagfile @var{file} for assigning addresses to symbol names. +@end table + +The tagfile is an ASCII file where each line describes a symbol for code +label addresses (@code{L}), variable addresses in flash (@code{P}) and +variables addresses in memory or I/O space (@code{M}). Hashmarks start a +tagfile comment that extends to the end of the line and is ignored by +disasm. Here is a defining example of how a tagfile looks like + +@smallexample +@cartouche +0x7f54 L putch Outputs a char # L are code labels +0x7ffe P W 1 version16 A word integer # P are PGM data +0x7f80 P A 4 headings Column headers # Auto-aligned strings +0x0100 M B 2048 sram 2 kB SRAM # Memory address +@end cartouche +@end smallexample + +Code labels @code{L} can be, eg, function names in program space or goto +labels. They use up to four columns separated by white space: the +address, the letter @code{L}, the symbolic name of the label and an +optional comment column for the symbol, which is copied by disasm into the +disassembly comment column, should this label be referenced or used by the +code. Variable symbols have a @code{P} or @code{M} in the second column; +they can be bytes or words as determined by the letter @code{B} or +@code{W} in the third column and either single variables or arrays as +specified by the multiplicity count in the forth column. @code{P} symbols, +but not @code{M} symbols, can also be the base location of nul-terminated +strings as encoded by @code{A} or @code{S} in the third column. Out of +necessity, the space occupied by @code{A}/@code{S} strings varies. The +difference between @code{A} and @code{S} symbols is that the array of +@code{A} strings might have an additional nul character to auto-align the +space occupied by them to an even address. The fifth column is the +symbolic name for the @code{P} or @code{M} address that can be used by +disasm to output relevant addresses symbolically. @code{P} areas described +in the tagfile also tell disasm that the corresponding area is not code +and should not be disassembled as such; instead the directives are used +for disassembly of that area. As with @code{L} labels, @code{P} and +@code{M} variables may have an optional final comment column pertaining to +the symbol that may be output in the disassembly column as and when the +corresponding variables are used. + +Tagfiles are useful for disassembly to make the output of disasm more +readable. They can be built manually and incrementally as one's under‐ +standing of the code grows. Alternatively, the bash shell script +@code{tools/elf2tag} that resides in the AVRDUDE repository can +automatically gen‐ erate a tag file from the .elf file that produced the +flash contents: + +@smallexample +@cartouche +$ tools/elf2tag application.elf >application.tag +@end cartouche +@end smallexample + +@code{elf2tag} uses the @code{avr-objdump -d} disassembly to create +@code{L} labels and @code{avr-nm} to generate @code{M} symbols. + @item write @var{memory} @var{addr} @var{data[,]} @var{@{data[,]@}} +@cindex @code{write} @var{memory} @var{addr} @var{data[,]} @var{@{data[,]@}} Manually program the respective memory cells, starting at address @var{addr}, using the data items provided. The terminal implements reading from and writing to flash, EEPROM, bootrow and usersig type memories normally @@ -2490,16 +2632,19 @@ One trailing comma at the end of data items is ignored to facilitate copy and paste of lists. @item write @var{memory} @var{addr} @var{data} +@cindex @code{write} @var{memory} @var{addr} @var{data} The start address @code{addr} may be omitted if the size of the memory being written to is one byte. @item write @var{memory} @var{addr} @var{len} @var{data[,]} @var{@{data[,]@}} @dots{} +@cindex @code{write} @var{memory} @var{addr} @var{len} @var{data[,]} @var{@{data[,]@}} @dots{} @w{ } The ellipsis @dots{} form writes the data to the entire memory intervall addressed by @var{addr len} and, if necessary, pads the remaining space by repeating the last data item. The fill write command does not write beyond the specified memory area even if more data than needed were given. @item save @var{memory} @var{@{addr len@}} @var{file[:format]} +@cindex @code{save} @var{memory} @var{@{addr len@}} @var{file[:format]} Save one or more memory segments to a file in a format specified by the @code{:}format letter. The default is @code{:r} for raw binary. Each memory segment is described by an address and length pair. In absence of @@ -2511,6 +2656,7 @@ and concatenate the chosen memory segments into the output file. If the file name is - then avrdude writes to stdout. @item backup @var{memlist} @var{file[:format]} +@cindex @code{backup} @var{memlist} @var{file[:format]} Backup one or more memories to the specified file using the selected format. The default format for a single-memory backup is @code{:r} (raw binary); for multi-memory backups it is @code{:I} (Intel Hex with @@ -2519,6 +2665,7 @@ in the @code{-U} command line argument. @code{backup} flushes the cache before reading memories. @item restore @var{memlist} @var{file[:format]} +@cindex @code{restore} @var{memlist} @var{file[:format]} Restore one or more memories from the specified file. It is the user's responsibility to erase memories as needed beforehand: some paged memories look like NOR-memory when using certain programmers, meaning programming @@ -2533,22 +2680,27 @@ memories verifies file contents with the corresponding microprocessor's memories. @item verify @var{memlist} @var{file[:format]} +@cindex @code{verify} @var{memlist} @var{file[:format]} Compare one or more memories with the specified file. Memlist can be a comma separated list of memories just as in the @code{-U} command line argument. @code{verify} flushes the cache before verifying memories. @item erase +@cindex @code{erase} Perform a chip erase and discard all pending writes to flash, EEPROM and bootrow. Note that EEPROM will be preserved if the EESAVE fuse bit is active, ie, had a corresponding value at the last reset prior to the operation. @item erase @var{memory} +@cindex @code{erase} @var{memory} @var{[addr len]} Erase the entire specified memory. @item erase @var{memory} @var{addr} @var{len} +@cindex @code{erase} @var{memory} @var{[addr len]} Erase a section of the specified memory. @item flush +@cindex @code{flush} Synchronise with the device all pending writes to flash, EEPROM, bootrow and usersig. With some programmer and part combinations, flash (and sometimes EEPROM, too) looks like a NOR memory, i.e., a write can only clear bits, @@ -2563,13 +2715,15 @@ a single previously cleared bit is set and, therefore, this routine should be called sparingly. @item abort +@cindex @code{abort} Normally, caches are only ever actually written to the device when using @code{flush}, at the end of the terminal session after typing @code{quit}, or after EOF on input is encountered. The @code{abort} command resets the cache discarding all previous writes to the flash, EEPROM, bootrow and usersig cache. -@item config [@var{opts}] +@item config @var{[opts]} +@cindex @code{config} @var{[opts]} Show all configuration properties of the part; these are usually bitfields in fuses or lock bits bytes that can take on values, which typically have a mnemonic name. Each part has their own set of configurable items. The @@ -2581,17 +2735,20 @@ assigned mnemonic values are the ones that are not commented out. The option @code{-v} increases the verbosity of the output of the config command. -@item config [@var{opts}] @var{property} [@var{opts}] +@item config @var{[opts]} @var{property} @var{[opts]} +@cindex @code{config} @var{[opts]} @var{property} @var{[opts]} Show the current value of the named configuration property. Wildcards or initial strings are permitted (but not both), in which case the current values of all matching properties are displayed. -@item config [@var{opts}] @var{property=} [@var{opts}] +@item config @var{[opts]} @var{property=} @var{[opts]} +@cindex @code{config} @var{[opts]} @var{property=} @var{[opts]} Show all possible values of the named configuration property (notice the trailing @code{=}). The one that is currently set is the only one not commented out. As before, wildcards or initial strings are permitted. -@item config [@var{opts}] @var{property=value} [@var{opts}] +@item config @var{[opts]} @var{property=value} @var{[opts]} +@cindex @code{config} @var{[opts]} @var{property=value} @var{[opts]} Modify the named configuration property to the given value. The corresponding fuse or lock bits will be changed immediately but the change will normally only take effect the next time the part is reset, at which @@ -2606,6 +2763,7 @@ and lock bits, to brick a part, i.e., make it unresponsive to further programming with the chosen programmer: here be dragons. @item factory reset +@cindex @code{factory reset} Resets the connected part to factory state as far as possible (bootloaders, for example, cannot write fuses and may not have a means to erase EEPROM). This command may change the clock frequency F_CPU of the @@ -2615,7 +2773,8 @@ different bit clock rate up to F_CPU/4 for the programmer next time. Note that the command @code{factory} can be abbreviated but the required argument @code{reset} needs to be spelled out in full. -@item regfile [@var{opts}] +@item regfile @var{[opts]} +@cindex @code{regfile} @var{[opts]} @code{regfile} with no further argument displays the register file of a part, i.e., all register names and their contents in @code{io} memory, if possible: note that external programming cannot read the registers of @@ -2627,8 +2786,8 @@ Option @code{-a} displays the register I/O addresses in addition; @code{-s} also shows the size of the register in bytes whilst @code{-v} shows a slightly expanded register explanation alongside each register. -@item regfile [@var{opts}] @var{reg} [@var{opts}] - +@item regfile @var{[opts]} @var{reg} @var{[opts]} +@cindex @code{regfile} @var{[opts]} @var{reg} @var{[opts]} @code{regfile} together with a register name @var{reg} shows all those registers that are matched by @var{reg}. Wildcards or partial strings are permitted but not both. Register names have the form @var{module.name} or @@ -2641,13 +2800,15 @@ utilised and all module registers with that exact @var{instance.name} or @var{name} are shown. Partial matching can be forced through use of wildcards, e.g., using @code{porta.out*} -@item regfile [@var{opts}] @var{reg}=@var{value} [@var{opts}] +@item regfile @var{[opts]} @var{reg}=@var{value} @var{[opts]} +@cindex @code{regfile} @var{[opts]} @var{reg}=@var{value} @var{[opts]} This sets a single register addressed by @var{reg} to the given @var{value}. Only external programming of modern parts (those with UPDI interface) can read from and write to register io memory, but as that memory is volatile, the contents will be lost after reset. -@item include [@var{opts}] @var{file} +@item include @var{[opts]} @var{file} +@cindex @code{include} @var{[opts]} @var{file} Include contents of the named file @var{file} as if it was typed. This is useful for batch scripts, e.g., recurring initialisation code for fuses. The include option @code{-e} prints the lines of the file as comments before @@ -2655,20 +2816,24 @@ processing them; on a non-zero verbosity level the line numbers are printed, too. @item signature +@cindex @code{signature} Display the device signature bytes. -@item part +@item part @var{[opts]} +@cindex @code{part} @var{[opts]} Display the current part information, including supported programming modes, memory and variants tables. Use @var{-m} to only print the memory table, and @var{-v} to only print the variants table. -@item verbose [@var{level}] +@item verbose @var{]level]} +@cindex @code{verbose} @var{]level]} Change (when @var{level} is provided), or display the verbosity level. The initial verbosity level is controlled by the number of @code{-v} options given on the command line. -@item quell [@var{level}] +@item quell @var{[level]} +@cindex @code{quell} @var{[level]} Change (when @var{level} is provided), or display the quell level. 1 is used to suppress progress reports. 2 or higher yields progressively quieter operations. The initial quell level is controlled @@ -2679,12 +2844,14 @@ by the number of @code{-q} options given on the command line. Give a short on-line summary of the available commands. @item quit +@cindex @code{quit} Leave terminal mode and thus AVRDUDE. @item q Can be used as an alias for @code{quit}. @item !@var{line} +@cindex @code{!} (subshell) Run the shell @var{line} in a subshell, e.g., @code{!ls *.hex}. Subshell commands take the rest of the line as their command. For security reasons, they must be enabled explictly by putting @code{allow_subshells = yes;} @@ -2702,9 +2869,11 @@ In addition, the following commands are supported on some programmers: @table @code @item pgerase @var{memory} @var{addr} +@cindex @code{pgerase} @var{memory} @var{addr} Erase one page of the memory specified. @item send @var{b1} @var{b2} @var{b3} @var{b4} +@cindex @code{send} @var{b1} @var{b2} @var{b3} @var{b4} Send raw instruction codes to the AVR device. If you need access to a feature of an AVR part that is not directly supported by AVRDUDE, this command allows you to use it, even though AVRDUDE does not implement the @@ -2712,18 +2881,22 @@ command. When using direct SPI mode, up to 3 bytes can be omitted. @item spi +@cindex @code{spi} Enter direct SPI mode. The @emph{pgmled} pin acts as chip select. @emph{Only supported on parallel bitbang programmers, and partially by USBtiny.} Chip Select must be externally held low for direct SPI when using USBtinyISP, and send must be a multiple of four bytes. @item pgm +@cindex @code{pgm} Return to programming mode (from direct SPI mode). @item vtarg @var{voltage} +@cindex @code{vtarg} @var{voltage} Set the target's supply voltage to @var{voltage} Volts. -@item varef [@var{channel}] @var{voltage} +@item varef @var{[channel]} @var{voltage} +@cindex @code{varef} @var{[channel]} @var{voltage} Set the adjustable voltage source to @var{voltage} Volts. This voltage is normally used to drive the target's @emph{Aref} input on the STK500 and STK600. @@ -2732,20 +2905,24 @@ selected by the optional parameter @var{channel} (either 0 or 1). @item fosc @var{freq}[@code{M}|@code{k}] +@cindex @code{fosc} @var{freq}[@code{M}|@code{k}] Set the programming oscillator to @var{freq} Hz. An optional trailing letter @code{M} multiplies by 1E6, a trailing letter @code{k} by 1E3. @item fosc off +@cindex @code{fosc off} Turn the programming oscillator off. @item sck @var{period} +@cindex @code{sck} @var{period} Set the SCK clock period to @var{period} microseconds. Note that some official Microchip programmers store the bitclock setting and will continue to use it until a diferent value is provided. See @code{-B bitclock} for more information. @item parms +@cindex @code{parms} Display programmer specific parameters. @end table @@ -3057,6 +3234,65 @@ avrdude done. Thank you. @page +@cindex @code{disasm} example + +@noindent @strong{Disassembe the flash contents of an ATtiny13A,} write +the output to file @code{blink.S}, compile to `blink.elf` and verify that +the flash contents of the ATtiny13A is the same as the one given by the +compiled @code{blink.elf}. Then @code{cat} the disassembled @code{blink.S} +to stdout. + +@smallexample +@cartouche + +$ avrdude -qq -p t13a -c avrisp2 -T "disasm -g flash 0 -1" >blink.S +$ avr-gcc -mmcu=attiny13a -nostdlib -Wl,--section-start=.text=0x0000 blink.S -o bl.elf +$ avrdude -qq -p t13a -c avrisp2 -U flash:v:bl.elf && echo OK +OK + +$ cat blink.S + + .equ io.pinb, 0x16 + .equ io.ddrb, 0x17 + + .text +main: +L000: rjmp Label1 ; L016 +L002: rjmp Label0 ; L014 +L004: rjmp Label0 ; L014 +L006: rjmp Label0 ; L014 +L008: rjmp Label0 ; L014 +L00a: rjmp Label0 ; L014 +L00c: rjmp Label0 ; L014 +L00e: rjmp Label0 ; L014 +L010: rjmp Label0 ; L014 +L012: rjmp .+0 ; L014 + +; Rjmp from L002, L004, L006, L008, L00a, L00c, L00e, L010 +Label0: +L014: reti + +Label1: ; Rjmp from L000 +L016: sbi io.ddrb, 2 ; Bit 2 = 0x04 + +Label2: ; Rjmp from L024 +L018: ldi r29, 0x1e ; 30 + +Label3: ; Brne from L01c, L020 +L01a: sbiw r30, 0x01 ; 1 +L01c: brne Label3 ; L01a +L01e: dec r29 +L020: brne Label3 ; L01a +L022: sbi io.pinb, 2 ; Bit 2 = 0x04 +L024: rjmp Label2 ; L018 + +L026: .fill 493, 2, 0xffff + +@end cartouche +@end smallexample + +@page + @noindent @strong{Mixing terminal commands and @code{-U} memory operations:} the example below burns a bootloader, uses a terminal line to write diff --git a/src/term.c b/src/term.c index 96f00ebb..93886650 100644 --- a/src/term.c +++ b/src/term.c @@ -269,16 +269,16 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, ); if(is_disasm) { struct { char ochr[2]; const char *info[2]; } opts[] = { - {{'g', 'G'}, {"generate avr-gcc source: sets -sOFQ", "don't create gcc source"}}, - {{'a', 'A'}, {"show addresses", "don't show addresses"}}, - {{'o', 'O'}, {"show opcode bytes", "don't show opcode bytes"}}, - {{'c', 'C'}, {"show comments", "don't show comments"}}, - {{'f', 'F'}, {"show affected flags in SREG", "don't show SREG flags"}}, - {{'q', 'Q'}, {"show cycles", "don't show cycles"}}, - {{'n', 'N'}, {"put opcode full name into comment", "don't show full name"}}, - {{'e', 'E'}, {"put explanation into comment", "don't show explanation"}}, + {{'g', 'G'}, {"generate avr-gcc source: sets -sOFQ", "do not create gcc source"}}, + {{'a', 'A'}, {"show addresses", "do not show addresses"}}, + {{'o', 'O'}, {"show opcode bytes", "do not show opcode bytes"}}, + {{'c', 'C'}, {"show comments", "do not show comments"}}, + {{'f', 'F'}, {"show affected flags in SREG", "do not show SREG flags"}}, + {{'q', 'Q'}, {"show cycles", "do not show cycles"}}, + {{'n', 'N'}, {"put opcode full name into comment", "do not show full names"}}, + {{'e', 'E'}, {"put explanation into comment", "do not show explanation"}}, {{'s', 'S'}, {"use avr-gcc code style", "use AVR instruction set style"}}, - {{'l', 'L'}, {"preprocess jump/call labels", "don't preprocess labels"}}, + {{'l', 'L'}, {"preprocess jump/call labels", "do not preprocess labels"}}, {{'d', 'D'}, {"decode all opcodes", "decode only opcodes for the part"}}, }; @@ -288,8 +288,8 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc, msg_error(" -%c %s, -%c %s\n", opts[i].ochr[on], opts[i].info[on], opts[i].ochr[!on], opts[i].info[!on]); } msg_error( - " -z zap list of jumps/calls before disassembly\n" - " -t= set the tagfile (zaps old tagfile contents)\n" + " -z zap the list of jumps and calls before disassembly\n" + " -t= drop symbols from a previous tagfile and initialise them anew\n" ); } msg_error("\n" From 3d46a0cd77e395a883f5b20d11f36d9db514e5f8 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 30 Jul 2024 00:45:45 +0100 Subject: [PATCH 391/422] Check in elf2tag whether needed commands are installed --- tools/elf2tag | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/elf2tag b/tools/elf2tag index a0d27715..28dde7b8 100755 --- a/tools/elf2tag +++ b/tools/elf2tag @@ -1,14 +1,19 @@ #!/usr/bin/env bash +# Part of the AVRDUDE project https://github.com/avrdudes/avrdude # Published under GNU General Public License, version 2 (GPL-2.0) # Copyright (C) 2007 Johannes Bauer # Copyright (C) 2024 Small modifications by Stefan Rueger progname=$(basename "$0") +for pgm in sort grep awk avr-objdump avr-nm; do + hash $pgm 2>/dev/null || { echo "$progname: $pgm does not seem to be installed, exiting"; exit 1; } +done + if [ "$1" == "" ]; then cat <.elf -Function: output a tag file suitable for the terminal disasm -t= command +Function: output a tagfile suitable for the avrdude disasm -t= command Options: none END exit 1 From 137ece466b6f6887e8106e5453730814309da78c Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 30 Jul 2024 13:17:46 +0100 Subject: [PATCH 392/422] Move tools/elf2tag -> src/elf2tag --- {tools => src}/elf2tag | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {tools => src}/elf2tag (100%) diff --git a/tools/elf2tag b/src/elf2tag similarity index 100% rename from tools/elf2tag rename to src/elf2tag From 823118c0ba81c35b81923b4bade45c3598645301 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 31 Jul 2024 16:07:53 +0100 Subject: [PATCH 393/422] Make main avrdude run less verbose --- src/avrdude.conf.in | 2 +- src/jtagmkII.c | 6 ++--- src/libavrdude.h | 1 + src/main.c | 59 +++++++++++++++++++++++---------------------- src/strutil.c | 11 +++++++++ 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 8495e72d..96fd5227 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -924,7 +924,7 @@ programmer # dryrun programmer # dryboot id = "dryboot"; - desc = "Emulates bootloader programming without a programmer"; + desc = "Emulates bootloader programming without the part"; type = "dryrun"; prog_modes = PM_SPM; ; diff --git a/src/jtagmkII.c b/src/jtagmkII.c index be97b147..5b9ea3f3 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -3006,11 +3006,9 @@ static int jtagmkII_initialize32(const PROGRAMMER *pgm, const AVRPART *p) { resp[3] != p->signature[1] || resp[4] != p->signature[2]) { if (ovsigck) { - pmsg_warning("expected signature for %s is %02X %02X %02X\n", p->desc, - p->signature[0], p->signature[1], p->signature[2]); + pmsg_warning("expected signature for %s is%s\n", p->desc, str_cchex(p->signature, 3, 1)); } else { - pmsg_error("expected signature for %s is %02X %02X %02X\n", p->desc, - p->signature[0], p->signature[1], p->signature[2]); + pmsg_error("expected signature for %s is%s\n", p->desc, str_cchex(p->signature, 3, 1)); imsg_error("double check chip or use -F to override this check\n"); return -1; } diff --git a/src/libavrdude.h b/src/libavrdude.h index e0d2d5c0..d5c38ad6 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1523,6 +1523,7 @@ unsigned long long int str_int(const char *str, int type, const char **errpp); int str_membuf(const char *str, int type, unsigned char *buf, int size, const char **errpp); char *str_nexttok(char *buf, const char *delim, char **next); const char *str_ccfrq(double f, int n); +const char *str_cchex(const void *buf, size_t len, int add_space); int str_levenshtein(const char *str1, const char *str2, int swap, int subst, int add, int del); size_t str_weighted_damerau_levenshtein(const char *str1, const char *str2); int str_mcunames_signature(const unsigned char *sigs, int pm, char *p, size_t n); diff --git a/src/main.c b/src/main.c index 4555d342..bb164b4e 100644 --- a/src/main.c +++ b/src/main.c @@ -1299,7 +1299,7 @@ int main(int argc, char * argv []) } } - int is_dryrun = str_eq(pgmid, "dryrun") || (dry && pgm->initpgm == dry->initpgm); + int is_dryrun = str_eq(pgm->type, "dryrun") || (dry && pgm->initpgm == dry->initpgm); if((port[0] == 0 || str_eq(port, "unknown")) && !is_dryrun) { msg_error("\n"); pmsg_error("no port has been specified on the command line or in the config file\n"); @@ -1500,7 +1500,7 @@ skipopen: pmsg_error("programmer does not support RC oscillator calibration\n"); exitrc = 1; } else { - pmsg_info("performing RC oscillator calibration\n"); + pmsg_notice("performing RC oscillator calibration\n"); exitrc = pgm->perform_osccal(pgm); } if (exitrc == 0) @@ -1557,7 +1557,7 @@ skipopen: // Indicate programmer is ready led_set(pgm, LED_RDY); - pmsg_info("AVR device initialized and ready to accept instructions\n"); + pmsg_notice("AVR device initialized and ready to accept instructions\n"); /* * Let's read the signature bytes to make sure there is at least a @@ -1585,16 +1585,18 @@ skipopen: char sib[AVR_SIBLEN + 1]; pgm->read_sib(pgm, p, sib); pmsg_notice("System Information Block: %s\n", sib); - pmsg_info("received FamilyID: \"%.*s\"\n", AVR_FAMILYIDLEN, sib); - if (strncmp(p->family_id, sib, AVR_FAMILYIDLEN)) - pmsg_error("expected FamilyID: \"%s\"\n", p->family_id); + if (strncmp(p->family_id, sib, AVR_FAMILYIDLEN)) { + pmsg_warning("received FamilyID: \"%.*s\"\n", AVR_FAMILYIDLEN, sib); + imsg_warning("expected FamilyID: \"%s\"\n", p->family_id); + } else + pmsg_notice("received FamilyID: \"%.*s\"\n", AVR_FAMILYIDLEN, sib); } if(erase) { erase = 0; if (uflags & UF_NOWRITE) { pmsg_warning("conflicting -e and -n options specified, NOT erasing chip\n"); } else { - pmsg_info("trying to unlock the chip\n"); + pmsg_notice("trying to unlock the chip\n"); exitrc = avr_unlock(pgm, p); if(exitrc) goto main_exit; @@ -1621,9 +1623,9 @@ skipopen: pmsg_warning("signature memory not defined for device %s\n", p->desc); else { const char *mculist = str_ccmcunames_signature(sig->buf, pgm->prog_modes); - if(!*mculist) { + if(!*mculist) { // No matching signatures? if(p->prog_modes & PM_UPDI) { // UPDI parts have different(!) offsets for signature - int k, n = 0; // Gather list of known different signature offsets + int k, n = 0; // Gather list of known different signature offsets unsigned myoff = sig->offset, offlist[10]; for(LNODEID ln1 = lfirst(part_list); ln1; ln1 = lnext(ln1)) { AVRMEM *m = avr_locate_signature(ldata(ln1)); @@ -1646,19 +1648,19 @@ skipopen: } } - pmsg_info("device signature ="); int ff = 1, zz = 1; for (i=0; isize; i++) { - msg_info(" %02X", sig->buf[i]); if (sig->buf[i] != 0xff) ff = 0; if (sig->buf[i] != 0x00) zz = 0; } - if(*mculist) - msg_info(" (%s)", mculist); - bool signature_matches = sig->size >= 3 && !memcmp(sig->buf, p->signature, 3); + int showsig = !signature_matches || ff || zz || verbose > 0; + if(showsig) + pmsg_info("device signature =%s", str_cchex(sig->buf, sig->size, 1)); + if(*mculist && showsig) + msg_info(" (%s)", is_dryrun? p->desc: mculist); if (ff || zz) { // All three bytes are 0xff or all three bytes are 0x00 if (++attempt < 3) { @@ -1667,26 +1669,22 @@ skipopen: goto sig_again; } msg_info("\n"); - pmsg_error("Yikes! Invalid device signature.\n"); + pmsg_error("invalid device signature%s\n", verbose<1? str_cchex(sig->buf, 3, 1): ""); if (!ovsigck) { - pmsg_error("expected signature for %s is %02X %02X %02X\n", p->desc, - p->signature[0], p->signature[1], p->signature[2]); - imsg_error("Double check connections and try again, or use -F to override\n"); - imsg_error("this check.\n\n"); + imsg_error("expected signature for %s is%s\n", p->desc, str_cchex(p->signature, 3, 1)); + imsg_error("double check connections and try again, or use -F to override this check\n"); exitrc = 1; goto main_exit; } - } else { + } else if(showsig) { msg_info("\n"); } if (!signature_matches) { if (ovsigck) { - pmsg_warning("expected signature for %s is %02X %02X %02X\n", p->desc, - p->signature[0], p->signature[1], p->signature[2]); + pmsg_warning("expected signature for %s is%s\n", p->desc, str_cchex(p->signature, 3, 1)); } else { - pmsg_error("expected signature for %s is %02X %02X %02X\n", p->desc, - p->signature[0], p->signature[1], p->signature[2]); + pmsg_error("expected signature for %s is%s\n", p->desc, str_cchex(p->signature, 3, 1)); imsg_error("double check chip or use -F to override this check\n"); exitrc = 1; goto main_exit; @@ -1701,7 +1699,7 @@ skipopen: upd = ldata(ln); if(upd->memstr && upd->op == DEVICE_WRITE && memlist_contains_flash(upd->memstr, p)) { cx->avr_disableffopt = 1; // Must write full flash file including trailing 0xff - pmsg_info("NOT erasing chip as page erase will be used for new flash%s contents\n", + pmsg_notice("NOT erasing chip as page erase will be used for new flash%s contents\n", avr_locate_bootrow(p)? "/bootrow": ""); imsg_notice("unprogrammed flash contents remains: use -e for an explicit chip-erase\n"); break; @@ -1713,8 +1711,8 @@ skipopen: upd = ldata(ln); if(upd->memstr && upd->op == DEVICE_WRITE && memlist_contains_flash(upd->memstr, p)) { erase = 1; - pmsg_info("Performing a chip erase as flash memory needs programming (-U %s:w:...)\n", upd->memstr); - imsg_notice("specify the -D option to disable this feature\n"); + pmsg_notice("Performing a chip erase as flash memory needs programming (-U %s:w:...)\n", upd->memstr); + imsg_notice2("specify the -D option to disable this feature\n"); } } } @@ -1726,9 +1724,12 @@ skipopen: * before the chip can accept new programming */ if (uflags & UF_NOWRITE) { - pmsg_warning("%s-n specified, NOT erasing chip\n", explicit_e? "conflicting -e and ": ""); + if(explicit_e) + pmsg_warning("conflicting -e and -n specified, NOT erasing chip\n"); + else + pmsg_notice("-n specified, NOT erasing chip\n"); } else { - pmsg_info("erasing chip\n"); + pmsg_notice("erasing chip\n"); exitrc = avr_chip_erase(pgm, p); if(exitrc == LIBAVRDUDE_SOFTFAIL) { imsg_info("delaying chip erase until first -U upload to flash\n"); diff --git a/src/strutil.c b/src/strutil.c index 9fcd158f..f3178a83 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -1141,6 +1141,17 @@ const char *str_ccfrq(double f, int n) { return str_ccprintf("%.*g Hz", n, f); } +// Return an uppercase hex string of max 64 len bytes from binary buffer buf +const char *str_cchex(const void *buf, size_t len, int add_space) { + if(len > 64) // Sanity + len = 64; + int wd = 2 + !!add_space; + char *ret = avr_cc_buffer(wd*len + 1); + for(size_t i=0; i Date: Tue, 30 Jan 2024 20:56:26 +0100 Subject: [PATCH 394/422] Remove obsolete SVN $Id$ tags from source files Remove SVN $Id$ tags from source files which have been made obsolete by moving to git and serve no purpose any more. This mostly removes the matches printed by the command git grep -E '\$[A-Za-z]+\$' The remaining exceptions are some binary files (PDF and font files), and jquery js files with both $Id$ and $Date$ tags. --- NEWS | 2 -- src/Makefile.am | 4 ---- src/arduino.c | 2 -- src/arduino.h | 2 -- src/avr.c | 2 -- src/avr910.c | 2 -- src/avr910.h | 2 -- src/avrcache.c | 2 -- src/avrdude.1 | 2 -- src/avrdude.conf.in | 4 +--- src/avrdude.h | 2 -- src/avrdude.spec.in | 2 -- src/avrftdi.c | 1 - src/avrftdi.h | 2 -- src/avrpart.c | 2 -- src/bitbang.c | 1 - src/bitbang.h | 1 - src/buspirate.c | 2 -- src/buspirate.h | 2 -- src/butterfly.c | 2 -- src/butterfly.h | 2 -- src/config.c | 2 -- src/config.h | 2 -- src/config_gram.y | 1 - src/configure.ac | 4 ---- src/developer_opts.c | 2 -- src/dfu.c | 2 -- src/dfu.h | 2 -- src/doc/Makefile.am | 4 ---- src/doc/avrdude.texi | 2 -- src/dryrun.c | 2 -- src/dryrun.h | 2 -- src/dryrun_private.h | 2 -- src/fileio.c | 2 -- src/flip1.c | 2 -- src/flip1.h | 2 -- src/flip2.c | 2 -- src/flip2.h | 2 -- src/freebsd_ppi.h | 2 -- src/ft245r.c | 2 -- src/jtag3.c | 2 -- src/jtag3.h | 2 -- src/jtag3_private.h | 2 -- src/jtagmkI.c | 2 -- src/jtagmkI.h | 2 -- src/jtagmkII.c | 2 -- src/jtagmkII.h | 2 -- src/jtagmkII_private.h | 2 -- src/jtagmkI_private.h | 2 -- src/lexer.l | 2 -- src/libavrdude.h | 2 -- src/linux_ppdev.h | 2 -- src/lists.c | 2 -- src/main.c | 2 -- src/par.c | 2 -- src/par.h | 2 -- src/pgm.c | 2 -- src/ppi.c | 2 -- src/ppi.h | 2 -- src/ppiwin.c | 2 -- src/ser_avrdoper.c | 2 -- src/ser_posix.c | 2 -- src/serbb.h | 1 - src/serbb_posix.c | 1 - src/serbb_win32.c | 1 - src/serialupdi.c | 2 -- src/serialupdi.h | 2 -- src/solaris_ecpp.h | 2 -- src/stk500.c | 2 -- src/stk500.h | 2 -- src/stk500generic.c | 2 -- src/stk500generic.h | 2 -- src/stk500v2.c | 1 - src/stk500v2.h | 2 -- src/term.c | 2 -- src/tpi.h | 2 -- src/update.c | 2 -- src/updi_constants.h | 2 -- src/updi_link.c | 2 -- src/updi_link.h | 2 -- src/updi_nvm.c | 2 -- src/updi_nvm.h | 2 -- src/updi_nvm_v0.c | 2 -- src/updi_nvm_v0.h | 2 -- src/updi_nvm_v2.c | 2 -- src/updi_nvm_v2.h | 2 -- src/updi_nvm_v3.c | 2 -- src/updi_nvm_v3.h | 2 -- src/updi_nvm_v4.c | 2 -- src/updi_nvm_v4.h | 2 -- src/updi_nvm_v5.c | 2 -- src/updi_nvm_v5.h | 2 -- src/updi_readwrite.c | 2 -- src/updi_readwrite.h | 2 -- src/updi_state.c | 2 -- src/updi_state.h | 2 -- src/urclock.c | 2 -- src/urclock.h | 2 -- src/urclock_hash.h | 2 -- src/urclock_private.h | 1 - src/usb_hidapi.c | 2 -- src/usb_libusb.c | 2 -- src/usbasp.c | 2 -- src/usbasp.h | 2 -- src/usbdevs.h | 2 -- src/wiring.c | 2 -- src/wiring.h | 2 -- src/xbee.c | 2 -- src/xbee.h | 2 -- tools/get-dw-params.xsl | 2 -- tools/get-hv-params.xsl | 2 -- tools/get-stk600-cards.xsl | 2 -- tools/get-stk600-devices.xsl | 2 -- 113 files changed, 1 insertion(+), 224 deletions(-) diff --git a/NEWS b/NEWS index 50f039ee..98aa9450 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,3 @@ -$Id$ - Approximate change log for AVRDUDE by version. (For detailed changes, see the version control system logs.) diff --git a/src/Makefile.am b/src/Makefile.am index 9e7a76ad..46ee98e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,10 +26,6 @@ # # make V=1 -# -# $Id$ -# - EXTRA_DIST = \ avrdude.1 \ avrdude.spec \ diff --git a/src/arduino.c b/src/arduino.c index 70072da7..16d56f46 100644 --- a/src/arduino.c +++ b/src/arduino.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for Arduino programmer * diff --git a/src/arduino.h b/src/arduino.h index ce1ff9b8..eed3343d 100644 --- a/src/arduino.h +++ b/src/arduino.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef arduino_h__ #define arduino_h__ diff --git a/src/avr.c b/src/avr.c index fe48def3..453d1b4b 100644 --- a/src/avr.c +++ b/src/avr.c @@ -18,8 +18,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/avr910.c b/src/avr910.c index 2770a04a..95329c04 100644 --- a/src/avr910.c +++ b/src/avr910.c @@ -18,8 +18,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for Atmel Low Cost Serial programmers which adher to the * protocol described in application note avr910. diff --git a/src/avr910.h b/src/avr910.h index f30fa6a3..4a32d218 100644 --- a/src/avr910.h +++ b/src/avr910.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef avr910_h #define avr910_h diff --git a/src/avrcache.c b/src/avrcache.c index dbf49201..c4b7a2db 100644 --- a/src/avrcache.c +++ b/src/avrcache.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/avrdude.1 b/src/avrdude.1 index 2f43e8af..0b81eef2 100644 --- a/src/avrdude.1 +++ b/src/avrdude.1 @@ -17,8 +17,6 @@ .\" along with this program. If not, see . .\" .\" -.\" $Id$ -.\" .Dd January 15, 2023 .Os .Dt AVRDUDE 1 diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 8495e72d..9ef0a575 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -1,6 +1,4 @@ -# $Id$ -*- text -*- -# -# AVRDUDE Configuration File +# AVRDUDE Configuration File -*- text -*- # avrdude_conf_version = "@AVRDUDE_FULL_VERSION@"; diff --git a/src/avrdude.h b/src/avrdude.h index 336690a1..bc3a2c6b 100644 --- a/src/avrdude.h +++ b/src/avrdude.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ - /* $Id$ */ - #ifndef avrdude_h #define avrdude_h diff --git a/src/avrdude.spec.in b/src/avrdude.spec.in index ff9879f6..b1e72e3d 100644 --- a/src/avrdude.spec.in +++ b/src/avrdude.spec.in @@ -1,7 +1,5 @@ ## -*- mode: rpm-spec; -*- ## -## $Id$ -## ## @configure_input@ ## diff --git a/src/avrftdi.c b/src/avrftdi.c index 1a00bf12..490322ed 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -17,7 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ /* * Interface to the MPSSE Engine of FTDI Chips using libftdi. */ diff --git a/src/avrftdi.h b/src/avrftdi.h index 30493271..4e1a7a94 100644 --- a/src/avrftdi.h +++ b/src/avrftdi.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef avrftdi_h #define avrftdi_h diff --git a/src/avrpart.c b/src/avrpart.c index 906a6cbf..78b3f9fa 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -19,8 +19,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include #include diff --git a/src/bitbang.c b/src/bitbang.c index 6c184832..391a875d 100644 --- a/src/bitbang.c +++ b/src/bitbang.c @@ -17,7 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - /* $Id$ */ #include diff --git a/src/bitbang.h b/src/bitbang.h index 1e38afb0..93a401e7 100644 --- a/src/bitbang.h +++ b/src/bitbang.h @@ -17,7 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -/* $Id$ */ #ifndef bitbang_h #define bitbang_h diff --git a/src/buspirate.c b/src/buspirate.c index 8a741570..ec0b57b6 100644 --- a/src/buspirate.c +++ b/src/buspirate.c @@ -33,8 +33,6 @@ * Tested with BusPirate PTH, firmware version 2.1 programming ATmega328P */ -/* $Id$ */ - #include #include diff --git a/src/buspirate.h b/src/buspirate.h index 12a68a1a..3713a472 100644 --- a/src/buspirate.h +++ b/src/buspirate.h @@ -19,8 +19,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef buspirate_h #define buspirate_h diff --git a/src/butterfly.c b/src/butterfly.c index 1337faec..c233eca7 100644 --- a/src/butterfly.c +++ b/src/butterfly.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for the serial programming mode of the Atmel butterfly * evaluation board. This board features a bootloader which uses a protocol diff --git a/src/butterfly.h b/src/butterfly.h index c1492504..3ba48dfe 100644 --- a/src/butterfly.h +++ b/src/butterfly.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef butterfly_h #define butterfly_h diff --git a/src/config.c b/src/config.c index eb7b45a8..2e71cb4a 100644 --- a/src/config.c +++ b/src/config.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/config.h b/src/config.h index 630f9c7a..e91ca5bc 100644 --- a/src/config.h +++ b/src/config.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* These are the internal definitions needed for config parsing */ #ifndef config_h diff --git a/src/config_gram.y b/src/config_gram.y index 11f35b4d..eae57dfd 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -18,7 +18,6 @@ * along with this program. If not, see . */ -/* $Id$ */ %{ #include "ac_cfg.h" diff --git a/src/configure.ac b/src/configure.ac index 0b9a2e85..b1e3102c 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -16,10 +16,6 @@ # along with this program. If not, see . # -# -# $Id$ -# - # Process this file with autoreconf to produce a configure script. dnl A few tool releases with release dates for orientation which tool diff --git a/src/developer_opts.c b/src/developer_opts.c index c47b797a..7ddb1db3 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * Code to program an Atmel AVR device through one of the supported * programmers. diff --git a/src/dfu.c b/src/dfu.c index 5b5e3b72..e206530d 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/dfu.h b/src/dfu.h index d3870b7d..03d2fc46 100644 --- a/src/dfu.h +++ b/src/dfu.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef dfu_h #define dfu_h diff --git a/src/doc/Makefile.am b/src/doc/Makefile.am index 7be681c8..66b55dc7 100644 --- a/src/doc/Makefile.am +++ b/src/doc/Makefile.am @@ -16,10 +16,6 @@ # along with this program. If not, see . # -# -# $Id$ -# - GENERATED_TEXINFOS = \ $(builddir)/programmers.texi \ $(builddir)/parts.texi \ diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 3613631e..e17850e6 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -1,8 +1,6 @@ %% -*-texinfo-*- \input texinfo -@c $Id$ - @setfilename avrdude.info @settitle AVRDUDE @finalout diff --git a/src/dryrun.c b/src/dryrun.c index 8e125bfd..e923fe93 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * The dryrun programmer emulates a physical programmer by allocating a copy of the part and * pretending all operations work well. diff --git a/src/dryrun.h b/src/dryrun.h index 7685053a..c6eefb9b 100644 --- a/src/dryrun.h +++ b/src/dryrun.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef dryrun_h__ #define dryrun_h__ diff --git a/src/dryrun_private.h b/src/dryrun_private.h index 6e208846..dd5eb736 100644 --- a/src/dryrun_private.h +++ b/src/dryrun_private.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef dryrun_private_h__ #define dryrun_private_h__ diff --git a/src/fileio.c b/src/fileio.c index 058c8cdc..45a826fd 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/flip1.c b/src/flip1.c index f486ed07..4efc1121 100644 --- a/src/flip1.c +++ b/src/flip1.c @@ -19,8 +19,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/flip1.h b/src/flip1.h index 276229e3..18af3fab 100644 --- a/src/flip1.h +++ b/src/flip1.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef flip1_h #define flip1_h diff --git a/src/flip2.c b/src/flip2.c index 50bb486f..793af44a 100644 --- a/src/flip2.c +++ b/src/flip2.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/flip2.h b/src/flip2.h index 002d3b3c..eed0cfc1 100644 --- a/src/flip2.h +++ b/src/flip2.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef flip2_h #define flip2_h diff --git a/src/freebsd_ppi.h b/src/freebsd_ppi.h index 016bf182..40cf60d5 100644 --- a/src/freebsd_ppi.h +++ b/src/freebsd_ppi.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef freebsd_ppi_h #define freebsd_ppi_h diff --git a/src/ft245r.c b/src/ft245r.c index 7cb93fe7..d245be91 100644 --- a/src/ft245r.c +++ b/src/ft245r.c @@ -19,8 +19,6 @@ */ -/* $Id$ */ - /* ft245r -- FT245R/FT232R Synchronous BitBangMode Programmer default pin assign FT232R / FT245R diff --git a/src/jtag3.c b/src/jtag3.c index 43ae6d5c..1bcdf461 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -18,8 +18,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for Atmel JTAGICE3 programmer */ diff --git a/src/jtag3.h b/src/jtag3.h index b6773dab..c130cb27 100644 --- a/src/jtag3.h +++ b/src/jtag3.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef jtag3_h #define jtag3_h diff --git a/src/jtag3_private.h b/src/jtag3_private.h index a26c5160..451e6a25 100644 --- a/src/jtag3_private.h +++ b/src/jtag3_private.h @@ -18,8 +18,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * JTAGICE3 definitions diff --git a/src/jtagmkI.c b/src/jtagmkI.c index 23923bf5..38683721 100644 --- a/src/jtagmkI.c +++ b/src/jtagmkI.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for Atmel JTAG ICE (mkI) programmer */ diff --git a/src/jtagmkI.h b/src/jtagmkI.h index 0a7ade1b..5d40c6b7 100644 --- a/src/jtagmkI.h +++ b/src/jtagmkI.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef jtagmkI_h #define jtagmkI_h diff --git a/src/jtagmkII.c b/src/jtagmkII.c index be97b147..9ad1bf42 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -21,8 +21,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for Atmel JTAG ICE mkII programmer * diff --git a/src/jtagmkII.h b/src/jtagmkII.h index b4005c9d..ec8d4bc9 100644 --- a/src/jtagmkII.h +++ b/src/jtagmkII.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef jtagmkII_h #define jtagmkII_h diff --git a/src/jtagmkII_private.h b/src/jtagmkII_private.h index d3aec68b..3c581d8f 100644 --- a/src/jtagmkII_private.h +++ b/src/jtagmkII_private.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * JTAG ICE mkII definitions diff --git a/src/jtagmkI_private.h b/src/jtagmkI_private.h index e67e0b3f..e2134823 100644 --- a/src/jtagmkI_private.h +++ b/src/jtagmkI_private.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * JTAG ICE mkI definitions diff --git a/src/lexer.l b/src/lexer.l index f0882904..96d0c776 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - %{ #include #include diff --git a/src/libavrdude.h b/src/libavrdude.h index e0d2d5c0..d61fbdd4 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef libavrdude_h #define libavrdude_h diff --git a/src/linux_ppdev.h b/src/linux_ppdev.h index 9b3469e5..ced79e58 100644 --- a/src/linux_ppdev.h +++ b/src/linux_ppdev.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef linux_ppdev_h #define linux_ppdev_h diff --git a/src/lists.c b/src/lists.c index f44e0947..5c2f5afc 100644 --- a/src/lists.c +++ b/src/lists.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ - /* $Id$ */ - /*---------------------------------------------------------------------- diff --git a/src/main.c b/src/main.c index 4555d342..aa69571c 100644 --- a/src/main.c +++ b/src/main.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * Code to program an Atmel AVR device through one of the supported * programmers. diff --git a/src/par.c b/src/par.c index 490068e9..f0968e61 100644 --- a/src/par.c +++ b/src/par.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/par.h b/src/par.h index e50ea60f..adcca7d0 100644 --- a/src/par.h +++ b/src/par.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef par_h #define par_h diff --git a/src/pgm.c b/src/pgm.c index f815406b..3c3de18e 100644 --- a/src/pgm.c +++ b/src/pgm.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/ppi.c b/src/ppi.c index ee09a598..61bd55ab 100644 --- a/src/ppi.c +++ b/src/ppi.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #if !defined(WIN32) diff --git a/src/ppi.h b/src/ppi.h index 7641dd84..8b64a12a 100644 --- a/src/ppi.h +++ b/src/ppi.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef ppi_h #define ppi_h diff --git a/src/ppiwin.c b/src/ppiwin.c index 077bb7fb..410e3e81 100644 --- a/src/ppiwin.c +++ b/src/ppiwin.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* This is the parallel port interface for Windows built using Cygwin. diff --git a/src/ser_avrdoper.c b/src/ser_avrdoper.c index 2a0ebf7d..8e023ad4 100644 --- a/src/ser_avrdoper.c +++ b/src/ser_avrdoper.c @@ -18,8 +18,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * Serial Interface emulation for USB programmer "AVR-Doper" in HID mode. */ diff --git a/src/ser_posix.c b/src/ser_posix.c index 8962f1cd..cd08e39c 100644 --- a/src/ser_posix.c +++ b/src/ser_posix.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * Posix serial interface for avrdude. */ diff --git a/src/serbb.h b/src/serbb.h index 11808bff..c2233e0a 100644 --- a/src/serbb.h +++ b/src/serbb.h @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -/* $Id$ */ #ifndef serbb_h #define serbb_h diff --git a/src/serbb_posix.c b/src/serbb_posix.c index 81393dd2..bae1f382 100644 --- a/src/serbb_posix.c +++ b/src/serbb_posix.c @@ -17,7 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -/* $Id$ */ /* * Posix serial bitbanging interface for avrdude. diff --git a/src/serbb_win32.c b/src/serbb_win32.c index ec0f7908..958ee16c 100644 --- a/src/serbb_win32.c +++ b/src/serbb_win32.c @@ -17,7 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -/* $Id$ */ /* * Win32 serial bitbanging interface for avrdude. diff --git a/src/serialupdi.c b/src/serialupdi.c index 6c46007d..54f1921e 100644 --- a/src/serialupdi.c +++ b/src/serialupdi.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Interface to the SerialUPDI programmer. * diff --git a/src/serialupdi.h b/src/serialupdi.h index 990c395e..f5b2bdbf 100644 --- a/src/serialupdi.h +++ b/src/serialupdi.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/solaris_ecpp.h b/src/solaris_ecpp.h index 7db040d1..af956f7b 100644 --- a/src/solaris_ecpp.h +++ b/src/solaris_ecpp.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef solaris_ecpp_h #define solaris_ecpp_h diff --git a/src/stk500.c b/src/stk500.c index d3a4b0b6..1cb1d4ef 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for Atmel STK500 programmer * diff --git a/src/stk500.h b/src/stk500.h index 6c9b8188..157fb6be 100644 --- a/src/stk500.h +++ b/src/stk500.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef stk500_h #define stk500_h diff --git a/src/stk500generic.c b/src/stk500generic.c index 2aa331be..b27e4032 100644 --- a/src/stk500generic.c +++ b/src/stk500generic.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for Atmel STK500 programmer * diff --git a/src/stk500generic.h b/src/stk500generic.h index c970ac42..40b6b25d 100644 --- a/src/stk500generic.h +++ b/src/stk500generic.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef stk500generic_h__ #define stk500generic_h__ diff --git a/src/stk500v2.c b/src/stk500v2.c index 35054740..91fc4398 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -19,7 +19,6 @@ * along with this program. If not, see . */ -/* $Id$ */ /* Based on Id: stk500.c,v 1.46 2004/12/22 01:52:45 bdean Exp */ /* diff --git a/src/stk500v2.h b/src/stk500v2.h index 5edcfac2..9f060f3c 100644 --- a/src/stk500v2.h +++ b/src/stk500v2.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef stk500v2_h #define stk500v2_h diff --git a/src/term.c b/src/term.c index a25d63b1..56b7f745 100644 --- a/src/term.c +++ b/src/term.c @@ -18,8 +18,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include diff --git a/src/tpi.h b/src/tpi.h index afb26b97..88c548d2 100644 --- a/src/tpi.h +++ b/src/tpi.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef tpi_h #define tpi_h diff --git a/src/update.c b/src/update.c index 3b1bcb89..a452cdc2 100644 --- a/src/update.c +++ b/src/update.c @@ -18,8 +18,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #include #include #include diff --git a/src/updi_constants.h b/src/updi_constants.h index 93fbc270..348184d9 100644 --- a/src/updi_constants.h +++ b/src/updi_constants.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_link.c b/src/updi_link.c index 735d0a4e..aa555c63 100644 --- a/src/updi_link.c +++ b/src/updi_link.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_link.h b/src/updi_link.h index fe350674..2e16ba0e 100644 --- a/src/updi_link.h +++ b/src/updi_link.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm.c b/src/updi_nvm.c index 441432b3..683a7bea 100644 --- a/src/updi_nvm.c +++ b/src/updi_nvm.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm.h b/src/updi_nvm.h index 50df8f18..60c42b92 100644 --- a/src/updi_nvm.h +++ b/src/updi_nvm.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v0.c b/src/updi_nvm_v0.c index f3f1be64..47324fb5 100644 --- a/src/updi_nvm_v0.c +++ b/src/updi_nvm_v0.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v0.h b/src/updi_nvm_v0.h index fbf4421d..cda8a6f3 100644 --- a/src/updi_nvm_v0.h +++ b/src/updi_nvm_v0.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v2.c b/src/updi_nvm_v2.c index ebf5382b..136a06c3 100644 --- a/src/updi_nvm_v2.c +++ b/src/updi_nvm_v2.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v2.h b/src/updi_nvm_v2.h index 59ff5eb5..0daa1263 100644 --- a/src/updi_nvm_v2.h +++ b/src/updi_nvm_v2.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v3.c b/src/updi_nvm_v3.c index 73c62bc3..b6cebeb3 100644 --- a/src/updi_nvm_v3.c +++ b/src/updi_nvm_v3.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v3.h b/src/updi_nvm_v3.h index 92947400..ca0d3e1f 100644 --- a/src/updi_nvm_v3.h +++ b/src/updi_nvm_v3.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v4.c b/src/updi_nvm_v4.c index 0773983a..67d0901a 100644 --- a/src/updi_nvm_v4.c +++ b/src/updi_nvm_v4.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v4.h b/src/updi_nvm_v4.h index 14a16353..448c3085 100644 --- a/src/updi_nvm_v4.h +++ b/src/updi_nvm_v4.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v5.c b/src/updi_nvm_v5.c index a337678c..4dd10cb0 100644 --- a/src/updi_nvm_v5.c +++ b/src/updi_nvm_v5.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_nvm_v5.h b/src/updi_nvm_v5.h index c1102236..c8ade93f 100644 --- a/src/updi_nvm_v5.h +++ b/src/updi_nvm_v5.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_readwrite.c b/src/updi_readwrite.c index e2ba1766..167e1682 100644 --- a/src/updi_readwrite.c +++ b/src/updi_readwrite.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_readwrite.h b/src/updi_readwrite.h index adef2e8a..7d06c3ff 100644 --- a/src/updi_readwrite.h +++ b/src/updi_readwrite.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_state.c b/src/updi_state.c index 5e0a1ae5..8522a75a 100644 --- a/src/updi_state.c +++ b/src/updi_state.c @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/updi_state.h b/src/updi_state.h index 4579d8fc..552cb469 100644 --- a/src/updi_state.h +++ b/src/updi_state.h @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id$ */ - /* * Based on pymcuprog * See https://github.com/microchip-pic-avr-tools/pymcuprog diff --git a/src/urclock.c b/src/urclock.c index 3c6bd7ea..65db9a0c 100644 --- a/src/urclock.c +++ b/src/urclock.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * The Urclock programmer * diff --git a/src/urclock.h b/src/urclock.h index 4315e0d8..5ea349cf 100644 --- a/src/urclock.h +++ b/src/urclock.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef urclock_h__ #define urclock_h__ diff --git a/src/urclock_hash.h b/src/urclock_hash.h index 80c009bf..01b41cc7 100644 --- a/src/urclock_hash.h +++ b/src/urclock_hash.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef urclock_hash_h__ #define urclock_hash_h__ diff --git a/src/urclock_private.h b/src/urclock_private.h index 65f18179..39fa979a 100644 --- a/src/urclock_private.h +++ b/src/urclock_private.h @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ #ifndef urclock_private_h #define urclock_private_h diff --git a/src/usb_hidapi.c b/src/usb_hidapi.c index 59c6dee4..9b3bed16 100644 --- a/src/usb_hidapi.c +++ b/src/usb_hidapi.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * USB interface via libhidapi for avrdude. */ diff --git a/src/usb_libusb.c b/src/usb_libusb.c index 2b11c862..7d16521e 100644 --- a/src/usb_libusb.c +++ b/src/usb_libusb.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * USB interface via libusb for avrdude. */ diff --git a/src/usbasp.c b/src/usbasp.c index 86957420..44d71689 100644 --- a/src/usbasp.c +++ b/src/usbasp.c @@ -17,8 +17,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * Interface to the USBasp programmer. * diff --git a/src/usbasp.h b/src/usbasp.h index 98d782f1..853c6d90 100644 --- a/src/usbasp.h +++ b/src/usbasp.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef usbasp_h #define usbasp_h diff --git a/src/usbdevs.h b/src/usbdevs.h index 1872bdaf..6fc6b773 100644 --- a/src/usbdevs.h +++ b/src/usbdevs.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * defines for the USB interface */ diff --git a/src/wiring.c b/src/wiring.c index 60b8f705..ecbd945d 100644 --- a/src/wiring.c +++ b/src/wiring.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for Wiring bootloaders * diff --git a/src/wiring.h b/src/wiring.h index dbe42b8b..08d8112a 100644 --- a/src/wiring.h +++ b/src/wiring.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef wiring_h__ #define wiring_h__ diff --git a/src/xbee.c b/src/xbee.c index 378cfc9d..43fb0c72 100644 --- a/src/xbee.c +++ b/src/xbee.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - /* * avrdude interface for AVR devices Over-The-Air programmable via an * XBee Series 2 device. diff --git a/src/xbee.h b/src/xbee.h index 00a1682b..a12f62b2 100644 --- a/src/xbee.h +++ b/src/xbee.h @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* $Id$ */ - #ifndef xbee_h__ #define xbee_h__ diff --git a/tools/get-dw-params.xsl b/tools/get-dw-params.xsl index a3f083e9..69e76ab7 100644 --- a/tools/get-dw-params.xsl +++ b/tools/get-dw-params.xsl @@ -15,8 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * - * $Id$ -->